introduced libi18nlangtagicu
Change-Id: Ie80e989d55d465e127ccc20290d654acf222e5bb
This commit is contained in:
parent
6681432e39
commit
095f3dde42
@ -33,6 +33,7 @@ $(eval $(call gb_Library_use_libraries,merged,\
|
||||
cppu \
|
||||
cppuhelper \
|
||||
i18nlangtag \
|
||||
i18nlangtagicu \
|
||||
$(if $(filter TRUE,$(SOLAR_JAVA)), \
|
||||
jvmaccess \
|
||||
jvmfwk) \
|
||||
|
@ -469,6 +469,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,OOO, \
|
||||
deployment \
|
||||
fileacc \
|
||||
i18nlangtag \
|
||||
i18nlangtagicu \
|
||||
i18nutil \
|
||||
mcnttype \
|
||||
package2 \
|
||||
|
@ -80,6 +80,7 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\
|
||||
hwpfilter \
|
||||
$(call gb_Helper_optional,HYPHEN,hyphen) \
|
||||
i18nlangtag \
|
||||
i18nlangtagicu \
|
||||
i18npool \
|
||||
i18nutil \
|
||||
$(call gb_Helper_optional,ICU,icu) \
|
||||
|
32
i18nlangtag/Library_i18nlangtagicu.mk
Normal file
32
i18nlangtag/Library_i18nlangtagicu.mk
Normal file
@ -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:
|
@ -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,\
|
||||
|
36
i18nlangtag/source/languagetag/languagetagicu.cxx
Normal file
36
i18nlangtag/source/languagetag/languagetagicu.cxx
Normal file
@ -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: */
|
@ -393,6 +393,7 @@ private:
|
||||
OUString& rLanguage,
|
||||
OUString& rScript,
|
||||
OUString& rCountry );
|
||||
|
||||
};
|
||||
|
||||
#endif // INCLUDED_I18NLANGTAG_LANGUAGETAG_HXX
|
||||
|
44
include/i18nlangtag/languagetagicu.hxx
Normal file
44
include/i18nlangtag/languagetagicu.hxx
Normal file
@ -0,0 +1,44 @@
|
||||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
|
||||
#define INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
|
||||
|
||||
#include <sal/config.h>
|
||||
#include <i18nlangtag/i18nlangtagdllapi.h>
|
||||
#include <unicode/locid.h>
|
||||
|
||||
class LanguageTag;
|
||||
|
||||
|
||||
/** Interface LanguageTag to ICU's icu::Locale
|
||||
|
||||
Separated from LanguageTag into its own library to not pollute the entire
|
||||
code base with ICU header file inclusion and linkage, only the few code
|
||||
actually using this needs to link against ICU libraries, which it did
|
||||
anyway.
|
||||
*/
|
||||
class I18NLANGTAG_DLLPUBLIC LanguageTagIcu
|
||||
{
|
||||
public:
|
||||
|
||||
/** Obtain language tag as ICU icu::Locale.
|
||||
|
||||
If the language tag is a "pure" ISO locale (see
|
||||
LanguageTag::getLocale()) that is directly constructed, otherwise it is
|
||||
converted using the available ICU mechanisms.
|
||||
|
||||
Always resolves an empty tag to the system locale.
|
||||
*/
|
||||
static icu::Locale getIcuLocale( const LanguageTag & rLanguageTag );
|
||||
};
|
||||
|
||||
#endif // INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
Loading…
x
Reference in New Issue
Block a user