Re: [Cppcms-users] How to format readable date from unix timestamp within template?
Brought to you by:
artyom-beilis
|
From: augustin <aug...@ov...> - 2013-12-10 01:54:34
|
On Monday, December 09, 2013 02:24:42 PM Artyom Beilis wrote:
> The problem with this clode
>
> std::ostringstream buf;
> app()->render(std::string("my_skin"), std::string("book_page"), buf, c);
> cp->rContent = buf.str();
>
> is that buf does not have a locale object associated with it.
>
> You need to add following line
>
> buf.imbue(app()->context().locale());
>
> i.e.
>
> std::ostringstream buf;
> buf.imbue(app()->context().locale());
> app()->render(std::string("my_skin"), std::string("book_page"), buf, c);
> cp->rContent = buf.str();
>
> The response().out() - the default output already has a locale embedded in
> it. when you create a generic std::ostream you need to imbue application
> specific locale (even if it is default system locale) to make various
> localization related tools to work.
That's it!
Thanks a lot.
Do you think it would be useful for me to add something about this in the
wiki?
If you wish, I can create a page in an appropriate place to document such
newbie gotchas.
augustin.
.
|