We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Gettext instantiation and file paths

Hello guys, I'm new to gettext and have two questions. Given the "requirements" described below:

1) How would instantiation of gettext look like?

2) Where will gettext search for files?

  • When changing locale, I want that to affect everything. So category is LC_ALL
  • I want to set Serbian (sr_RS) with character UTF8 character encoding
  • locale -a returns sr_RS.utf8

To clarify my question, please write an example of how would you instantiate Gettext adapter given above requirements and where will Gettext look for files given that configuration.

Thank you!

edited Jun '16

Refer to: https://docs.phalcon.io/en/latest/reference/translate.html

Note: Gettext adapter is documented elsewhere: https://docs.phalcon.io/en/latest/api/Phalcon_Translate_Adapter_Gettext.html

Pozdrav! ☺

Thanks, buraz, but still that does not help. Tbh, in most cases, I find source code more helpful than docs :)

Given how many sub-questions I have, I thought the easiest way to help me out would be to write params that you would pass and then the path Gettext would look for given the params passed. Learning by example is the easiest I guess :)

Or, the questions: Do I need sr_RS.utf8 or will sr_RS be enough? Shouldn't bind_textdomain_codeset be called somewhere? Should locale folder be named sr_RS.utf8 or just sr_RS? Do I need folder LC_MESSAGES? Will it look for it even if category is set to LC_ALL?

I know the questions are more gettext-related than phalcon, but given that I'm not familiar with gettext that much, this forum was safe bet.

Thanks :)