[PATCH] added LanguageTagIcu::getIcuLocale() with additional variant
Eike Rathke (via Code Review)
gerrit at gerrit.libreoffice.org
Mon Apr 29 06:16:58 PDT 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/3668
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/68/3668/1
added LanguageTagIcu::getIcuLocale() with additional variant
Change-Id: I5a5689f449ac7653bb716f2ce67ea1039fe2559c
---
M i18nlangtag/source/languagetag/languagetagicu.cxx
M include/i18nlangtag/languagetagicu.hxx
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/i18nlangtag/source/languagetag/languagetagicu.cxx b/i18nlangtag/source/languagetag/languagetagicu.cxx
index 6f426d6..e088b3c 100644
--- a/i18nlangtag/source/languagetag/languagetagicu.cxx
+++ b/i18nlangtag/source/languagetag/languagetagicu.cxx
@@ -33,4 +33,15 @@
OUStringToOString( rLanguageTag.getBcp47(), RTL_TEXTENCODING_ASCII_US).getStr());
}
+
+// static
+icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant )
+{
+ /* FIXME: how should this work with any BCP47? */
+ return icu::Locale(
+ OUStringToOString( rLanguageTag.getLanguage(), RTL_TEXTENCODING_ASCII_US).getStr(),
+ OUStringToOString( rLanguageTag.getCountry(), RTL_TEXTENCODING_ASCII_US).getStr(),
+ OUStringToOString( rVariant, RTL_TEXTENCODING_ASCII_US).getStr());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/i18nlangtag/languagetagicu.hxx b/include/i18nlangtag/languagetagicu.hxx
index 20e5349..2fc9db3 100644
--- a/include/i18nlangtag/languagetagicu.hxx
+++ b/include/i18nlangtag/languagetagicu.hxx
@@ -12,6 +12,7 @@
#include <sal/config.h>
#include <i18nlangtag/i18nlangtagdllapi.h>
+#include <rtl/ustring.hxx>
#include <unicode/locid.h>
class LanguageTag;
@@ -37,6 +38,17 @@
Always resolves an empty tag to the system locale.
*/
static icu::Locale getIcuLocale( const LanguageTag & rLanguageTag );
+
+ /** Obtain language tag as ICU icu::Locale, adding variant data.
+
+ From the LanguageTag only language and country are used to construct
+ the icu:Locale, the variant field is copied from rVariant. For example
+ needed to create an icu::Collator instance where the variant field
+ denotes the algorithm to be used.
+
+ Always resolves an empty tag to the system locale.
+ */
+ static icu::Locale getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant );
};
#endif // INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
--
To view, visit https://gerrit.libreoffice.org/3668
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a5689f449ac7653bb716f2ce67ea1039fe2559c
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Eike Rathke <erack at redhat.com>
More information about the LibreOffice
mailing list