Re: [Cppcms-users] How to format readable date from unix timestamp within template?
Brought to you by:
artyom-beilis
|
From: sergey l. <ccp...@gm...> - 2013-12-10 03:24:29
|
Hello friends! There are some references about locale in stream in documentation. http://cppcms.com/cppcms_ref/latest/classcppcms_1_1application.html#a3a1342b4834c8cdb79c2619dff010319 Render a template template_name of a skin skin using content content to an output stream out. Note: You are responsible to imbue suitable locale to the stream. On Tue, Dec 10, 2013 at 5:54 AM, augustin <aug...@ov...>wrote: > 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. > > > > > . > > > ------------------------------------------------------------------------------ > Sponsored by Intel(R) XDK > Develop, test and display web and hybrid apps with a single code base. > Download it for free now! > > http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |