[Libreoffice-commits] .: i18npool/inc i18npool/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Nov 16 09:45:25 PST 2012
i18npool/inc/i18npool/languagetag.hxx | 15 +++++++++++++++
i18npool/source/languagetag/languagetag.cxx | 14 ++++++++++++++
2 files changed, 29 insertions(+)
New commits:
commit 3eb4304af99265c898835cd307ba7d689038996b
Author: Eike Rathke <erack at redhat.com>
Date: Fri Nov 16 18:44:19 2012 +0100
added LanguageTag::getIsoLanguageCountry() method
Change-Id: I8917c2958f021f11933d9da7fec8ef01609387c8
diff --git a/i18npool/inc/i18npool/languagetag.hxx b/i18npool/inc/i18npool/languagetag.hxx
index 5666fd1..552110d 100644
--- a/i18npool/inc/i18npool/languagetag.hxx
+++ b/i18npool/inc/i18npool/languagetag.hxx
@@ -95,6 +95,21 @@ public:
*/
LanguageType getLanguageType( bool bResolveSystem = true ) const;
+ /** Obtain ISO strings for language and country.
+
+ This is a convenience method for places that so far use only language and
+ country to replace the MsLangId::convert...IsoNames...() calls. Avoid
+ use in new code.
+
+ ATTENTION! May return empty strings if the language tag is not
+ expressable in valid ISO codes!
+
+ @see isIsoLocale()
+
+ Always resolves an empty tag to the system locale.
+ */
+ void getIsoLanguageCountry( rtl::OUString& rLanguage, rtl::OUString& rCountry ) const;
+
/** Get ISO 639 language code, or BCP 47 language.
Always resolves an empty tag to the system locale.
diff --git a/i18npool/source/languagetag/languagetag.cxx b/i18npool/source/languagetag/languagetag.cxx
index 3e655ee..f863ae2 100644
--- a/i18npool/source/languagetag/languagetag.cxx
+++ b/i18npool/source/languagetag/languagetag.cxx
@@ -618,6 +618,20 @@ LanguageType LanguageTag::getLanguageType( bool bResolveSystem ) const
}
+void LanguageTag::getIsoLanguageCountry( rtl::OUString& rLanguage, rtl::OUString& rCountry ) const
+{
+ if (!isIsoLocale())
+ {
+ rLanguage = OUString();
+ rCountry = OUString();
+ return;
+ }
+ // After isIsoLocale() it's safe to call getLanguage() for ISO code.
+ rLanguage = getLanguage();
+ rCountry = getCountry();
+}
+
+
namespace
{
More information about the Libreoffice-commits
mailing list