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

Unified Diff: chrome/common/spellcheck_common.cc

Issue 11748005: Merge 174304 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/hyphenator/hyphenator_message_filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/spellcheck_common.cc
===================================================================
--- chrome/common/spellcheck_common.cc (revision 174841)
+++ chrome/common/spellcheck_common.cc (working copy)
@@ -9,13 +9,17 @@
namespace chrome {
namespace spellcheck_common {
-static const struct {
- // The language.
- const char* language;
+struct LanguageRegion {
+ const char* language; // The language.
+ const char* language_region; // language & region, used by dictionaries.
+};
- // The corresponding language and region, used by the dictionaries.
- const char* language_region;
-} g_supported_spellchecker_languages[] = {
+struct LanguageVersion {
+ const char* language; // The language input.
+ const char* version; // The corresponding version.
+};
+
+static const LanguageRegion g_supported_spellchecker_languages[] = {
// Several languages are not to be included in the spellchecker list:
// th-TH
{"af", "af-ZA"},
@@ -58,10 +62,19 @@
{"vi", "vi-VN"},
};
+bool IsValidRegion(const std::string& region) {
+ for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages);
+ ++i) {
+ if (g_supported_spellchecker_languages[i].language_region == region)
+ return true;
+ }
+ return false;
+}
+
// This function returns the language-region version of language name.
// e.g. returns hi-IN for hi.
std::string GetSpellCheckLanguageRegion(const std::string& input_language) {
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(g_supported_spellchecker_languages);
+ for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages);
++i) {
if (g_supported_spellchecker_languages[i].language == input_language) {
return std::string(
@@ -78,13 +91,7 @@
// with additional words found by the translation team.
static const char kDefaultVersionString[] = "-1-2";
- static const struct {
- // The language input.
- const char* language;
-
- // The corresponding version.
- const char* version;
- } special_version_string[] = {
+ static LanguageVersion special_version_string[] = {
{"es-ES", "-1-1"}, // 1-1: Have not been augmented with addtional words.
{"nl-NL", "-1-1"},
{"sv-SE", "-1-1"},
@@ -121,7 +128,7 @@
std::string language = GetSpellCheckLanguageRegion(input_language);
std::string versioned_bdict_file_name(language + kDefaultVersionString +
".bdic");
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(special_version_string); ++i) {
+ for (size_t i = 0; i < arraysize(special_version_string); ++i) {
if (language == special_version_string[i].language) {
versioned_bdict_file_name =
language + special_version_string[i].version + ".bdic";
@@ -134,7 +141,7 @@
std::string GetCorrespondingSpellCheckLanguage(const std::string& language) {
// Look for exact match in the Spell Check language list.
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(g_supported_spellchecker_languages);
+ for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages);
++i) {
// First look for exact match in the language region of the list.
std::string spellcheck_language(
@@ -154,7 +161,7 @@
}
void SpellCheckLanguages(std::vector<std::string>* languages) {
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(g_supported_spellchecker_languages);
+ for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages);
++i) {
languages->push_back(g_supported_spellchecker_languages[i].language);
}
« no previous file with comments | « no previous file | content/browser/hyphenator/hyphenator_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698