I am looking for a working i18n example for Twig (the template engine).
Documentation is a bit sparse when it comes to language files. Where should they go, how should
I've tried everything possible in slim 3 but nothing was working, only slim 2, so I've created my own way. Basically the system detects the language from the browser and load the correct translation file, more details in the picture:
The twig i18n extension is based on gettext. So first of all everything related to gettext applies. You find that documented here: Gettext Docs.
So now to the more concrete parts of you question, but please ensure you've at least understood the basic principles with gettext:
Where should they [the language files] go
Into the directory that has been registered for the text-domain.
, how should they look and what should they be named?
Language files should be named the following:
text-domain-
locale.po/mo
Example for a text domain called myAppPhp
and the fr_FR
locale:
myAppPhp-fr_FR.po
myAppPhp-fr_FR.mo
I have been trying with
.po/.mo
files, no luck.
.po/.mo
sounds good to me, maybe you have just missed the path where to move them or you have forgotten to add the text-domain in front.