[Libreoffice-commits] core.git: lingucomponent/source

Tor Lillqvist tml at collabora.com
Fri May 18 07:17:30 UTC 2018


 lingucomponent/source/spellcheck/macosxspell/macspellimp.mm |   22 +++++++-----
 1 file changed, 14 insertions(+), 8 deletions(-)

New commits:
commit 69c8e9a0607e9a197dfff8139f2ca14c2538da8a
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu May 17 12:35:34 2018 +0300

    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 at libreoffice.org>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

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?)


More information about the Libreoffice-commits mailing list