0

We need to have ability in code use inline translations with translated strings from csv files with selected locale, which is different from store. For example, user select english language in frontend, but we want to create PDF or rend email with de_DE translations. We want to get something like this (not correct this code)

> setLocale('de_DE');
> __('Good morning'); 

// Guten Morgen

thanks

  • I have setUp by default, for example, English. Plus shop has many languages in Frontend for clients. And we have all translations in csv files in correct folders. everything work good. BUT, i want select directly in code to what language will translate strings, despite default locale in Backend and selected language for shop by Client. – yehor test Jun 20 '17 at 15:47
0

I have found the solution!!!! I have tried a lot of code and recommendations. But for me one way to solve my problem is next: So in Magento\Framework\App\Language\Dictionary class exist

function getDictionary($locale) 

what returns array from csv files for selected locale. then I just get value from array by key - default string in base language - English.

| 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.