Statistics
25
1
0
5d
Badges
Dependencies

Translate

High Performance Localization Component for Nette Framework

Build Status Coverage Status Code Climate Scrutinizer Code Quality

composer require rostenkowski/translate

Requirements

  • PHP 7.1+
  • nette/di
  • nette/neon
  • nette/safe-stream
  • nette/utils
  • nette/tester

Translations

Translations are stored by default in *.neon files in this format:

# simple message
Welcome!: Vítejte!

# with placeholder
Hi %s!: Ahoj %s! 

# multiple forms
You have %s points.: 
  - Máte %s bod.
  - Máte %s body.
  - Máte %s bodů.

Usage with Nette Framework

Put your translations to %appDir%/translations directory as cs_CZ.neon etc.

# register extension
extensions:
  translate: Rostenkowski\Translate
  
# configuration
translate:
  default: cs_CZ

Usage with plain PHP

<?php

namespace App;

require __DIR__ . '/vendor/autoload.php';

use Rostenkowski\Translate\Translator;
use Rostenkowski\Translate\NeonDictionary\NeonDictionaryFactory;

// both translations and cache are in the same directory
$translator = new Translator(new NeonDictionaryFactory(__DIR__, __DIR__));
$translator->setLocale('cs_CZ');
$translator->translate('Welcome!');

Contributing

# run tests
vendor/bin/tester -c tests/php.ini tests/

# code coverage report (requires xdebug)
vendor/bin/tester -c tests/php-coverage.ini --coverage-src src/ --coverage ~/coverage-report.html tests/  

# remove test artifacts
rm -rf tests/temp/cache/
  • v1.0.0 Introducing Translate

    High Performance Localization Component for PHP 7

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com