You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've a app that support multi language (fr & en) and is available for different "countries". This country parameters depends on a route (so we have 2 parameters that operate on the translation , locale + country
What I would like to do is to be able to override some translation keys per country for the same language.
Example :
Http call to http://MyApp/en/germany/myForm will give me a different than http://MyApp/en/france/myForm because the translator nows that for 'france' it should get the translation from another path than for 'germany'. So it will override the default folder that includes all default translations ..
I was wondering how to create multiple translator instances that have it's proper paths of translations files, and have a factory that return the right translatorService regarding the country parameter.
What is the best way to achieve that ?
Thanks for helping
The text was updated successfully, but these errors were encountered:
Ideally you need to use specific country in the locale, i.e. instead of just en you need to use en_GB, en_US, etc. And so instead messages.en.yaml you would create different translation files for the specific country, i.e. messages.en_GB.yaml, messages.en_US.yaml, see some examples from the Symfony Demo: https://github.com/symfony/demo/tree/main/translations . In this case Symfony translator would handle everything for you picking up correct translation base on country. But in case you want to handle it yourself via a special route parameter - not sure, it would lead to a workaround and extra work from your side probably.
This solution would not fit as I used a country parameter as example but it could be another.
Do you have any example where I can override some paths of the translator ? or create different instances ?
Thanks for your help
Hi,
I've a app that support multi language (fr & en) and is available for different "countries". This country parameters depends on a route (so we have 2 parameters that operate on the translation , locale + country
What I would like to do is to be able to override some translation keys per country for the same language.
Example :
Http call to http://MyApp/en/germany/myForm will give me a different than http://MyApp/en/france/myForm because the translator nows that for 'france' it should get the translation from another path than for 'germany'. So it will override the default folder that includes all default translations ..
I was wondering how to create multiple translator instances that have it's proper paths of translations files, and have a factory that return the right translatorService regarding the country parameter.
What is the best way to achieve that ?
Thanks for helping
The text was updated successfully, but these errors were encountered: