Google Chrome Extension Internationalization

Wednesday, January 13, 2010

Starting with Google Chrome developer channel release 4.0.288.1 and beta channel release 4.0.249.64 for Windows, an internationalization (i18n) framework for Google Chrome Extensions is available and enabled by default. This framework lets extension developers translate user-visible parts of the extension manifest — such as the name and description, and localize messages using simple JavaScript calls to the chrome.i18n.getMessage() method. We've implemented this feature as described in the design docs for Chromium.

The following screenshots show a browser action's tooltip that has been translated into English, Spanish, Serbian, and Korean.



To localize the extension manifest, extract all user-visible strings into message catalogs, and define the default locale.

{
"name": "__MSG_name__",
"description": "__MSG_description__",
...
"default_locale": "en",
...
}

To get translated messages in JavaScript code, including extension code and content scripts, invoke one of the following forms of chrome.i18n.getMessage().

chrome.i18n.getMessage("messagename")
chrome.i18n.getMessage("messagename", "one parameter")
chrome.i18n.getMessage("messagename", ["one", "to", "nine", "parameters"])

For more details, see the documentation.

We're more than happy to hear your feedback, not only on our implementation and documentation, but also on the API design. You can reach us at the chromium-extensions group.

Post a Comment