Translation service
Esta página aún no está disponible en tu idioma.
Zumito comes with a localization system by default.
Define translations
The first step to start using the translations system is to register some texts. to do so, simply create a json file on the translations
folder of your bundle with the name of the lang in ISO 639-1 format
Examples:
Directorysrc
Directorymodules
Directoryexample
Directorytranslations
- en.json
- es.json
DirectoryexampleSubkey2
- en.json
- es.json
Then in the json just write your text with a key.
en.json
es.json
exampleSubkey2/en.json
Obtain translations
Now we have set some translations let’s obtain the translated text. To do so, first we need to import the translator service. To do so, first we need to import the serviceContainer like here:
then in our code import the translator service:
And get your translated texts by the key and language:
Translation variables
Somethings translations need to have variable text, like user info or other data. You can define a text with one or multiple variables encapsulated with brakets:
en.json
then you can get the translation like this: