i18nlangtag/source/languagetag/languagetag.cxx |   10 ++++++++++
 include/i18nlangtag/languagetag.hxx            |   10 ++++++++++
 2 files changed, 20 insertions(+)

New commits:
commit a6baab25b53d0a87686a5fcdabf86747e9678021
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Mon Oct 25 11:41:09 2021 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Mon Oct 25 13:07:50 2021 +0200

    Introduce LanguageTag::convertToLanguageTypeWithFallback(Locale)
    
    ... with keeping LANGUAGE_SYSTEM not resolved or falling back.
    
    Change-Id: I10211c2b2140a9822f1403dc00af3ee9ded08f69
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124140
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/i18nlangtag/source/languagetag/languagetag.cxx 
b/i18nlangtag/source/languagetag/languagetag.cxx
index ebad94022615..6f6a766e861f 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -2812,6 +2812,16 @@ css::lang::Locale 
LanguageTag::convertToLocaleWithFallback( const OUString& rBcp
 }
 
 
+// static
+LanguageType LanguageTag::convertToLanguageTypeWithFallback( const 
css::lang::Locale& rLocale, bool bResolveSystem )
+{
+    if (rLocale.Language.isEmpty() && !bResolveSystem)
+        return LANGUAGE_SYSTEM;
+
+    return LanguageTag( rLocale).makeFallback().getLanguageType();
+}
+
+
 // static
 bool LanguageTag::isValidBcp47( const OUString& rString, OUString* 
o_pCanonicalized, bool bDisallowPrivate )
 {
diff --git a/include/i18nlangtag/languagetag.hxx 
b/include/i18nlangtag/languagetag.hxx
index 62957f1f7f70..4fbb6d0c2e11 100644
--- a/include/i18nlangtag/languagetag.hxx
+++ b/include/i18nlangtag/languagetag.hxx
@@ -507,6 +507,16 @@ public:
      */
     static css::lang::Locale convertToLocaleWithFallback( const OUString& 
rBcp47 );
 
+    /** Convert Locale to MS-LangID with fallback.
+
+        @param bResolveSystem
+               If TRUE, resolve an empty language tag denoting the system
+               locale to the real locale used and fallback.
+               If FALSE, return LANGUAGE_SYSTEM for such a tag and do not 
fallback.
+     */
+    static LanguageType convertToLanguageTypeWithFallback( const 
css::lang::Locale& rLocale,
+                                                           bool bResolveSystem 
= true );
+
     /** If rString represents a valid BCP 47 language tag.
 
         Never resolves an empty tag to the system locale, in fact an empty

Reply via email to