diff options
author | Eike Rathke <erack@redhat.com> | 2013-04-24 22:55:43 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-04-24 23:10:31 +0200 |
commit | 095f3dde425eb79da0e7fbfe40e18de1ac4f368b (patch) | |
tree | fc22271125013d978fe77effe3c790fcdf51cb6c /i18nlangtag | |
parent | 6681432e39228deb982105caa8de2319c2084a08 (diff) |
introduced libi18nlangtagicu
Change-Id: Ie80e989d55d465e127ccc20290d654acf222e5bb
Diffstat (limited to 'i18nlangtag')
-rw-r--r-- | i18nlangtag/Library_i18nlangtagicu.mk | 32 | ||||
-rw-r--r-- | i18nlangtag/Module_i18nlangtag.mk | 1 | ||||
-rw-r--r-- | i18nlangtag/source/languagetag/languagetagicu.cxx | 36 |
3 files changed, 69 insertions, 0 deletions
diff --git a/i18nlangtag/Library_i18nlangtagicu.mk b/i18nlangtag/Library_i18nlangtagicu.mk new file mode 100644 index 000000000000..d1def1b37339 --- /dev/null +++ b/i18nlangtag/Library_i18nlangtagicu.mk @@ -0,0 +1,32 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +$(eval $(call gb_Library_Library,i18nlangtagicu)) + +$(eval $(call gb_Library_use_sdk_api,i18nlangtagicu)) + +$(eval $(call gb_Library_add_defs,i18nlangtagicu,\ + -DI18NLANGTAG_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Library_use_libraries,i18nlangtagicu,\ + sal \ + i18nlangtag \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_Library_use_externals,i18nlangtagicu,\ + icu_headers \ + icuuc \ +)) + +$(eval $(call gb_Library_add_exception_objects,i18nlangtagicu,\ + i18nlangtag/source/languagetag/languagetagicu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/i18nlangtag/Module_i18nlangtag.mk b/i18nlangtag/Module_i18nlangtag.mk index edd2e1d2e2a9..22b8a7f42de9 100644 --- a/i18nlangtag/Module_i18nlangtag.mk +++ b/i18nlangtag/Module_i18nlangtag.mk @@ -10,6 +10,7 @@ $(eval $(call gb_Module_Module,i18nlangtag)) $(eval $(call gb_Module_add_targets,i18nlangtag,\ Library_i18nlangtag \ + Library_i18nlangtagicu \ )) $(eval $(call gb_Module_add_check_targets,i18nlangtag,\ diff --git a/i18nlangtag/source/languagetag/languagetagicu.cxx b/i18nlangtag/source/languagetag/languagetagicu.cxx new file mode 100644 index 000000000000..6f426d6a67c8 --- /dev/null +++ b/i18nlangtag/source/languagetag/languagetagicu.cxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "i18nlangtag/languagetagicu.hxx" +#include "i18nlangtag/languagetag.hxx" + + +// static +icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag ) +{ + if (rLanguageTag.isIsoLocale()) + { + // The simple case. + const com::sun::star::lang::Locale& rLocale = rLanguageTag.getLocale(); + if (rLocale.Country.isEmpty()) + return icu::Locale( OUStringToOString( rLocale.Language, RTL_TEXTENCODING_ASCII_US).getStr()); + return icu::Locale( + OUStringToOString( rLocale.Language, RTL_TEXTENCODING_ASCII_US).getStr(), + OUStringToOString( rLocale.Country, RTL_TEXTENCODING_ASCII_US).getStr()); + } + + /* TODO: could we optimize this for the isIsoODF() case where only a script + * is added? */ + + // Let ICU decide how it wants a BCP47 string stuffed into its Locale. + return icu::Locale::createFromName( + OUStringToOString( rLanguageTag.getBcp47(), RTL_TEXTENCODING_ASCII_US).getStr()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |