summaryrefslogtreecommitdiff
path: root/include/i18nlangtag/languagetag.hxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-07-13 00:54:24 +0200
committerEike Rathke <erack@redhat.com>2013-07-13 11:54:37 +0200
commit5d1a8e0d47b6d6e9e3e5735d0ee52fa0b4782202 (patch)
tree4d01c413a5ffeaa7871ac45c8d4985a31a1f07f7 /include/i18nlangtag/languagetag.hxx
parentec07170735331cb64f2e967682ad74def733a931 (diff)
added static convertTo...() methods
Standalone conversions from Locale and LangID do not need a LanguageTag instance. Provide simple static methods. For consistency also static methods to convert from BCP47, but using a temporary instance. Change-Id: I5edd27e917ef9e92e8ec457e715b7558d7e4660f
Diffstat (limited to 'include/i18nlangtag/languagetag.hxx')
-rw-r--r--include/i18nlangtag/languagetag.hxx68
1 files changed, 68 insertions, 0 deletions
diff --git a/include/i18nlangtag/languagetag.hxx b/include/i18nlangtag/languagetag.hxx
index bbda176a8f20..1a1d69deaae6 100644
--- a/include/i18nlangtag/languagetag.hxx
+++ b/include/i18nlangtag/languagetag.hxx
@@ -41,6 +41,9 @@ typedef struct _rtl_Locale rtl_Locale; // as in rtl/locale.h
Note that member variables are mutable and may change their values even in
const methods. Getter methods return either the original value or matching
converted values.
+
+ For standalone conversions if no LanguageTag instance is at hand, static
+ convertTo...() methods exist.
*/
class I18NLANGTAG_DLLPUBLIC LanguageTag
{
@@ -365,6 +368,71 @@ public:
*/
bool operator!=( const LanguageTag & rLanguageTag ) const;
+
+ /** Convert MS-LangID to Locale.
+
+ @param bResolveSystem
+ If TRUE, resolve an empty language tag denoting the system
+ locale to the real locale used.
+ If FALSE, return an empty Locale for such a tag.
+ */
+ static com::sun::star::lang::Locale convertToLocale( LanguageType nLangID, bool bResolveSystem = true );
+
+ /** Convert Locale to MS-LangID.
+
+ @param bResolveSystem
+ If TRUE, resolve an empty language tag denoting the system
+ locale to the real locale used.
+ If FALSE, return LANGUAGE_SYSTEM for such a tag.
+ */
+ static LanguageType convertToLanguageType( const com::sun::star::lang::Locale& rLocale, bool bResolveSystem = true );
+
+ /** Convert MS-LangID to BCP 47 string.
+
+ @param bResolveSystem
+ If TRUE, resolve an empty language tag denoting the system
+ locale to the real locale used.
+ If FALSE, return an empty OUString for such a tag.
+ */
+ static OUString convertToBcp47( LanguageType nLangID, bool bResolveSystem = true );
+
+ /** Convert Locale to BCP 47 string.
+
+ @param bResolveSystem
+ If TRUE, resolve an empty language tag denoting the system
+ locale to the real locale used.
+ If FALSE, return an empty OUString for such a tag.
+ */
+ static OUString convertToBcp47( const com::sun::star::lang::Locale& rLocale, bool bResolveSystem = true );
+
+ /** Convert BCP 47 string to Locale, convenience method.
+
+ NOTE: exists only for consistency with the other convertTo...()
+ methods, internally uses a temporary LanguageTag instance for
+ conversion so does not save anything compared to
+ LanguageTag(rBcp47).getLocale(bResolveSystem).
+
+ @param bResolveSystem
+ If TRUE, resolve an empty language tag denoting the system
+ locale to the real locale used.
+ If FALSE, return an empty Locale for such a tag.
+ */
+ static com::sun::star::lang::Locale convertToLocale( const OUString& rBcp47, bool bResolveSystem = true );
+
+ /** Convert BCP 47 string to MS-LangID, convenience method.
+
+ NOTE: exists only for consistency with the other convertTo...()
+ methods, internally uses a temporary LanguageTag instance for
+ conversion so does not save anything compared to
+ LanguageTag(rBcp47).getLanguageType(bResolveSystem).
+
+ @param bResolveSystem
+ If TRUE, resolve an empty language tag denoting the system
+ locale to the real locale used.
+ If FALSE, return LANGUAGE_SYSTEM for such a tag.
+ */
+ static LanguageType convertToLanguageType( const OUString& rBcp47, bool bResolveSystem = true );
+
private:
enum Decision