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,\ ...@@ -48,6 +48,7 @@ $(eval $(call gb_Library_use_libraries,comphelper,\
sal \ sal \
salhelper \ salhelper \
ucbhelper \ ucbhelper \
i18nisolang1 \
$(gb_UWINAPI) \ $(gb_UWINAPI) \
)) ))
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "rtl/instance.hxx" #include "rtl/instance.hxx"
#include "rtl/ustrbuf.hxx" #include "rtl/ustrbuf.hxx"
#include "rtl/ustring.hxx" #include "rtl/ustring.hxx"
#include "i18npool/languagetag.hxx"
namespace { namespace {
...@@ -62,32 +63,11 @@ struct TheConfigurationWrapper: ...@@ -62,32 +63,11 @@ struct TheConfigurationWrapper:
OUString getDefaultLocale( OUString getDefaultLocale(
css::uno::Reference< css::uno::XComponentContext > const & context) css::uno::Reference< css::uno::XComponentContext > const & context)
{ {
css::lang::Locale locale( return LanguageTag(
css::uno::Reference< css::lang::XLocalizable >( css::uno::Reference< css::lang::XLocalizable >(
css::configuration::theDefaultProvider::get(context), css::configuration::theDefaultProvider::get(context),
css::uno::UNO_QUERY_THROW)-> css::uno::UNO_QUERY_THROW)->
getLocale()); getLocale()).getBcp47();
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();
} }
OUString extendLocalizedPath(OUString const & path, OUString const & locale) { OUString extendLocalizedPath(OUString const & path, OUString const & locale) {
...@@ -95,7 +75,7 @@ OUString extendLocalizedPath(OUString const & path, OUString const & locale) { ...@@ -95,7 +75,7 @@ OUString extendLocalizedPath(OUString const & path, OUString const & locale) {
buf.append("/['*"); buf.append("/['*");
SAL_WARN_IF( SAL_WARN_IF(
locale.match("*"), "comphelper", locale.match("*"), "comphelper",
"Locale \"" << locale << "\" starts with \"-\""); "Locale \"" << locale << "\" starts with \"*\"");
assert(locale.indexOf('&') == -1); assert(locale.indexOf('&') == -1);
assert(locale.indexOf('"') == -1); assert(locale.indexOf('"') == -1);
assert(locale.indexOf('\'') == -1); assert(locale.indexOf('\'') == -1);
......
...@@ -337,9 +337,7 @@ void Service::setLocale(css::lang::Locale const & eLocale) ...@@ -337,9 +337,7 @@ void Service::setLocale(css::lang::Locale const & eLocale)
css::lang::Locale Service::getLocale() throw (css::uno::RuntimeException) { css::lang::Locale Service::getLocale() throw (css::uno::RuntimeException) {
osl::MutexGuard guard(*lock_); osl::MutexGuard guard(*lock_);
css::lang::Locale loc; css::lang::Locale loc;
if ( locale_ == "*" ) { /* FIXME-BCP47: WTF is this?!? */ if (! locale_.isEmpty()) {
loc.Language = locale_;
} else if (! locale_.isEmpty()) {
loc = LanguageTag( locale_).getLocale( false); loc = LanguageTag( locale_).getLocale( false);
} }
return loc; 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