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 #include <i18nlangtag/languagetagicu.hxx>
11 #include <i18nlangtag/languagetag.hxx>
15 icu::Locale
LanguageTagIcu::getIcuLocale( const LanguageTag
& rLanguageTag
)
17 if (rLanguageTag
.isIsoLocale())
20 const css::lang::Locale
& rLocale
= rLanguageTag
.getLocale();
21 if (rLocale
.Country
.isEmpty())
22 return icu::Locale( OUStringToOString( rLocale
.Language
, RTL_TEXTENCODING_ASCII_US
).getStr());
24 OUStringToOString( rLocale
.Language
, RTL_TEXTENCODING_ASCII_US
).getStr(),
25 OUStringToOString( rLocale
.Country
, RTL_TEXTENCODING_ASCII_US
).getStr());
28 /* TODO: could we optimize this for the isIsoODF() case where only a script
31 // Let ICU decide how it wants a BCP47 string stuffed into its Locale.
32 return icu::Locale::createFromName(
33 OUStringToOString( rLanguageTag
.getBcp47(), RTL_TEXTENCODING_ASCII_US
).getStr());
38 icu::Locale
LanguageTagIcu::getIcuLocale( const LanguageTag
& rLanguageTag
, const OUString
& rVariant
, const OUString
& rKeywords
)
40 /* FIXME: how should this work with any BCP47? */
42 OUStringToOString( rLanguageTag
.getLanguage(), RTL_TEXTENCODING_ASCII_US
).getStr(),
43 OUStringToOString( rLanguageTag
.getCountry(), RTL_TEXTENCODING_ASCII_US
).getStr(),
44 OUStringToOString( rVariant
, RTL_TEXTENCODING_ASCII_US
).getStr(),
45 OUStringToOString( rKeywords
, RTL_TEXTENCODING_ASCII_US
).getStr()
49 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */