Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,461
    Plugin Contributions
    29

    Default What value for locale should I use on my server?

    So, as I was saying earlier (https://www.zen-cart.com/showthread....l-server-maybe),
    it may sometimes be a real headache to know what to put in your main language file (the equivalent of english.php) for this
    PHP Code:
      $locales = array('en_US''en_US.utf8''en''English_United States.1252'); 
    so that you do not get character set/encoding issues.

    As I develop on Windows/Xampp, the php-generated day names in spanish are displayed with corrupted characters where the accent should be
    eg.: s�bado 23 diciembre 1978,
    a typical encoding problem that can often be seen on the interweb, and usually easily fixed with a bit of care.

    Using setlocale(LC_ALL, $locales); instead of LC_TIME
    and adding
    ini_set('default_charset', "UTF-8");
    to php.ini
    do not fix this problem, which I think is not fixable.
    It seems Windows cannot produce these utf-8 things as mentioned here:
    "The locale argument can take a locale name, a language string, a language string and country/region code, a code page, or a language string, country/region code, and code page. The set of available locale names, languages, country/region codes, and code pages includes all those supported by the Windows NLS API except code pages that require more than two bytes per character, such as UTF-7 and UTF-8.
    If you provide a code page value of UTF-7 or UTF-8, setlocale will fail, returning NULL."
    So, the only solution I found was to convert the result in function zen_date_long to utf-8 only for Windows as shown here
    PHP Code:
        return ( stristr(PHP_OS,"win") ? 
        
    utf8_encode(strftime(DATE_FORMAT_LONGmktime($hour$minute$second$month$day$year))) : 
        
    strftime(DATE_FORMAT_LONGmktime($hour$minute$second$month$day$year)) );  
      } 
    I spent/wasted hours down this particular rabbit-hole and wrote a script to identify what values for locale you could use on your particular server. I also added a few links to the most useful references I found on the topic and a way to list all installed locales on a Windows computer (added here for googlers), so here it is for your delight:
    test_locales.zip
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto, Product Listing Sorter...

  2. #2
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,461
    Plugin Contributions
    29

    Default Re: What value for locale should I use on my server?

    Example output from the script
    Windows 10 /Xampp
    English


    Trying: 'en'
    locale 'en' found for 'en'. eg.: Saturday 23 December 1978

    Trying: 'english_gbr'
    locale 'English_United Kingdom.1252' found for 'english_gbr'. eg.: Saturday 23 December 1978

    Trying: 'english_britain'
    locale 'English_United Kingdom.1252' found for 'english_britain'. eg.: Saturday 23 December 1978

    Trying: 'english_england'
    locale 'English_United Kingdom.1252' found for 'english_england'. eg.: Saturday 23 December 1978

    Trying: 'english_great britain'
    locale 'English_United Kingdom.1252' found for 'english_great britain'. eg.: Saturday 23 December 1978

    Trying: 'english_uk'
    locale 'English_United Kingdom.1252' found for 'english_uk'. eg.: Saturday 23 December 1978

    Trying: 'english_united kingdom'
    locale 'English_United Kingdom.1252' found for 'english_united kingdom'. eg.: Saturday 23 December 1978

    Trying: 'english_united-kingdom'
    locale 'English_United Kingdom.1252' found for 'english_united-kingdom'. eg.: Saturday 23 December 1978

    Trying: 'en_GB.utf8'
    No locale found for 'en_GB.utf8'

    Trying: 'en_US'
    No locale found for 'en_US'

    Trying: 'en_US.utf8'
    No locale found for 'en_US.utf8'

    Trying: 'en_us_utf8'
    No locale found for 'en_us_utf8'

    Trying: 'en.UTF-8'
    No locale found for 'en.UTF-8'

    Trying: 'english_usa'
    locale 'English_United States.1252' found for 'english_usa'. eg.: Saturday 23 December 1978

    Trying: 'english_america'
    locale 'English_United States.1252' found for 'english_america'. eg.: Saturday 23 December 1978

    Trying: 'english_united states'
    locale 'English_United States.1252' found for 'english_united states'. eg.: Saturday 23 December 1978

    Trying: 'english_united-states'
    locale 'English_United States.1252' found for 'english_united-states'. eg.: Saturday 23 December 1978

    Trying: 'english_us'
    locale 'English_United States.1252' found for 'english_us'. eg.: Saturday 23 December 1978

    Dutch


    Trying: 'nl_NL.utf8'
    No locale found for 'nl_NL.utf8'

    Trying: 'nl'
    locale 'nl' found for 'nl'. eg.: zaterdag 23 december 1978

    Trying: 'nl-NL'
    locale 'nl-NL' found for 'nl-NL'. eg.: zaterdag 23 december 1978

    Trying: 'nld_nld'
    locale 'Dutch_Netherlands.1252' found for 'nld_nld'. eg.: zaterdag 23 december 1978

    German


    Trying: 'de'
    locale 'de' found for 'de'. eg.: Samstag 23 Dezember 1978

    Trying: '[email protected]'
    No locale found for '[email protected]'

    Trying: 'de_DE'
    No locale found for 'de_DE'

    Trying: 'deu_deu'
    locale 'German_Germany.1252' found for 'deu_deu'. eg.: Samstag 23 Dezember 1978

    Spanish


    Trying: 'es_utf8'
    No locale found for 'es_utf8'

    Trying: 'es'
    locale 'es' found for 'es'. eg.: s�bado 23 diciembre 1978

    Trying: 'es-ES'
    locale 'es-ES' found for 'es-ES'. eg.: s�bado 23 diciembre 1978

    Trying: 'Spanish_Modern_Sort'
    No locale found for 'Spanish_Modern_Sort'

    Trying: 'es_utf8'
    No locale found for 'es_utf8'

    Trying: '[email protected]'
    No locale found for '[email protected]'

    Trying: 'esp_esp'
    locale 'Spanish_Spain.1252' found for 'esp_esp'. eg.: s�bado 23 diciembre 1978

    Trying: 'esp_spain'
    locale 'Spanish_Spain.1252' found for 'esp_spain'. eg.: s�bado 23 diciembre 1978

    Trying: 'spanish_esp'
    locale 'Spanish_Spain.1252' found for 'spanish_esp'. eg.: s�bado 23 diciembre 1978

    Trying: 'spanish_spain'
    locale 'Spanish_Spain.1252' found for 'spanish_spain'. eg.: s�bado 23 diciembre 1978

    Trying: 'es_ES.utf8'
    No locale found for 'es_ES.utf8'

    Trying: 'es-es'
    locale 'es-es' found for 'es-es'. eg.: s�bado 23 diciembre 1978
    I can't post the UNIX result, CK editor chokes on something.

    Note that this script will show the installed locales on Unix.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto, Product Listing Sorter...

  3. #3
    Join Date
    Jan 2010
    Location
    Bulgaria
    Posts
    22
    Plugin Contributions
    2

    Default Re: What value for locale should I use on my server?

    Hello there,

    I'm not sure if here is the right place for my post. If necessary please move to another place.

    I'm working on Bulgarian language pack now using ZenCart-1.5.5d. I'm not familiar with php! In /includes/languages/bulgarian.php (a copy of the original /includes/languages/english.php) there are some lines that I am not sure how to change.
    Is there someone who could give me a piece of advice with this?

    PHP Code:

    // look in your $PATH_LOCALE/locale directory for available locales..
      
    $locales = array('bg_BG''bg_BG.utf8''bg''Bulgarian_Bulgaria.1251');
      @
    setlocale(LC_TIME$locales);
      
    define('DATE_FORMAT_SHORT''%d/%m/%Y');  // this is used for strftime()
      
    define('DATE_FORMAT_LONG''%A %d %B, %Y'); // this is used for strftime()
      
    define('DATE_FORMAT''d/m/Y'); // this is used for date()
      
    define('DATE_TIME_FORMAT'DATE_FORMAT_SHORT ' %H:%M:%S');

    ////
    // Return date in raw format
    // $date should be in format mm/dd/yyyy
    // raw date is in format YYYYMMDD, or DDMMYYYY
      
    if (!function_exists('zen_date_raw')) {
        function 
    zen_date_raw($date$reverse false) {
          if (
    $reverse) {
            return 
    substr($date32) . substr($date02) . substr($date64);
          } else {
            return 
    substr($date64) . substr($date02) . substr($date32);
          }
        }
      }

    // if USE_DEFAULT_LANGUAGE_CURRENCY is true, use the following currency, instead of the applications default currency (used when changing language)
      
    define('LANGUAGE_CURRENCY''BGN');

    // Global entries for the <html> tag
      
    define('HTML_PARAMS','dir="ltr" lang="bg"'); 
    Should I make changes to those:

    PHP Code:
    define('HTML_PARAMS','dir="ltr" 
    and

    PHP Code:
            return substr($date32) . substr($date02) . substr($date64);
          } else {
            return 
    substr($date64) . substr($date02) . substr($date32); 
    It needs to be in this formats: DDMMYYYY and bg_BG.utf8
    I hope that I am clear enough.
    Thank you in advance!

  4. #4
    Join Date
    Jul 2012
    Posts
    16,481
    Plugin Contributions
    17

    Default Re: What value for locale should I use on my server?

    Not being familiar with the Bulgarian language, is it one where one reads from left-to-right (ltr) or right-to-left (rtl) that would determine whether the dir= tag would need to be modified away from its current left-to-right.

    Having $reverse = true would provide a raw date in the order desired if the date is provided as mm/dd/yyyy. This is opposite of the "default". My suggestion would be to add a line after the function declaration and before the if statement that is:

    $reverse = !$reverse;

    That will/should take a false result and make it true or a true result and make it false. Should also verify that there is not already a function of zen_date_raw in the code because if so changes here would have no effect.

    But also not sure if you are indicating whether the date is entered by the user in the series/sequence provided or if the result of zen_date_raw is as you have asked. I mean it appears that existing code may not work properly if the dat is provided as described in the code and the above modification is made because for example the account_edit page expects the first four characters to refer to the year when zen_date_raw has a false value for $reverse.

    Now if the dates are provided as ddmmyyyy, then for "normal" output well... should just ask:

    What date needs to be formatted as ddmmyyyy? The input or the output of the function?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jan 2010
    Location
    Bulgaria
    Posts
    22
    Plugin Contributions
    2

    Default Re: What value for locale should I use on my server?

    Thank you for your reply mc12345678

    I didn't know that "ltr" stands for left-to-right, so that's clear for me now. Bulgarian is ltr.

    I am wondering if my locales are properly filled ('bg_BG', 'bg_BG.utf8', 'bg', 'Bulgarian_Bulgaria.1251')?

    And I would like when Bulgarian is selected in the site to display the dates to the customers and admins in the format ddmmyyyy instead of mmddyyyy.
    There is this tutorial: https://www.zen-cart.com/content.php...-to-dd-mm-yyyy
    I was not sure if it is applicable to 1.5.5d. In it there is no change to "$reverse =" but there are changes to those digits "return substr($date, 3, 2) . substr($date, 0, 2) . substr($date, 6, 4);...."
    Does someone knows if I could use the tutorial? It seems to be the right way.

    Regards!

  6. #6
    Join Date
    Jul 2012
    Posts
    16,481
    Plugin Contributions
    17

    Default Re: What value for locale should I use on my server?

    Quote Originally Posted by znlambov View Post
    Thank you for your reply mc12345678

    I didn't know that "ltr" stands for left-to-right, so that's clear for me now. Bulgarian is ltr.

    I am wondering if my locales are properly filled ('bg_BG', 'bg_BG.utf8', 'bg', 'Bulgarian_Bulgaria.1251')?

    And I would like when Bulgarian is selected in the site to display the dates to the customers and admins in the format ddmmyyyy instead of mmddyyyy.
    There is this tutorial: https://www.zen-cart.com/content.php...-to-dd-mm-yyyy
    I was not sure if it is applicable to 1.5.5d. In it there is no change to "$reverse =" but there are changes to those digits "return substr($date, 3, 2) . substr($date, 0, 2) . substr($date, 6, 4);...."
    Does someone knows if I could use the tutorial? It seems to be the right way.

    Regards!
    Items found in the FAQ are maintained up-to-date. That particular tutorial (thank you for doing the leg work) remains applicable and was the other solution I was considering when I stopped writing above. :)

    I didn't look through/at alllll parts of your language rebuild, but I did see that the entry like: bg_BG was correct. Some of the information is located and detailed in the php manual others in multiple other Internet sources or loosely explained in the php manual.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jan 2010
    Location
    Bulgaria
    Posts
    22
    Plugin Contributions
    2

    Default Re: What value for locale should I use on my server?

    Quote Originally Posted by mc12345678 View Post
    Items found in the FAQ are maintained up-to-date. That particular tutorial (thank you for doing the leg work) remains applicable and was the other solution I was considering when I stopped writing above. :)
    Well, in the tutorial there are minor differences with the latest ZC version, but nothing to worry about :)
    Just some missing parts... as far as I remember step 9. is obsolete (or at least missing in ZC1.5.5d).

  8. #8
    Join Date
    Jul 2012
    Posts
    16,481
    Plugin Contributions
    17

    Default Re: What value for locale should I use on my server?

    Quote Originally Posted by znlambov View Post
    Well, in the tutorial there are minor differences with the latest ZC version, but nothing to worry about :)
    Just some missing parts... as far as I remember step 9. is obsolete (or at least missing in ZC1.5.5d).
    Correct, it appears that the constant: DOB_FORMAT_STRING is not used in the admin of ZC 1.5.5d. That said, if in operation/searching your admin side you find that something needs that constant independently defined, then instruction is available. I haven't done any deeper analysis to identify when it was moved out/removed and can't recall if the store side language define is loaded after the admin side to identify that such constants are still loaded to memory, but not specifically on the admin side. That said, in the admin search performed the constant isn't defined nor is it used on the admin side, so it would provide no benefit to define for base operation.

    Yes, perhaps for ZC 1.5.5 (or when it was removed) the instruction could identify "if present", but ideally, one would search for where/if such a modification is needed. Further, having seen what types of things had to be changed (primarily mm/dd/yyyy type entries) after applying the changes of the faq, searching for remaining cases of that string may be of benefit as well. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,461
    Plugin Contributions
    29

    Default Re: What value for locale should I use on my server?

    As part of my spring-clean I have published my script to check what locales you may use with your server:

    https://github.com/torvista/Zen-Cart...Server-Locales
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto, Product Listing Sorter...

 

 

Similar Threads

  1. Replies: 2
    Last Post: 10 Jan 2011, 01:18 AM
  2. What output format should I use for phpMyAdmin backups?
    By AmirGTR in forum General Questions
    Replies: 3
    Last Post: 25 Jan 2010, 07:33 AM
  3. Replies: 9
    Last Post: 12 Jan 2010, 11:21 AM
  4. What add-on should i use?
    By ams30gts in forum All Other Contributions/Addons
    Replies: 5
    Last Post: 27 Jun 2009, 03:43 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR