|
Boost Users : |
Subject: Re: [Boost-users] [Locale] Getting correct system locale under Mac OS X
From: Artyom Beilis (artyomtnk_at_[hidden])
Date: 2013-11-11 16:58:55
> On Mon, 11/11/13, Orhun Birsoy <orhunbirsoy_at_[hidden]> wrote:
>
> I am running 10.8.5 and when I select "Norway
> (Norwegian Bokmal)" (nb_NO) as the region, LANG env.
> variable is undefined, making
> boost::locale::generator("") to generate a
> "C" locale. I can of-course get the locale
> identifier from NSLocale (or CFLocale) and initialize the
> boost::locale::generator with "nb_NO" which seems
> to be working, but with Mavericks things got even more
> interesting.
The boost locale uses LANG, LC_ALL, and LC_CTYPE to detect
the locale, this is how the locale is defined on POSIX systems
and on Mac OS X (at least on my copy IIRC)
ICU uses internally the same way to do it.
> It looks like, in 10.9 you can mix and match
> language with a country anyway you like i.e. I can select
> "Norway" as my region and "English" as
> my language and again LANG is empty but NSLocale returns
> "en_NO".
Boost.Locale supports a single locale, it does not allow "combining"
different types of locale.
> But this time when I use
> boost::locale::generator("en_NO"),
> boost::locale::as::number uses "." (dot) as
> decimal separator, although NSLocale reports ","
> (comma).
The problem en_NO is not standard locale like there is
no ru_US. I.e. it is not a part of CLDR.
http://demo.icu-project.org/icu-bin/locexp#region
So it does some fallbacks.
> 1. Can boost::locale handle such combinations
> (en_NO, en_TR, etc)? (I am using ICU backend, others are
> explicitly turned off). a. for number
> formatting? b. for messages formatting
> (translations)? which mo will it pick for en_TR ?
> 2. How can I 'customize' locale generated by
> boost::locale to reflect the changes user might do in system
> locale settings (i.e. select en_US but change the decimal
> symbol)?
The setup is defined by CLDR or by the database of the specific backend.
Now, about mo-translation it is little bit different. It tries to match the best. If there is en_TR/LC_MESSAGES/app.mo and the locale is en_TR it would try to load it, afterwards it would try to load en/LC_MESSAGES/app.mo
> Thanks.
> Orhun Birsoy
Regards
Artyom Beilis
--------------
CppCMS - C++ Web Framework: http://cppcms.com/
CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net