Can anybody explain how to use a locale that is set up globally in an initializer as follows:
#initializers/i18n.js
export function initialize(applicationInstance) {
let i18n = applicationInstance.lookup('service:i18n');
let moment = applicationInstance.lookup('service:moment');
let locale = calculateLocale(i18n.get('locales'));
i18n.set('locale', locale);
moment.setLocale(locale);
}
function calculateLocale(locales) {
// whatever you do to pick a locale for the user:
const language = navigator.languages[0] || navigator.language || navigator.userLanguage;
return locales.includes(language.toLowerCase()) ? language : 'en-GB';
}
export default {
name: 'i18n',
initialize
};
in ember-pikaday
add-on ? I tried to follow the steps in their README without success.
Thank you.