diff options
-rw-r--r-- | include/linguistic/misc.hxx | 4 | ||||
-rw-r--r-- | lingucomponent/source/lingutil/lingutil.cxx | 6 | ||||
-rw-r--r-- | linguistic/source/misc.cxx | 13 |
3 files changed, 18 insertions, 5 deletions
diff --git a/include/linguistic/misc.hxx b/include/linguistic/misc.hxx index 3d6321ef1e74..da5c4dccec2e 100644 --- a/include/linguistic/misc.hxx +++ b/include/linguistic/misc.hxx @@ -111,6 +111,10 @@ LNG_DLLPUBLIC ::com::sun::star::lang::Locale LinguLanguageToLocale( LanguageType */ LNG_DLLPUBLIC bool LinguIsUnspecified( LanguageType nLanguage ); +/** The same as LinguIsUnspecified(LanguageType) but taking a BCP 47 language + tag string instead. */ +LNG_DLLPUBLIC bool LinguIsUnspecified( const OUString & rBcp47 ); + ::com::sun::star::uno::Sequence< sal_Int16 > LocaleSeqToLangSeq( ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > &rLocaleSeq ); diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx index 48fe7c582134..5543a66a9dc7 100644 --- a/lingucomponent/source/lingutil/lingutil.cxx +++ b/lingucomponent/source/lingutil/lingutil.cxx @@ -208,11 +208,7 @@ void MergeNewStyleDicsAndOldStyleDics( DBG_ASSERT( nOldStyleDics, "old style dictionary with more then one language found!"); if (nOldStyleDics > 0) { - /* TODO: this conversion exists only to check with - * LinguIsUnspecified(), add another check that takes the tag - * string instead. */ - LanguageType nLang = LanguageTag::convertToLanguageTypeWithFallback( aIt2->aLocaleNames[0] ); - if (nLang == LANGUAGE_DONTKNOW || linguistic::LinguIsUnspecified( nLang)) + if (linguistic::LinguIsUnspecified( aIt2->aLocaleNames[0])) { OSL_FAIL( "old style dictionary with invalid language found!" ); continue; diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index 867dccfc4c38..fe24438a0b6c 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -106,6 +106,19 @@ bool LinguIsUnspecified( LanguageType nLanguage ) return false; } +// When adding anything keep both LinguIsUnspecified() methods in sync! +// For mappings between language code string and LanguageType see +// i18nlangtag/source/isolang/isolang.cxx + +bool LinguIsUnspecified( const OUString & rBcp47 ) +{ + if (rBcp47.getLength() != 3) + return false; + if (rBcp47 == "zxx" || rBcp47 == "und" || rBcp47 == "mul") + return true; + return false; +} + static inline sal_Int32 Minimum( sal_Int32 n1, sal_Int32 n2, sal_Int32 n3 ) { sal_Int32 nMin = n1 < n2 ? n1 : n2; |