Change hardcoded language via localization

I have a website which uses CakePHP’s localization. The website text is hardcoded in Cake’s __('') function in the Polish language and I have language files for English and Hungarian.

I’m trying to figure out a way to replace all the hardcoded polish strings in the __('') functions with their english translation from the language files.

I’d like to do this in order to create content for my website in English and then later translate it, rather than creating it in Polish and then translating it.

I’ve read the documentation (https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html) and found nothing. The CakePHP translator uses po/pot files. Any ideas?

still not sure what you dont understand, the usuall way to do translations is

  1. use __('translate me'); in files
  2. in console bin/cake i18n extract
  3. translate po files
  4. put it in `/Locale/pl_PL’ for example
  5. I18n::setLocale('pl-PL'); or any other lang, i like to pass lang as route param but its up to you, you can also use browser request header

and thats it, iirc you just need to use pl or pl_PL as pattern for dirs in Locale, as side note it helps translators to use __dx(''); instead of pure __(''); as some translations tends to be ambiguous

Hi, thanks for responding. That’s not the issue. My problem is that I have echo __('Polskie zdanie'); in my php file and a .po file for English in ‘/Locale/en’ and a .po for Hungarian in ‘/Locale/hu’.

I want to have echo __('English language sentence'); and a .po file in ‘/Locale/pl’ for Polish and keep the hungarian one as is. I want to swap out the language in the hardcoded php file as my new developers dont speak Polish and when they’re working on php files they are reading Polish strings in the __('') function.

I’d like to swap out what’s in my php files with what’s in my ‘/Locale/en’ file and then store the polish version in ‘/Locale/pl’.

ah so you want to swap en and pl around, sorry but there is no such functionality out of box, you could probably translate it to en, and write your custom script to swap them but its quite a bit of work