c00000fd c00000fd - 2 months ago 8
HTML Question

Internationalization of HTML pages for my Google Chrome Extension

I found a very easy way to implement translation (or localization) of my Google Chrome Extension, but that seems to apply only to

.json
,
css
and
js
files.

But how to localize my
html
content, say in the popup or an options window?

Xan Xan
Answer

As RobW noted in a comment, there is an open feature request for adding i18n support in HTML using the same mechanism. As of now, indeed you can't use the same approach.

The issue mentions one possible workaround: to have separate HTML pages per language and switch between them in the manifest:

  "browser_action": {
    "default_popup": "__MSG_browser_action_page__"
  }

But if that's not a suitable approach, the only way is to translate the page dynamically via JavaScript. You mention a solution the simplest approach, by just tagging elements to translate with ids and replacing them on page load.

You can also employ more sophisticated tools like webL10n in parallel with Chrome's approach. Note that you should probably still minimally implement Chrome's approach, so that Web Store knows that the item is supporting several languages.