Localisation in


#1

Hello

Depending of a the context of use, I need to “translate” some words in the same locale.

An example :
in the first context, the word “team” is called a "team"
in the second context, the word “team” is called a "group"
in the third context, the word “team” is called a “troop”

What is the best way to do that with the localisation functions of cakephp 3 ?

I can use :I18n::setLocale('context1'); ?
Thanks
F.


#2

Hi,

You can use the __d(‘domain’, ‘key’) or __x(‘context’, ‘key’) function to achieve that. Note that you need multiple translation files when you want to use the __d()-function (where the name of the translation file refers to the ‘domain’.

Please have a look here for further detail:
https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#using-translation-functions

Best regards


#3

Hello,

__d is the solution for me.

Thanks,