bump product version to 6.4.0.3
[LibreOffice.git] / i18nlangtag / source / languagetag / languagetagicu.cxx
blob18d37f704773d1fe5932391811d967a3a6bb462e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <i18nlangtag/languagetagicu.hxx>
11 #include <i18nlangtag/languagetag.hxx>
14 // static
15 icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag )
17 if (rLanguageTag.isIsoLocale())
19 // The simple case.
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());
23 return icu::Locale(
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
29 * is added? */
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());
37 // static
38 icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant, const OUString & rKeywords )
40 /* FIXME: how should this work with any BCP47? */
41 return icu::Locale(
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: */