Ember-i18n location fallback

275 Views Asked by At

I am trying to introduce ember-i18n into my current project to manage translations across different varieties of english. Specifically, aiming to handle en-US & general en words. The issue I am having is that even if I specify the i18n.locale to be en-US it still uses the translations form the en/translations.js file. This is happening even if the defaultLocale is set to en-US in the config/environment.js

I have specified two translation files:

locales/
├── en
│   └── translations.js
└── en-US
    └── translations.js

with the following contents:

app/locales/en/translations.js

export default {                                                                                                                                                                                                                                                                                                                
  cheque: 'Cheque',                                                                                                                                                                                                                                                                                                           
  province: 'Province',                                                                                                                                                                                                                                                                                                       
  postalCode: 'Postal Code',                                                                                                                                                                                                                                                    
};

app/locales/en-US/translations.js

export default {                                                                                                                                                                                                                                                                                                              
  cheque: 'Check',                                                                                                                                                                                                                                                                                                            
  province: 'State',                                                                                                                                                                                                                                                                                                          
  postalCode: 'Zip Code',                                                                                                                                                                                                                                                                                                     
};    

Any ideas why the I can't get the location fallback to work as intended?

references:

Ember-i18n Wiki - Location Fallback

1

There are 1 best solutions below

0
On BEST ANSWER

James A. Rosen answered my question in this tweet. The issue was that the folder needs to be lower case (en-us instead of en-US).

The default Ember-CLI resolver downcases all module names.

Because it didn't recognize that I had an en-us folder it was defaulting to the en translations.