mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1097625 - Fallback to use LANG variable as dictionary doesn't work. r=ehsan
This commit is contained in:
parent
5f470bd4a1
commit
91d3fd2503
@ -857,22 +857,30 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
|
||||
// Strip trailing charset if there is any
|
||||
int32_t dot_pos = lang.FindChar('.');
|
||||
if (dot_pos != -1) {
|
||||
lang = Substring(lang, 0, dot_pos - 1);
|
||||
}
|
||||
// Replace '_' with '-'
|
||||
int32_t underScore = lang.FindChar('_');
|
||||
if (underScore != -1) {
|
||||
lang.Replace(underScore, 1, '-');
|
||||
lang = Substring(lang, 0, dot_pos);
|
||||
}
|
||||
// Some Linux distributions use '_' as lang/dialect separator.
|
||||
rv = SetCurrentDictionary(lang);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Replace '_' with '-' when dictionary with underscore not found.
|
||||
int32_t underScore = lang.FindChar('_');
|
||||
if (underScore != -1) {
|
||||
lang.Replace(underScore, 1, '-');
|
||||
rv = SetCurrentDictionary(lang);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = SetCurrentDictionary(NS_LITERAL_STRING("en-US"));
|
||||
if (NS_FAILED(rv)) {
|
||||
nsTArray<nsString> dictList;
|
||||
rv = mSpellChecker->GetDictionaryList(&dictList);
|
||||
if (NS_SUCCEEDED(rv) && dictList.Length() > 0) {
|
||||
SetCurrentDictionary(dictList[0]);
|
||||
// Some Linux distributions are using '_' as separator for dictionaries.
|
||||
rv = SetCurrentDictionary(NS_LITERAL_STRING("en_US"));
|
||||
if (NS_FAILED(rv)) {
|
||||
nsTArray<nsString> dictList;
|
||||
rv = mSpellChecker->GetDictionaryList(&dictList);
|
||||
if (NS_SUCCEEDED(rv) && dictList.Length() > 0) {
|
||||
SetCurrentDictionary(dictList[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user