cancel
Showing results for 
Search instead for 
Did you mean: 

Translations fall back on en_US instead of original key

Translations fall back on en_US instead of original key

Currently the translations in Magento 2 will use the original string if there is no translation.

For instance:

en_US.csv:

 

"My First String","My First Translation"
"My Second String","My Second Translation"

nl_NL.csv:

 

"My First String","Mijn Eerste Vertaling"

if you do the following when language is set to 'en_US':

echo __('My First String') . '<br>'
. __('My Second String'). '<br>'
. __('My Third String');

The output will be: 
My First Translation
My Second Translation
My Third String
(falls back on original string)

 

 

if you do this when language is set to 'nl_NL':, the output will be:
Mijn eerste vertaling
My Second String
(falls back on original string)

My Third String (falls back on original string)

 

I think it would be really useful for it to fall back on the default language first, so the output would be:

Mijn eerste vertaling
My Second translation (falls back on en_US translation)
My Third String
(falls back on original string)

 

Why?

Because this would open up the ability to use short placeholder strings in the code, instead of the long translations.
For instance, you could do:

"ACCOUNT_NOT_CONFIRMED","This account is not confirmed. <a href=""%1"">Click here</a> to resend confirmation email."

 

This also gives the benefit of being able to correct the en_US language files (for instance when having spelling mistakes) without having to worry about translations or the string in the code.