Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: chrome/common/extensions/extension_l10n_util.cc

Issue 22801019: Provide i18n support for descriptions in commands API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/extension_l10n_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/extensions/extension_l10n_util.h" 5 #include "chrome/common/extensions/extension_l10n_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 // Initialize app.launch.local_path. 162 // Initialize app.launch.local_path.
163 if (!LocalizeManifestValue(keys::kLaunchLocalPath, messages, manifest, error)) 163 if (!LocalizeManifestValue(keys::kLaunchLocalPath, messages, manifest, error))
164 return false; 164 return false;
165 165
166 // Initialize app.launch.web_url. 166 // Initialize app.launch.web_url.
167 if (!LocalizeManifestValue(keys::kLaunchWebURL, messages, manifest, error)) 167 if (!LocalizeManifestValue(keys::kLaunchWebURL, messages, manifest, error))
168 return false; 168 return false;
169 169
170 // Initialize description of commmands.
171 base::DictionaryValue* commands_handler = NULL;
172 if (manifest->GetDictionary(keys::kCommands, &commands_handler)) {
173 for (DictionaryValue::Iterator iter(*commands_handler); !iter.IsAtEnd();
174 iter.Advance()) {
175 key.assign(base::StringPrintf("commands.%s.description",
176 iter.key().c_str()));
177 if (!LocalizeManifestValue(key, messages, manifest, error))
178 return false;
179 }
180 }
181
170 // Add current locale key to the manifest, so we can overwrite prefs 182 // Add current locale key to the manifest, so we can overwrite prefs
171 // with new manifest when chrome locale changes. 183 // with new manifest when chrome locale changes.
172 manifest->SetString(keys::kCurrentLocale, CurrentLocaleOrDefault()); 184 manifest->SetString(keys::kCurrentLocale, CurrentLocaleOrDefault());
173 return true; 185 return true;
174 } 186 }
175 187
176 bool LocalizeExtension(const base::FilePath& extension_path, 188 bool LocalizeExtension(const base::FilePath& extension_path,
177 base::DictionaryValue* manifest, 189 base::DictionaryValue* manifest,
178 std::string* error) { 190 std::string* error) {
179 DCHECK(manifest); 191 DCHECK(manifest);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale) 379 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale)
368 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) { 380 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) {
369 extension_l10n_util::SetProcessLocale(locale); 381 extension_l10n_util::SetProcessLocale(locale);
370 } 382 }
371 383
372 ScopedLocaleForTest::~ScopedLocaleForTest() { 384 ScopedLocaleForTest::~ScopedLocaleForTest() {
373 extension_l10n_util::SetProcessLocale(locale_); 385 extension_l10n_util::SetProcessLocale(locale_);
374 } 386 }
375 387
376 } // namespace extension_l10n_util 388 } // namespace extension_l10n_util
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension_l10n_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698