jamesarosen/ember-i18n

Dynamic update of <html lang="en"> with FastBoot support

Closed this issue · 2 comments

How do I dynamically update the language attribute of the html tag:<html lang="en">?

@daniel-de-wit document.documentElement.setAttribute('lang','ru')

@lifeart Thanks, I was hoping for a built-in solution that works with FastBoot as well. I've should have made that more clear, I updated the title.

Using an instance-initializer I seem to get it working:

export default {
    after: 'ember-i18n',
    name: 'set-app-locale',

    initialize(application) {
        application.lookup('service:-document').documentElement.setAttribute('lang', 'nl');
    },
};