[Libreoffice-commits] core.git: 5 commits - i18nlangtag/source include/i18nlangtag
Eike Rathke
erack at redhat.com
Tue Aug 27 09:09:35 PDT 2013
i18nlangtag/source/isolang/isolang.cxx | 54 ++++++++++++++++++++++++++++----
i18nlangtag/source/isolang/mslangid.cxx | 7 ----
include/i18nlangtag/mslangid.hxx | 6 ++-
3 files changed, 54 insertions(+), 13 deletions(-)
New commits:
commit 434f3c8e7fac0644cfe1d7a15f97f0c267bac048
Author: Eike Rathke <erack at redhat.com>
Date: Tue Aug 27 18:08:08 2013 +0200
use ...IgnoreAsciiCase()
Change-Id: I4de5201d6352ef1b7fc0dafcac9f8439dd943b60
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 58ef58e..41d8411 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -773,9 +773,9 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
for (const IsoLanguageScriptCountryEntry* pScriptEntry = aImplIsoLangScriptEntries;
pScriptEntry->mnLang != LANGUAGE_DONTKNOW; ++pScriptEntry)
{
- if (rLocale.Variant.startsWith( pScriptEntry->maLanguageScript))
+ if (rLocale.Variant.startsWithIgnoreAsciiCase( pScriptEntry->maLanguageScript))
{
- if (pScriptEntry->getTagString() == rLocale.Variant)
+ if (rLocale.Variant.equalsIgnoreAsciiCase( pScriptEntry->getTagString()))
return pScriptEntry->getLocale();
if (!pFirstScript)
pFirstScript = pScriptEntry;
@@ -792,8 +792,8 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
for (const IsoLanguageScriptCountryEntry* pScriptEntry = pFirstScript;
pScriptEntry->mnLang != LANGUAGE_DONTKNOW; ++pScriptEntry)
{
- if (rLocale.Variant.startsWith( pScriptEntry->maLanguageScript) &&
- pScriptEntry->maCountry == rLocale.Country)
+ if (rLocale.Variant.startsWithIgnoreAsciiCase( pScriptEntry->maLanguageScript) &&
+ rLocale.Country.equalsIgnoreAsciiCaseAscii( pScriptEntry->maCountry))
return pScriptEntry->getLocale();
}
}
@@ -888,9 +888,9 @@ LanguageType MsLangId::Conversion::convertLocaleToLanguageImpl(
for (const IsoLanguageScriptCountryEntry* pScriptEntry = aImplIsoLangScriptEntries;
pScriptEntry->mnLang != LANGUAGE_DONTKNOW; ++pScriptEntry)
{
- if (rLocale.Variant.startsWith( pScriptEntry->maLanguageScript))
+ if (rLocale.Variant.startsWithIgnoreAsciiCase( pScriptEntry->maLanguageScript))
{
- if (pScriptEntry->getTagString() == rLocale.Variant)
+ if (rLocale.Variant.equalsIgnoreAsciiCase( pScriptEntry->getTagString()))
return pScriptEntry->mnLang;
}
}
commit fbf0a3ee5fec87bff4fd5c373509b287d88a0a31
Author: Eike Rathke <erack at redhat.com>
Date: Tue Aug 27 17:54:28 2013 +0200
in convertLocaleToLanguageImpl() don't use the implied fall back
... and through of dreaded convertIsoNamesToLanguage()
Change-Id: Ifb86974f9398094ed1a513a060ff61d63f798ea3
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 9722700..58ef58e 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -878,13 +878,39 @@ LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( const OUString&
LanguageType MsLangId::Conversion::convertLocaleToLanguageImpl(
const ::com::sun::star::lang::Locale& rLocale )
{
- /* FIXME: this x-... is temporary until conversion will be moved up to
- * LanguageTag. Also handle the nasty "*" joker as privateuse. */
- LanguageType nRet = ((!rLocale.Variant.isEmpty() &&
- (rLocale.Variant.startsWithIgnoreAsciiCase( "x-") || (rLocale.Variant == "*"))) ?
- convertPrivateUseToLanguage( rLocale.Variant) :
- convertIsoNamesToLanguage( rLocale.Language, rLocale.Country));
- return nRet;
+ if (rLocale.Language == I18NLANGTAG_QLT)
+ {
+ // "x-..." private use and the nasty "*" joker
+ if (rLocale.Variant.startsWithIgnoreAsciiCase( "x-") || (rLocale.Variant == "*"))
+ return convertPrivateUseToLanguage( rLocale.Variant);
+
+ // Search in ISO lll-Ssss-CC
+ for (const IsoLanguageScriptCountryEntry* pScriptEntry = aImplIsoLangScriptEntries;
+ pScriptEntry->mnLang != LANGUAGE_DONTKNOW; ++pScriptEntry)
+ {
+ if (rLocale.Variant.startsWith( pScriptEntry->maLanguageScript))
+ {
+ if (pScriptEntry->getTagString() == rLocale.Variant)
+ return pScriptEntry->mnLang;
+ }
+ }
+ }
+ else
+ {
+ // language is lower case in table
+ OUString aLowerLang = rLocale.Language.toAsciiLowerCase();
+ // country is upper case in table
+ OUString aUpperCountry = rLocale.Country.toAsciiUpperCase();
+
+ // Search in ISO lll-CC
+ for (const IsoLanguageCountryEntry* pEntry = aImplIsoLangEntries;
+ pEntry->mnLang != LANGUAGE_DONTKNOW; ++pEntry)
+ {
+ if (aLowerLang.equalsAscii( pEntry->maLanguage) && aUpperCountry.equalsAscii( pEntry->maCountry))
+ return pEntry->mnLang;
+ }
+ }
+ return LANGUAGE_DONTKNOW;
}
commit a18c90dfe5f07227dea5c8e7cc21167ee90e446a
Author: Eike Rathke <erack at redhat.com>
Date: Tue Aug 27 17:29:58 2013 +0200
split off convertLocaleToLanguageImpl()
Change-Id: Ief7402a1067598fe9635ac23dedcaf8faf8de2be
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 3eb2d25..9722700 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -875,6 +875,20 @@ LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( const OUString&
// static
+LanguageType MsLangId::Conversion::convertLocaleToLanguageImpl(
+ const ::com::sun::star::lang::Locale& rLocale )
+{
+ /* FIXME: this x-... is temporary until conversion will be moved up to
+ * LanguageTag. Also handle the nasty "*" joker as privateuse. */
+ LanguageType nRet = ((!rLocale.Variant.isEmpty() &&
+ (rLocale.Variant.startsWithIgnoreAsciiCase( "x-") || (rLocale.Variant == "*"))) ?
+ convertPrivateUseToLanguage( rLocale.Variant) :
+ convertIsoNamesToLanguage( rLocale.Language, rLocale.Country));
+ return nRet;
+}
+
+
+// static
LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const OUString& rLang,
const OUString& rCountry )
{
diff --git a/i18nlangtag/source/isolang/mslangid.cxx b/i18nlangtag/source/isolang/mslangid.cxx
index a4daef86..6e816ee 100644
--- a/i18nlangtag/source/isolang/mslangid.cxx
+++ b/i18nlangtag/source/isolang/mslangid.cxx
@@ -169,12 +169,7 @@ LanguageType MsLangId::Conversion::convertLocaleToLanguage(
if (rLocale.Language.isEmpty())
return LANGUAGE_SYSTEM;
- /* FIXME: this x-... is temporary until conversion will be moved up to
- * LanguageTag. Also handle the nasty "*" joker as privateuse. */
- LanguageType nRet = ((!rLocale.Variant.isEmpty() &&
- (rLocale.Variant.startsWithIgnoreAsciiCase( "x-") || (rLocale.Variant == "*"))) ?
- convertPrivateUseToLanguage( rLocale.Variant) :
- convertIsoNamesToLanguage( rLocale.Language, rLocale.Country));
+ LanguageType nRet = convertLocaleToLanguageImpl( rLocale);
if (nRet == LANGUAGE_DONTKNOW)
nRet = LANGUAGE_SYSTEM;
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index 14386ec..6be7e66 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -212,7 +212,11 @@ public:
I18NLANGTAG_DLLPRIVATE static LanguageType convertLocaleToLanguage(
const ::com::sun::star::lang::Locale & rLocale );
- /** Convert x-... privateuse, used by convertLocaleToLanguage(Locale) */
+ /** Used by convertLocaleToLanguage(Locale) */
+ I18NLANGTAG_DLLPRIVATE static LanguageType convertLocaleToLanguageImpl(
+ const ::com::sun::star::lang::Locale & rLocale );
+
+ /** Convert x-... privateuse, used by convertLocaleToLanguageImpl(Locale) */
I18NLANGTAG_DLLPRIVATE static LanguageType convertPrivateUseToLanguage(
const OUString& rPriv );
commit d9eaef1fafe5fa3037d02962bfe334f50132803e
Author: Eike Rathke <erack at redhat.com>
Date: Tue Aug 27 17:08:38 2013 +0200
better check for 'qlt' instead of assuming Variant follows convention
Change-Id: I0915e5cd657633533a7374d533ec12c2bdaa3b8b
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 9c2ae71..3eb2d25 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -766,7 +766,7 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
OUString aUpperCountry = rLocale.Country.toAsciiUpperCase();
sal_Int32 nCountryLen = aUpperCountry.getLength();
- if (!rLocale.Variant.isEmpty())
+ if (rLocale.Language == I18NLANGTAG_QLT)
{
// Search in ISO lll-Ssss-CC
const IsoLanguageScriptCountryEntry* pFirstScript = NULL;
commit 29c61173d66864dde5ca18d6c21dca22ab4e018c
Author: Eike Rathke <erack at redhat.com>
Date: Tue Aug 27 16:53:58 2013 +0200
avoid creation of a temporary Locale instance
Change-Id: I973c196d7f19725ccbbd6d24707fc30e5fe78eef
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index db13298..9c2ae71 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -718,7 +718,9 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
{
if ( pScriptEntry->mnLang == nLang )
{
- rLocale = pScriptEntry->getLocale();
+ rLocale.Language = I18NLANGTAG_QLT;
+ rLocale.Country = OUString::createFromAscii( pScriptEntry->maCountry);
+ rLocale.Variant = pScriptEntry->getTagString();
return;
}
}
More information about the Libreoffice-commits
mailing list