1

I have a i18n folder with 7 csv files which contain keys and translation into 7 different languages.

Then I go into admin panel and in General->Locale options, I select a language which is contained in my i18n folder.
All works fine as expected (I see correct translation in frontend checkout page).

But when within admin panel, I select the locale which I don’t have in my i18n folder, then in frontend checkout page I only see translation keys (and not translation them selves).

Is there a way to set a default fallback language to English for example, when the current selected language is not supported?

0

I figured out one way of doing this: extend \Magento\Framework\Phrase\Renderer\Translate and the function “render”.

The “render” function normally returns a translation based on a translation key. If this is not the case and this function tries to return the translation key itself, this means the translation did not happen.

I fixed this problem by adding something like:

if ($translatedWord == $translationKey) { // translation did not happen
    return $englishTranslations[$translationKey];
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.