Setting @@lc_time_names

A place for users and developers of the Xataface to discuss and receive support.

Setting @@lc_time_names

Postby Cabeza » Fri Oct 05, 2012 8:57 am

Steve,
Any suggestion as to where would be the proper place in the app to insert the ref statement so that the server serves time names in languages other than English?
Thanks.
Cabeza
 
Posts: 31
Joined: Mon Sep 03, 2012 10:25 am

Re: Setting @@lc_time_names

Postby Cabeza » Tue Oct 09, 2012 12:39 am

Steve,
I am going to look into sending this as a mysql_query or df_query via the app's beforeHandleRequest() on conf_ApplicationDelegate, but I would appreciate your comments anyway.
Thanks
Cabeza
 
Posts: 31
Joined: Mon Sep 03, 2012 10:25 am

Re: Setting @@lc_time_names

Postby shannah » Thu Oct 11, 2012 6:29 am

Yes. Put this inside a mysql_query.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Setting @@lc_time_names

Postby Cabeza » Sat Oct 13, 2012 4:33 am

Thanks Steve. It works, with caveats, see below.
For those who may have been following this thread, passing the setting to the MySQL session via

(on conf/ApplicationDelegate.php)

Code: Select all
class conf_ApplicationDelegate {
//...other stuff
    function beforeHandleRequest(){
        $app = Dataface_Application::getInstance();
        $query_lc = "SET @@lc_time_names = 'es_ES'";
        $result_lc = mysql_query($query_lc, df_db());
        //...
    }
   //...
}

works, but only sets the output to whatever locale you choose when the output is managed by MySQL's date format functions. When using php's format functions this setting is of little value. (obvious in hindsight, but not on my first rookie attempt...)
Next step is to try to complete the circle via php's setlocale() and will eventually revert here.
Last edited by Cabeza on Sat Oct 13, 2012 5:42 am, edited 1 time in total.
Cabeza
 
Posts: 31
Joined: Mon Sep 03, 2012 10:25 am

Re: Setting @@lc_time_names

Postby Cabeza » Sat Oct 13, 2012 5:40 am

(the story goes on...)
adding
Code: Select all
$lc_es = setlocale(LC_TIME, 'es_ES.UTF-8');

on beforeHandleRequest() takes care of the php output strings, but it also means that uses of date() have to be refactored to strftime(). Date() is English only and takes no hints from setlocale().
There are a few things to take care when using setlocale() (Check php.net for the nitty gritty). The most important for me -and as warned by Lodovico Grossi @ http://us2.php.net/manual/en/function.setlocale.php- is that using LC_ALL may make a mess of the strings used on mysql_query() calls, so watch out. That is the reason why I went for the less greedy LC_TIME.

Hope it helps.


Xataface version: 1.3.2 on OSX 10.8.x Apache 2.2.22 php 5.3 MySQL 5.5.16
Cabeza
 
Posts: 31
Joined: Mon Sep 03, 2012 10:25 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 21 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved