Thread: [Cppcms-users] Intionalization method call raises exception
Brought to you by:
artyom-beilis
|
From: CN L. <cn...@gr...> - 2013-08-03 04:37:50
|
Hi!
I use wikipp as my starting point.
--------
config.js:
"wikipp" : {
//trimmed off
"disable_registration" : false,
"languages" : {
"en" : "en_US.UTF-8",
"tw" : "zh_TW.UTF-8"
},
},
"localization" : {
"backend" : "icu",
"locales" : [ "en_US.UTF-8", "zh_TW.UTF-8" ],
"messages" : {
"paths" : [ "/usr/local/share/locale","./locale" ],
"domains" : [ "wikipp" ]
}
}
--------
tw.po:
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Lokalize 1.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid "LANG"
msgstr "繁體中文"
--------
After running make and make install, file "wikipp.mo" does exist in directories
/usr/local/share/locale/tw/LC_MESSAGES/
and
./locale/tw/LC_MESSAGES/
--------
master.cpp:
master::master(wiki &_w) :
application(_w.service()),
wi(_w),
locale_name(wi.locale_name)
{
conn = wi.conn;
cppcms::json::object langs=settings().get("wikipp.languages",cppcms::json::object());
for(cppcms::json::object::const_iterator i=langs.begin(),e=langs.end();i!=e;++i) {
std::string lname;
if(i->first=="en")
lname="English";
else {
lname=_("LANG").str(service().generator().generate(i->second.str()));
if(lname=="LANG")
{
//Non-English contents always go here. Never get translated!
BOOSTER_DEBUG("not translated:") << i->first << "," << i->second.str();
lname=i->first;
}
}
languages[lname]=settings().get<std::string>("wikipp.script") +"/"+ i->first.str();
}
media=settings().get<std::string>("wikipp.media");
cookie_prefix=settings().get("session.cookies.prefix","cppcms_session")+"_";
}
void master::current_language(content::master &m,std::string const &locale_name)
{
m.current_language=_("LANG").str(service().generator().generate(locale_name));
}
-----------
The log:
2013-08-03 12:08:43; not translated:, debug: tw,zh_TW.UTF-8 (master.cpp:112)
2013-08-03 12:08:43; not translated:, debug: tw,zh_TW.UTF-8 (master.cpp:112)
2013-08-03 12:08:43; not translated:, debug: tw,zh_TW.UTF-8 (master.cpp:112)
2013-08-03 12:08:43; not translated:, debug: tw,zh_TW.UTF-8 (master.cpp:112)
2013-08-03 12:08:43; not translated:, debug: tw,zh_TW.UTF-8 (master.cpp:112)
When
void master::current_language(content::master &m,std::string const &locale_name)
is called by page.cpp, the following exception is thrown:
2013-08-03 12:11:02; cppcms, error: Caught exception [Conversion failed]
0xb7689063: booster::stack_trace::trace(void**, int) + 0x23 in /usr/local/lib/libbooster.so.0
0xb768c3cb: booster::locale::conv::conversion_error::conversion_error() + 0xab in /usr/local/lib/libbooster.so.0
0xb768e7a6: booster::locale::conv::impl::iconv_between::convert(char const*, char const*) + 0x1e6 in /usr/local/lib/libbooster.so.0
0xb7689b93: booster::locale::conv::impl::convert_between(char const*, char const*, char const*, char const*, booster::locale::conv::method_type) + 0x93 in /usr/local/lib/libbooster.so.0
0xb7689d7e: booster::locale::conv::between(char const*, char const*, std::string const&, std::string const&, booster::locale::conv::method_type) + 0x4e in /usr/local/lib/libbooster.so.0
0xb769ebca: booster::locale::gnu_gettext::mo_message<char>::load_file(std::string const&, std::string const&, std::string const&, int, booster::function<std::vector<char, std::allocator<char> > (std::string const&, std::string const&)> const&) + 0x90a in /usr/local/lib/libbooster.so.0
0xb76a30e2: booster::locale::gnu_gettext::mo_message<char>::mo_message(booster::locale::gnu_gettext::messages_info const&) + 0x7c2 in /usr/local/lib/libbooster.so.0
0xb769aad8: booster::locale::message_format<char>* booster::locale::gnu_gettext::create_messages_facet<char>(booster::locale::gnu_gettext::messages_info const&) + 0x38 in /usr/local/lib/libbooster.so.0
0xb76ca2cc: booster::locale::impl_icu::icu_localization_backend::install(std::locale const&, unsigned int, unsigned int) + 0x95c in /usr/local/lib/libbooster.so.0
0xb7698a28: booster::locale::localization_backend_manager::impl::actual_backend::install(std::locale const&, unsigned int, unsigned int) + 0x88 in /usr/local/lib/libbooster.so.0
0xb7695db2: booster::locale::generator::generate(std::locale const&, std::string const&) const + 0x202 in /usr/local/lib/libbooster.so.0
0xb769621f: booster::locale::generator::generate(std::string const&) const + 0x4f in /usr/local/lib/libbooster.so.0
0x805da99: apps::master::current_language(content::master&, std::string const&) + 0x39 in ./wikipp
0x80644e7: apps::home::display() + 0x167 in ./wikipp
0x8056624: apps::wiki::main(std::string) + 0x1f4 in ./wikipp
0xb7520abf: cppcms::http::context::dispatch(booster::intrusive_ptr<cppcms::application>, std::string, bool) + 0x8f in /usr/local/lib/libcppcms.so.1
0xb7522948: booster::function<void ()>::callable_impl<void, cppcms_boost::_bi::bind_t<void, void (*)(booster::intrusive_ptr<cppcms::application>, std::string, bool), cppcms_boost::_bi::list3<cppcms_boost::_bi::value<booster::intrusive_ptr<cppcms::application> >, cppcms_boost::_bi::value<std::string>, cppcms_boost::_bi::value<bool> > > >::call() + 0x68 in /usr/local/lib/libcppcms.so.1
0xb7523e90: cppcms::impl::thread_pool::worker() + 0x80 in /usr/local/lib/libcppcms.so.1
0xb7523c61: booster::function<void ()>::callable_impl<void, cppcms_boost::_bi::bind_t<void, cppcms_boost::_mfi::mf0<void, cppcms::impl::thread_pool>, cppcms_boost::_bi::list1<cppcms_boost::_bi::value<cppcms::impl::thread_pool*> > > >::call() + 0x21 in /usr/local/lib/libcppcms.so.1
0xb76fa68f: booster_thread_func + 0x2f in /usr/local/lib/libbooster.so.0
0xb7175c39: ??? + 0xb7175c39 in /lib/i386-linux-gnu/i686/cmov/libpthread.so.0
0xb725f78e: clone + 0x5e in /lib/i386-linux-gnu/i686/cmov/libc.so.6
(http_context.cpp:139)
----
To see what happen, I change config.js to
"localization" : {
//"locales" : [ "en_US.UTF-8", "zh_TW.UTF-8" ],
"locales" : [ "zh_TW.BIG5" ],
"messages" : {
"paths" : [ "/usr/local/share/locale","./locale" ],
"domains" : [ "wikipp" ]
}
,"disable_charset_in_content_type":true
}
It is weird! The rendered English html page is never changed - Content-Type is always "charset=utf-8":
<head>
<title>My Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
|