1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #ifndef INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
11 #define INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
13 #include <sal/config.h>
15 #include <string_view>
17 #include <i18nlangtag/i18nlangtagdllapi.h>
18 #include <rtl/ustring.hxx>
19 #include <unicode/locid.h>
24 /** Interface LanguageTag to ICU's icu::Locale
26 Separated from LanguageTag to not pollute the entire code base (and thus
27 makefiles) with ICU header file inclusion, only the few code actually using
28 this needs to know about ICU, which it did anyway.
30 class SAL_WARN_UNUSED I18NLANGTAG_DLLPUBLIC LanguageTagIcu
34 /** Obtain language tag as ICU icu::Locale.
36 If the language tag is a "pure" ISO locale (see
37 LanguageTag::getLocale()) that is directly constructed, otherwise it is
38 converted using the available ICU mechanisms.
40 Always resolves an empty tag to the system locale.
42 static icu::Locale
getIcuLocale( const LanguageTag
& rLanguageTag
);
44 /** Obtain language tag as ICU icu::Locale, adding variant data.
46 From the LanguageTag only language and country are used to construct
47 the icu:Locale, the variant field is copied from rVariant.
48 The 4th arg of icu::Locale "keywords" (eg: for collation)
50 Always resolves an empty tag to the system locale.
52 static icu::Locale
getIcuLocale( const LanguageTag
& rLanguageTag
, std::u16string_view rVariant
, std::u16string_view rKeywords
);
54 /** Obtain the display name for a language tag.
56 Gets a localized name from icu::Locale::getDisplayName(). Meant to be
57 used only with language tags that do not have a language list entry in
58 svtools/inc/langtab.hrc STR_ARR_SVT_LANGUAGE_TABLE, thus used by
59 SvtLanguageTable::GetLanguageString()
62 The language tag for which the name is to be displayed.
64 @param rDisplayLanguage
65 The language in which the name is to be displayed.
66 Usually Application::GetSettings().GetUILanguageTag().
68 static OUString
getDisplayName( const LanguageTag
& rLanguageTag
, const LanguageTag
& rDisplayLanguage
);
71 #endif // INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */