LibreOffice Module i18nlangtag (master) 1
Static Public Member Functions | List of all members
LanguageTagIcu Class Reference

Interface LanguageTag to ICU's icu::Locale. More...

#include <languagetagicu.hxx>

Static Public Member Functions

static icu::Locale getIcuLocale (const LanguageTag &rLanguageTag)
 Obtain language tag as ICU icu::Locale. More...
 
static icu::Locale getIcuLocale (const LanguageTag &rLanguageTag, std::u16string_view rVariant, std::u16string_view rKeywords)
 Obtain language tag as ICU icu::Locale, adding variant data. More...
 
static OUString getDisplayName (const LanguageTag &rLanguageTag, const LanguageTag &rDisplayLanguage)
 Obtain the display name for a language tag. More...
 

Detailed Description

Interface LanguageTag to ICU's icu::Locale.

Separated from LanguageTag to not pollute the entire code base (and thus makefiles) with ICU header file inclusion, only the few code actually using this needs to know about ICU, which it did anyway.

Definition at line 30 of file languagetagicu.hxx.

Member Function Documentation

◆ getDisplayName()

OUString LanguageTagIcu::getDisplayName ( const LanguageTag rLanguageTag,
const LanguageTag rDisplayLanguage 
)
static

Obtain the display name for a language tag.

Gets a localized name from icu::Locale::getDisplayName(). Meant to be used only with language tags that do not have a language list entry in svtools/inc/langtab.hrc STR_ARR_SVT_LANGUAGE_TABLE, thus used by SvtLanguageTable::GetLanguageString()

Parameters
rLanguageTagThe language tag for which the name is to be displayed.
rDisplayLanguageThe language in which the name is to be displayed. Usually Application::GetSettings().GetUILanguageTag().

Definition at line 50 of file languagetagicu.cxx.

References getIcuLocale(), and LANGUAGE_SYSTEM.

◆ getIcuLocale() [1/2]

icu::Locale LanguageTagIcu::getIcuLocale ( const LanguageTag rLanguageTag)
static

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.

Definition at line 15 of file languagetagicu.cxx.

References LanguageTag::getBcp47(), LanguageTag::getLocale(), LanguageTag::isIsoLocale(), and OUStringToOString().

Referenced by getDisplayName().

◆ getIcuLocale() [2/2]

icu::Locale LanguageTagIcu::getIcuLocale ( const LanguageTag rLanguageTag,
std::u16string_view  rVariant,
std::u16string_view  rKeywords 
)
static

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. The 4th arg of icu::Locale "keywords" (eg: for collation)

Always resolves an empty tag to the system locale.

Definition at line 38 of file languagetagicu.cxx.

References LanguageTag::getCountry(), LanguageTag::getLanguage(), and OUStringToOString().


The documentation for this class was generated from the following files: