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

Side by Side Diff: chrome/browser/spellchecker.cc

Issue 89006: [chromium-reviews] Add Australian English spell check support. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/third_party/hunspell/dictionaries/README_en_AU.txt » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/browser/spellchecker.h" 5 #include "chrome/browser/spellchecker.h"
6 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/common/pref_service.h" 23 #include "chrome/common/pref_service.h"
24 #include "chrome/third_party/hunspell/src/hunspell/hunspell.hxx" 24 #include "chrome/third_party/hunspell/src/hunspell/hunspell.hxx"
25 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
26 #include "grit/locale_settings.h" 26 #include "grit/locale_settings.h"
27 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
28 28
29 using base::TimeTicks; 29 using base::TimeTicks;
30 30
31 static const int kMaxSuggestions = 5; // Max number of dictionary suggestions. 31 static const int kMaxSuggestions = 5; // Max number of dictionary suggestions.
32 32
33
33 namespace { 34 namespace {
34 35
35 static const struct { 36 static const struct {
36 // The language. 37 // The language.
37 const char* language; 38 const char* language;
38 39
39 // The corresponding language and region, used by the dictionaries. 40 // The corresponding language and region, used by the dictionaries.
40 const char* language_region; 41 const char* language_region;
41 } g_supported_spellchecker_languages[] = { 42 } g_supported_spellchecker_languages[] = {
42 {"en-US", "en-US"}, 43 {"en-US", "en-US"},
43 {"en-GB", "en-GB"}, 44 {"en-GB", "en-GB"},
45 {"en-AU", "en-AU"},
44 {"fr", "fr-FR"}, 46 {"fr", "fr-FR"},
45 {"it", "it-IT"}, 47 {"it", "it-IT"},
46 {"de", "de-DE"}, 48 {"de", "de-DE"},
47 {"es", "es-ES"}, 49 {"es", "es-ES"},
48 {"nl", "nl-NL"}, 50 {"nl", "nl-NL"},
49 {"pt-BR", "pt-BR"}, 51 {"pt-BR", "pt-BR"},
50 {"ru", "ru-RU"}, 52 {"ru", "ru-RU"},
51 {"pl", "pl-PL"}, 53 {"pl", "pl-PL"},
52 // {"th", "th-TH"}, // Not to be included in Spellchecker as per B=1277824 54 // {"th", "th-TH"}, // Not to be included in Spellchecker as per B=1277824
53 {"sv", "sv-SE"}, 55 {"sv", "sv-SE"},
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 124
123 // Next, look for exact match in the language_region part of the list. 125 // Next, look for exact match in the language_region part of the list.
124 Language spellcheck_language_region( 126 Language spellcheck_language_region(
125 g_supported_spellchecker_languages[i].language_region); 127 g_supported_spellchecker_languages[i].language_region);
126 if (spellcheck_language_region == language) 128 if (spellcheck_language_region == language)
127 return g_supported_spellchecker_languages[i].language; 129 return g_supported_spellchecker_languages[i].language;
128 } 130 }
129 131
130 // Look for a match by comparing only language parts. All the 'en-RR' 132 // Look for a match by comparing only language parts. All the 'en-RR'
131 // except for 'en-GB' exactly matched in the above loop, will match 133 // except for 'en-GB' exactly matched in the above loop, will match
132 // 'en-US'. This is not ideal because 'en-AU', 'en-ZA', 'en-NZ' had 134 // 'en-US'. This is not ideal because 'en-ZA', 'en-NZ' had
133 // better be matched with 'en-GB'. This does not handle cases like 135 // better be matched with 'en-GB'. This does not handle cases like
134 // 'az-Latn-AZ' vs 'az-Arab-AZ', either, but we don't use 3-part 136 // 'az-Latn-AZ' vs 'az-Arab-AZ', either, but we don't use 3-part
135 // locale ids with a script code in the middle, yet. 137 // locale ids with a script code in the middle, yet.
136 // TODO(jungshik): Add a better fallback. 138 // TODO(jungshik): Add a better fallback.
137 Language language_part(language, 0, language.find('-')); 139 Language language_part(language, 0, language.find('-'));
138 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(g_supported_spellchecker_languages); 140 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(g_supported_spellchecker_languages);
139 ++i) { 141 ++i) {
140 Language spellcheck_language( 142 Language spellcheck_language(
141 g_supported_spellchecker_languages[i].language_region); 143 g_supported_spellchecker_languages[i].language_region);
142 if (spellcheck_language.substr(0, spellcheck_language.find('-')) == 144 if (spellcheck_language.substr(0, spellcheck_language.find('-')) ==
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // The following dictionaries have either not been augmented with additional 339 // The following dictionaries have either not been augmented with additional
338 // words (version 1-1) or have new words, as well as an upgraded dictionary 340 // words (version 1-1) or have new words, as well as an upgraded dictionary
339 // as of Feb 2009 (version 1-3). 341 // as of Feb 2009 (version 1-3).
340 static const struct { 342 static const struct {
341 // The language input. 343 // The language input.
342 const char* language; 344 const char* language;
343 345
344 // The corresponding version. 346 // The corresponding version.
345 const char* version; 347 const char* version;
346 } special_version_string[] = { 348 } special_version_string[] = {
349 {"en-AU", "-1-1"},
347 {"en-GB", "-1-1"}, 350 {"en-GB", "-1-1"},
348 {"es-ES", "-1-1"}, 351 {"es-ES", "-1-1"},
349 {"nl-NL", "-1-1"}, 352 {"nl-NL", "-1-1"},
350 {"ru-RU", "-1-1"}, 353 {"ru-RU", "-1-1"},
351 {"sv-SE", "-1-1"}, 354 {"sv-SE", "-1-1"},
352 {"he-IL", "-1-1"}, 355 {"he-IL", "-1-1"},
353 {"el-GR", "-1-1"}, 356 {"el-GR", "-1-1"},
354 {"hi-IN", "-1-1"}, 357 {"hi-IN", "-1-1"},
355 {"tr-TR", "-1-1"}, 358 {"tr-TR", "-1-1"},
356 {"et-EE", "-1-1"}, 359 {"et-EE", "-1-1"},
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 hunspell_->put_word(word_to_add.c_str()); 627 hunspell_->put_word(word_to_add.c_str());
625 628
626 // Now add the word to the custom dictionary file. 629 // Now add the word to the custom dictionary file.
627 Task* write_word_task = 630 Task* write_word_task =
628 new AddWordToCustomDictionaryTask(custom_dictionary_file_name_, word); 631 new AddWordToCustomDictionaryTask(custom_dictionary_file_name_, word);
629 if (file_loop_) 632 if (file_loop_)
630 file_loop_->PostTask(FROM_HERE, write_word_task); 633 file_loop_->PostTask(FROM_HERE, write_word_task);
631 else 634 else
632 write_word_task->Run(); 635 write_word_task->Run();
633 } 636 }
OLDNEW
« no previous file with comments | « no previous file | chrome/third_party/hunspell/dictionaries/README_en_AU.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698