logoalt Hacker News

account42 • today at 9:55 AM • 1 reply • view on HN

> Setting de_DE means writing "a million and change" as 1.000.000,69 which sometimes causes problems copying data from one window to another but mostly confuses me.

It also breaks programs all the time because a lot of languages make the users locale the default for formatting and parsing numbers even though there are many use cases where you want a neutral, fixed format.

It's sad that POSIX-likes are still stuck on the concept of a fixed set of locales instead of something more flexible where you can have a sensible choice of RFC 3339 dates with untranslated English text and your local currency but formatted with a . decimal separator. Instead we have to use hacks like en_DK that only partially fix the issue for some.


Replies

1718627440 • today at 10:45 AM

> make the users locale the default for formatting and parsing numbers even though there are many use cases where you want a neutral

This is just the usual case of not selecting a different locale meaning the locale is inherited from the parent. You can just specify the locale instead of omitting it, if you want another one.

> It's sad that POSIX-likes are still stuck on the concept of a fixed set of locales

That's not really the case. The locale names are just labels for your favorite settings and they are prepopulated with the official ones (who's names are standardized). You can name your locale "what_my_grandma_likes_to_read".

As an example for en_GB:

    $ cat /usr/share/i18n/locales/en_GB
    comment_char %
    escape_char /
    
    % This file is part of the GNU C Library and contains locale data.
    % The Free Software Foundation does not claim any copyright interest
    % in the locale data contained in this file.  The foregoing does not
    % affect the license of the GNU C Library as a whole.  It does not
    % exempt you from the conditions of the license if your use would
    % otherwise be governed by that license.
    
    % English language locale for Britain
    % Source: RAP
    % Address: Sankt Jo//rgens Alle 8
    %    DK-1615 Ko//benhavn V, Danmark
    % Contact: Keld Simonsen
    % Email: [email protected]
    % Tel: +45 - 31226543
    % Fax: +45 - 33256543
    % Language: en
    % Territory: GB
    % Revision: 4.3
    % Date: 1996-10-15
    % Users: general
    
    LC_IDENTIFICATION
    title      "English locale for Britain"
    source     "RAP"
    address    "Sankt J<U00F8>rgens Alle 8, DK-1615 K<U00F8>benhavn V, Danmark"
    contact    "Keld Simonsen"
    email      "[email protected]"
    tel        ""
    fax        ""
    language   "British English"
    territory  "United Kingdom"
    revision   "1.0"
    date       "2000-06-28"
    
    category "i18n:2012";LC_IDENTIFICATION
    category "i18n:2012";LC_CTYPE
    category "i18n:2012";LC_COLLATE
    category "i18n:2012";LC_TIME
    category "i18n:2012";LC_NUMERIC
    category "i18n:2012";LC_MONETARY
    category "i18n:2012";LC_MESSAGES
    category "i18n:2012";LC_PAPER
    category "i18n:2012";LC_NAME
    category "i18n:2012";LC_ADDRESS
    category "i18n:2012";LC_TELEPHONE
    category "i18n:2012";LC_MEASUREMENT
    END LC_IDENTIFICATION
    
    LC_CTYPE
    copy "i18n"
    
    translit_start
    include "translit_combining";""
    translit_end
    END LC_CTYPE
    
    LC_COLLATE
    % Copy the template from ISO/IEC 14651
    copy "iso14651_t1"
    END LC_COLLATE
    
    LC_MONETARY
    int_curr_symbol         "GBP "
    currency_symbol         "<U00A3>"
    mon_decimal_point       "."
    mon_thousands_sep       ","
    mon_grouping            3;3
    positive_sign           ""
    negative_sign           "-"
    int_frac_digits         2
    frac_digits             2
    p_cs_precedes           1
    p_sep_by_space          0
    n_cs_precedes           1
    n_sep_by_space          0
    p_sign_posn             1
    n_sign_posn             1
    END LC_MONETARY
    
    LC_NUMERIC
    decimal_point           "."
    thousands_sep           ","
    grouping                3;3
    END LC_NUMERIC
    
    LC_TIME
    abday       "Sun";"Mon";"Tue";"Wed";"Thu";"Fri";"Sat"
    day         "Sunday";/
                "Monday";/
                "Tuesday";/
                "Wednesday";/
                "Thursday";/
                "Friday";/
                "Saturday"
    abmon       "Jan";"Feb";/
                "Mar";"Apr";/
                "May";"Jun";/
                "Jul";"Aug";/
                "Sep";"Oct";/
                "Nov";"Dec"
    mon         "January";/
                "February";/
                "March";/
                "April";/
                "May";/
                "June";/
                "July";/
                "August";/
                "September";/
                "October";/
                "November";/
                "December"
    d_t_fmt     "%a %d %b %Y %T %Z"
    d_fmt       "%d//%m//%y"
    t_fmt       "%T"
    am_pm       "am";"pm"
    t_fmt_ampm  "%l:%M:%S %P %Z"
    date_fmt    "%a %e %b %H:%M:%S %Z %Y"
    week    7;19971130;4
    first_weekday 2
    END LC_TIME
    
    LC_MESSAGES
    copy "en_US"
    END LC_MESSAGES
    
    LC_PAPER
    copy "i18n"
    END LC_PAPER
    
    LC_TELEPHONE
    tel_int_fmt    "+%c %a %l"
    tel_dom_fmt    "%A %l"
    int_select     "00"
    int_prefix     "44"
    END LC_TELEPHONE
    
    LC_MEASUREMENT
    copy "i18n"
    END LC_MEASUREMENT
    
    LC_NAME
    copy "en_US"
    END LC_NAME
    
    LC_ADDRESS
    postal_fmt    "%f%N%a%N%d%N%b%N%s %h %e %r%N%z %T%N%c%N"
    country_name "United Kingdom"
    country_ab2   "GB"
    country_ab3   "GBR"
    country_num   826
    country_car    "GB"
    lang_name     "English"
    lang_ab      "en"
    lang_term    "eng"
    lang_lib    "eng"
    END LC_ADDRESS
➕ show 1 reply