Our site specifies the language for a page in the URL - http://oursite/en/whatever. I am using a route to pick this up and set the locale to use for the content. We even perform substitutions, so that http://oursite/zh/whatever behaves like (or redirects to) http://oursite/cn/whatever. So far so good.
However, there are a few things that are needed for SEO and accessibility that aren’t in the rendered body content:
- The lang attribute on the html tag: <html lang=“zh”>
- The description meta, which should be in localized text, preferably pulled from our ember-i18n strings.
- The rel=canonical, which needs to specify the URL with cn rather than zh, etc.
From what I’ve read, ember-cli-head should be perfect for the latter two. However, what’s the right way to set the language in the html tag? I can backfill it from my route, but will screen readers be able to adjust if the page language adjusts after the initially rendered page? Is there something I can use with fastboot so the page always renders with the html lang attribute tracking the ISO language corresponding to the language from the URL? I can’t DOM-hack from fastboot…