Kaydet (Commit) 8ef9e38a authored tarafından Eike Rathke's avatar Eike Rathke

use LanguageTag

This creates a circular dependency between modules i18npool and
comphelper, but not between libraries. To be resolved by moving
languagetag, isolang and mslangid stuff to a separate module.

Change-Id: I669aa66010800632c5637b42c6136a7ca14e7e68
üst ce1cbedd
......@@ -48,6 +48,7 @@ $(eval $(call gb_Library_use_libraries,comphelper,\
sal \
salhelper \
ucbhelper \
i18nisolang1 \
$(gb_UWINAPI) \
))
......
......@@ -49,6 +49,7 @@
#include "rtl/instance.hxx"
#include "rtl/ustrbuf.hxx"
#include "rtl/ustring.hxx"
#include "i18npool/languagetag.hxx"
namespace {
......@@ -62,32 +63,11 @@ struct TheConfigurationWrapper:
OUString getDefaultLocale(
css::uno::Reference< css::uno::XComponentContext > const & context)
{
css::lang::Locale locale(
return LanguageTag(
css::uno::Reference< css::lang::XLocalizable >(
css::configuration::theDefaultProvider::get(context),
css::uno::UNO_QUERY_THROW)->
getLocale());
OUStringBuffer buf;
SAL_WARN_IF(
locale.Language.indexOf('-') != -1, "comphelper",
"Locale language \"" << locale.Language << "\" contains \"-\"");
buf.append(locale.Language);
SAL_WARN_IF(
locale.Country.isEmpty() && !locale.Variant.isEmpty(), "comphelper",
"Locale has empty country but non-empty variant \"" << locale.Variant
<< '"');
if (!locale.Country.isEmpty()) {
buf.append('-');
SAL_WARN_IF(
locale.Country.indexOf('-') != -1, "comphelper",
"Locale language \"" << locale.Country << "\" contains \"-\"");
buf.append(locale.Country);
if (!locale.Variant.isEmpty()) {
buf.append('-');
buf.append(locale.Variant);
}
}
return buf.makeStringAndClear();
getLocale()).getBcp47();
}
OUString extendLocalizedPath(OUString const & path, OUString const & locale) {
......@@ -95,7 +75,7 @@ OUString extendLocalizedPath(OUString const & path, OUString const & locale) {
buf.append("/['*");
SAL_WARN_IF(
locale.match("*"), "comphelper",
"Locale \"" << locale << "\" starts with \"-\"");
"Locale \"" << locale << "\" starts with \"*\"");
assert(locale.indexOf('&') == -1);
assert(locale.indexOf('"') == -1);
assert(locale.indexOf('\'') == -1);
......
......@@ -337,9 +337,7 @@ void Service::setLocale(css::lang::Locale const & eLocale)
css::lang::Locale Service::getLocale() throw (css::uno::RuntimeException) {
osl::MutexGuard guard(*lock_);
css::lang::Locale loc;
if ( locale_ == "*" ) { /* FIXME-BCP47: WTF is this?!? */
loc.Language = locale_;
} else if (! locale_.isEmpty()) {
if (! locale_.isEmpty()) {
loc = LanguageTag( locale_).getLocale( false);
}
return loc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment