diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-05-17 12:35:34 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2018-05-18 09:17:04 +0200 |
commit | 69c8e9a0607e9a197dfff8139f2ca14c2538da8a (patch) | |
tree | 8d8d33ef0a62e12ce57618206b3552ffd03f8efb /lingucomponent | |
parent | fe61d9771fdf00a448f0df4fb7b69a43751e1af8 (diff) |
tdf#112442: Use list of available dictionaries, not available locales
Also, turn some specific overly generic languages that LO doesn't
recognize in this context into the country-specific ones that the
dictionary (probably) is for. Skip some odd locales LO doesn't know in
this context. In particular, what the system calls the "en" dictionary
is for "en_US", and "nb" is for "nb_NO". The "es" one probably is for
"es_ES".
Also, skip some language-country combinations that LO doesn't
recognize in this context. In partiular, "en_JP" and "en_SG".
Change-Id: I29450775a263bdc03fd43849380f66e6ffffd09b
Reviewed-on: https://gerrit.libreoffice.org/54476
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'lingucomponent')
-rw-r--r-- | lingucomponent/source/spellcheck/macosxspell/macspellimp.mm | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm index 15a195c52a02..a863cd2d87b9 100644 --- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm +++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm @@ -110,16 +110,12 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales() // TODO How on Mac OS X? // invoke a second dictionary manager to get the shared dictionary list - NSArray *aLocales = [NSLocale availableLocaleIdentifiers]; + NSArray *aSpellCheckLanguages = [[NSSpellChecker sharedSpellChecker] availableLanguages]; - //Test for existence of the dictionaries - for (NSUInteger i = 0; i < [aLocales count]; i++) + for (NSUInteger i = 0; i < [aSpellCheckLanguages count]; i++) { - NSString* pLangStr = static_cast<NSString*>([aLocales objectAtIndex:i]); - if( [[NSSpellChecker sharedSpellChecker] setLanguage:pLangStr ] ) - { - postspdict.push_back( pLangStr ); - } + NSString* pLangStr = static_cast<NSString*>([aSpellCheckLanguages objectAtIndex:i]); + postspdict.push_back( pLangStr ); } numshr = postspdict.size(); @@ -151,6 +147,16 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales() NSString* aCountry = [ aLocDict objectForKey:NSLocaleCountryCode ]; OUString lang([aLang cStringUsingEncoding: NSUTF8StringEncoding], [aLang length], aEnc); OUString country([ aCountry cStringUsingEncoding: NSUTF8StringEncoding], [aCountry length], aEnc); + // Fix some overly generic or odd locales LO doesn't know + if (lang == "en" && country.isEmpty()) + country = "US"; // I guess that is what it means + else if (lang == "nb" && country.isEmpty()) + country = "NO"; + else if (lang == "es" && country.isEmpty()) + country = "ES"; // Probably better than claiming it to be for all es-* ? + else if ((lang == "en" && country == "JP") + || (lang == "en" && country == "SG")) + continue; // Just skip, LO doesn't have those yet in this context Locale nLoc( lang, country, OUString() ); newloc = 1; //eliminate duplicates (is this needed for MacOS?) |