diff options
author | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-22 01:05:58 +0000 |
---|---|---|
committer | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-22 01:05:58 +0000 |
commit | 545af6a24a8a5648ad2f801a3bd73bd9229cb026 (patch) | |
tree | 88954d45213a68a8de0740ac25928a6652c88ec9 /chrome/common | |
parent | d3c0fe8bb3b20f03eaa7535daeddc15e83e9cea6 (diff) | |
download | chromium_src-545af6a24a8a5648ad2f801a3bd73bd9229cb026.zip chromium_src-545af6a24a8a5648ad2f801a3bd73bd9229cb026.tar.gz chromium_src-545af6a24a8a5648ad2f801a3bd73bd9229cb026.tar.bz2 |
Adding localization for English and Serbian to the news sample (and copying news into i18n_news since support in Chrome is
not pushed yet to dev).
This example shows how to localize manifest and user visible messages using Chrome l10n infrastructure.
I would have used static message replacement for all messages in feed.html, except error handling, if we had it.
Review URL: http://codereview.chromium.org/509019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35125 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
4 files changed, 128 insertions, 9 deletions
diff --git a/chrome/common/extensions/docs/examples/extensions/news/_locales/en/messages.json b/chrome/common/extensions/docs/examples/extensions/news/_locales/en/messages.json new file mode 100644 index 0000000..0288725 --- /dev/null +++ b/chrome/common/extensions/docs/examples/extensions/news/_locales/en/messages.json @@ -0,0 +1,59 @@ +{ + "name": { + "message": "News Reader", + "description": "Extension name in manifest." + }, + "description": { + "message": "Displays the first 5 items from the '$Google$ News - top news' RSS feed in a popup.", + "description": "Extension description in manifest.", + "placeholders": { + "google": { + "content": "Google", + "example": "Google" + } + } + }, + "default_title": { + "message": "$Google$ News", + "description": "Extension browser action tooltip text in manifest.", + "placeholders": { + "google": { + "content": "Google", + "example": "Google" + } + } + }, + "unknown_title": { + "message": "Unknown title", + "description": "Unknown news title." + }, + "error": { + "message": "Error: $error$", + "description": "Generic error template. Expects error parameter to be passed in.", + "placeholders": { + "error": { + "content": "$1", + "example": "Failed to fetch RSS feed." + } + } + }, + "failed_to_fetch_rss": { + "message": "Failed to fetch RSS feed.", + "description": "User visible error message." + }, + "not_a_valid_feed": { + "message": "Not a valid feed.", + "description": "User visible error message." + }, + "more_stories": { + "message": "To $Google$ News \u00BB", + "description": "Link name to more Google News.", + "placeholders": { + "google": { + "content": "Google", + "example": "Google" + } + } + } +} + diff --git a/chrome/common/extensions/docs/examples/extensions/news/_locales/sr/messages.json b/chrome/common/extensions/docs/examples/extensions/news/_locales/sr/messages.json new file mode 100644 index 0000000..7d43d7a --- /dev/null +++ b/chrome/common/extensions/docs/examples/extensions/news/_locales/sr/messages.json @@ -0,0 +1,59 @@ +{ + "name": { + "message": "Читач вести", + "description": "Назив екстензије у манифесту." + }, + "description": { + "message": "Приказује првих 5 вести са '$Google$ Вести - главне вести' у прозорчићу.", + "description": "Опис екстензије у манифесту.", + "placeholders": { + "google": { + "content": "Google", + "example": "Google" + } + } + }, + "default_title": { + "message": "$Google$ Вести", + "description": "Назив дугмета екстензије.", + "placeholders": { + "google": { + "content": "Google", + "example": "Google" + } + } + }, + "unknown_title": { + "message": "Непознат наслов", + "description": "Непознат наслов вести." + }, + "error": { + "message": "Грешка - $error$", + "description": "Општи облик грешке.", + "placeholders": { + "error": { + "content": "$1", + "example": "фид је недоступан." + } + } + }, + "failed_to_fetch_rss": { + "message": "фид је недоступан.", + "description": "Порука грешке коју види корисник када је фид недоступан." + }, + "not_a_valid_feed": { + "message": "неисправан фид.", + "description": "Порука грешке коју види корисник када је фид неисправан." + }, + "more_stories": { + "message": "Ка $Google$ Вестима \u00BB", + "description": "Назив везе ка још вести.", + "placeholders": { + "google": { + "content": "Google", + "example": "Google" + } + } + } +} + diff --git a/chrome/common/extensions/docs/examples/extensions/news/feed.html b/chrome/common/extensions/docs/examples/extensions/news/feed.html index 6592a87..4d7ca01 100644 --- a/chrome/common/extensions/docs/examples/extensions/news/feed.html +++ b/chrome/common/extensions/docs/examples/extensions/news/feed.html @@ -119,19 +119,19 @@ function main() { function handleFeedParsingFailed(error) { var feed = document.getElementById("feed"); feed.className = "error"; - feed.innerText = "Error: " + error; + feed.innerText = chrome.i18n.getMessage("error", error); } // Handles errors during the XMLHttpRequest. function handleError() { - handleFeedParsingFailed('Failed to fetch RSS feed.'); + handleFeedParsingFailed(chrome.i18n.getMessage('failed_to_fetch_rss')); } // Handles parsing the feed data we got back from XMLHttpRequest. function handleResponse() { var doc = req.responseXML; if (!doc) { - handleFeedParsingFailed("Not a valid feed."); + handleFeedParsingFailed(chrome.i18n.getMessage('not_a_valid_feed')); return; } buildPreview(doc); @@ -190,7 +190,7 @@ function buildPreview(doc) { if (itemTitle) { itemTitle = itemTitle.textContent; } else { - itemTitle = "Unknown title"; + itemTitle = chrome.i18n.getMessage("unknown_title"); } // Grab the description. @@ -235,7 +235,7 @@ function buildPreview(doc) { if (moreStoriesUrl) { var more = document.createElement("a"); more.className = "more"; - more.innerText = "More stories \u00BB"; + more.innerText = chrome.i18n.getMessage("more_stories"); more.addEventListener("click", moreStories); feed.appendChild(more); } diff --git a/chrome/common/extensions/docs/examples/extensions/news/manifest.json b/chrome/common/extensions/docs/examples/extensions/news/manifest.json index f0c7e0e..681d6ef 100644 --- a/chrome/common/extensions/docs/examples/extensions/news/manifest.json +++ b/chrome/common/extensions/docs/examples/extensions/news/manifest.json @@ -1,15 +1,16 @@ { - "name": "News Reader", + "name": "__MSG_name__", "version": "1.1", - "description": "Displays the first 5 items from the 'Google News - top news' RSS feed in a popup.", + "description": "__MSG_description__", "icons": { "128": "news_icon.png" }, "browser_action": { - "default_title": "Google News", + "default_title": "__MSG_default_title__", "default_icon": "news_action.png", "popup": "feed.html" }, "permissions": [ "tabs", "http://news.google.com/*" - ] + ], + "default_locale": "en" } |