PHP code example of zemistr / l10n-nette-translator
1. Go to this page and download the library: Download zemistr/l10n-nette-translator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zemistr / l10n-nette-translator example snippets
php composer.phar
/** @var \l10nNetteTranslator\Translator */
protected $translator;
public function injectTranslator(\l10nNetteTranslator\Translator $translator) {
$this->translator = $translator;
}
protected function beforeRender() {
$this->template->setTranslator($this->translator);
}
class XxxPresenter extends \Nette\Application\UI\Presenter {
public function createComponentForm() {
$form = new Form();
$form->setTranslator($this->translator);
...
return $form;
}
}
class XxxPresenter extends \Nette\Application\UI\Presenter {
public function actionDefault() {
// argument must be ISO 639-1 code
$this->translator->setActiveLanguageCode('cs');
}
}
latte
// users -> singular => %n% person
// users -> plural 1 => %n% people
{_'users'} // 1 person
{_'users', 0} // 0 people
{_'users', 50} // 50 people
----
// user -> singular => I am %firstname% %lastname%
{_'user', ['%firstname%' => 'John','%lastname%' => 'Doe']} // I am John Doe
{_'user', 1, ['%firstname%' => 'John','%lastname%' => 'Doe']} // I am John Doe
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.