CakePHP v4.2 - Language Issue - again, displaying different static text translation than language locale set


I have project which based on user that logged in has option to put content
in one or more languages and have different default language.

What I want to do is to be able to switch which static text translations I use.
Example: I want user to be able to put French as main content yet display all texts __(“Text”); from French translation file. This is easy I setup locale to FR, and all is fine. French content + French translation.

Example 2 (the problem): I want user to be able to put content as English (not English translation into i18n table!) and still show him French translated text so __(“Text”) would show French translation not English one.

Back in the day there were L10n and i18n. Now I’m really lost and already tried some methods to cheat the system but I always get either wrong static text translations or system changes “default language everywhere”.

To sum up. after user is logged in I want to be able to choose which fr/default.po or en/default.po file will load without affecting the system loading content from DB/dates/currencies :smiley:

Yes crazy… but this is the issue I have to solve -.-

Exactly what version of CakePHP are you using?

Cakephp 4.2, damn forgot to mention it on starrt

And what, specifically, is not covered by the Internationalization & Localization page of the manual? It’s got sections on setting the default and changing it at runtime.

The problem I listed in example two.
I want the logged in user to see labels, static texts, etc that uses __() translated into one language example English
while all content loaded from DB and 18n tables in specific language example French.
Basically I want to have 2 languages at same time.
One that is used to fulfil forms and DB and stored in i18n table. While keeping the warnings/notifications and static text in different langauge
When I do \Cake\I18n\I18n::setLocale(‘en’); it changes everything.
What I want is to run \Cake\I18n\I18n::setLocale(‘en’);
and do if(specific_user) {
load(fr/default.po) file instead of en/default.po
So he can continue to work and update English content, but see static texts in French

I guess my next question would be why you need to do this. Is it so that someone working in English, with English menus and field names and help text and error messages, can update French names and descriptions of things in the database? If so, maybe you don’t really need to do what you think, and instead the translate behavior is the thing? This lets you build your edit pages such that the default values for the fields are pulled from the desired translation, and that translation is what’s updated in the database, without affecting the UI at all.

Because it’s course project.
There are courses in multi languages and I’m already using translate behaviour and all was working perfect. Until they requested that some of the content creators would like to have the static texts in their native language, so I thought no problem \Cake\I18n\I18n::setLocale(‘en’); !
Wrong, when I change this the translate behaviour goes bazingas and starts adding translations of previous “original” language that some other user created with setting \Cake\I18n\I18n::setLocale(‘fr’);

I was hoping there is some option to just change the translation file which is loaded for specific users.

Also I’m looking for configuration level tweak to avoid reworking multiple forms