$ composer create-project nette/web-project
$ composer require kdyby/translation
config.neon
we will add an extension to enable Kdyby\Translation:$locale
and $tranlator
. Using [Dependency Injection | doc:di] mechanism we get an injected Kdyby\Translation\Translator service. (In my example, I don't use any BasePresenter, instead I only use the HomepagePresenter).RouterFactory.php
ui.cs_CZ.neon
and ui.en_US.neon
to the folder app/lang
. Here ui
is the name of our dictionary and cs_CZ
is a combination of language and state. (ISO_639-1 and ISO 3166-1)fr_CA
.Keeping both the language and the country in the culture is necessary because you may have a different French translation for users from France, Belgium or Canada, and a different Spanish content for users from Spain or Mexico. The language is a code of two lowercase characters, according to the ISO 639-1 standard (for instance, en for English). The country is a code of two uppercase characters, according to the ISO 3166-1 standard (for instance, GB for Great Britain).
{_ ui.title}
for putting translated phrase.