23 Mar 2013, 13:03
#1
Administrator
- Join Date:
- Sep 2009
- Posts:
- 13,980
- Plugin Contributions:
- 46
Setting locale in template-override directory
I have a multi-lingual site (English and Spanish) and I noticed yesterday that zen_date_long was formatting Saturdays like s�bado, even though my /includes/languages/MY_TEMPLATE/spanish.php had the statement
After much hair-pulling and a helpful link (http://www.zen-cart.com/showthread.php?133111-locale-not-available-on-local-server-maybe) from torvista, I finally figured out what the heck was going on.
I'd upgraded this site from ZC 1.3.9h and converted to UTF-8 in the process. Although my template-override version of spanish.php was setting the locale for UTF-8, my base (i.e. /includes/languages/spanish.php) language file was still setting the locale to the non-UTF-8 format! Since it's a function call instead of a define, the last file loaded (base) "won".
I'm just mentioning this here to save others a fair amount of time and to note that the issue could be rectified by wrapping the call to setlocale with a "define" so that the function will only be run once, e.g.
@setlocale(LC_TIME, 'es_ES.UTF-8');After much hair-pulling and a helpful link (http://www.zen-cart.com/showthread.php?133111-locale-not-available-on-local-server-maybe) from torvista, I finally figured out what the heck was going on.
I'd upgraded this site from ZC 1.3.9h and converted to UTF-8 in the process. Although my template-override version of spanish.php was setting the locale for UTF-8, my base (i.e. /includes/languages/spanish.php) language file was still setting the locale to the non-UTF-8 format! Since it's a function call instead of a define, the last file loaded (base) "won".
I'm just mentioning this here to save others a fair amount of time and to note that the issue could be rectified by wrapping the call to setlocale with a "define" so that the function will only be run once, e.g.
if (!defined('ZEN_SETLOCALE_RUN')) {
define('ZEN_SETLOCALE_RUN', true);
@setlocale(LC_ALL, 'en_EN.UTF-8);
}