Hacker News new | past | comments | ask | show | jobs | submit login

If someone sets the language to (say) French but keeps their locale as English, do you write a thousand as 1,000 or 1.000? What about the reverse case?



Congratulation: You just opened the Pandora box of locale vs language!

My understanding would be that locale should dictate numerical formatting. But one could argue the opposite and also be right.


If you were discussing POSIX locale, the definitions are quite clear, and there's no ambiguity. But that's also because POSIX subdivides locale into many subsections.

From "man setlocale":

       LC_ALL              All of the locale

       LC_ADDRESS          Formatting of addresses and
                           geography-related items (*)

       LC_COLLATE          String collation

       LC_CTYPE            Character classification

       LC_IDENTIFICATION   Metadata describing the locale (*)

       LC_MEASUREMENT      Settings related to measurements
                           (metric versus US customary) (*)

       LC_MESSAGES         Localizable natural-language messages

       LC_MONETARY         Formatting of monetary values

       LC_NAME             Formatting of salutations for persons (*)

       LC_NUMERIC          Formatting of nonmonetary numeric values

       LC_PAPER            Settings related to the standard paper size (*)

       LC_TELEPHONE        Formats to be used with telephone services (*)

       LC_TIME             Formatting of date and time values


Not to disparage the conversation the technical bits are certainly interesting but, for almost every application, this is the point where things move towards diminishing returns. You could invest infinitely into getting every bit of design and copy for every language and locale permutation flawless and you’re company would be worse off because you should have spent that time elsewhere. In many cases, it’s simply not unrealistic to expect your customer to use google translate.


If we're opening Pandora's boxes...

I've got GNOME set up in English, but my region to be the Netherlands. It will helpfully display local dates, but that also results in the month names being in Dutch.


Maybe that's what the Gnome interface limits you to (no idea) but LC_TIME and the timezone are not inherently linked under Linux.

If by "local dates" dates you mean the format rather than timezone then LC_TIME=en_DK will give you English text with RFC3339 YYYY-MM-DD formatting.


Unfortunately I don't really know what LC_TIME is :) But if I look through the calendar widget that drops down when I click the time in the top bar, is says e.g. that the previous month is called "augustus" and that today is "vrijdag". Looking into my "Region & Language" settings, my language is set to English (United Kingdom), and formats is set to Nederland (Nederlands), which is said to cover numbers, dates and currencies. Especially for currencies I'd prefer my local currency, but I'd prefer for numbers to use the UK system, and not quite sure what I'd like for dates as long as it's not the US system.


I checked the documentation for the ICU Unicode library and Apple's Foundation library, and they both say that numerical formatting is a property of the locale rather than the language. I'd be surprised if other major platforms did otherwise.


Yeah my understanding is people would classify this as locale too, but it's always seemed weird to me. I guess my question is whether this is about formatting to begin with. Periods mean something different depending on the language, right? It seems less about displaying it differently and more about conveying correct information. But then again, mm/dd/yy and dd/mm/yy are often exposed as a formatting option...


Ouch. If you are writing user interface for something that doesn't need to be "correct" (legally, or whatever), I find it best to accept whatever decimal separator (what you want, or change by locale, or both, whatever), and never use or allow thousands separators. Bonus points if you document it somewhere on the interface.

If you really, really, really need a thousands separator, use spaces.


Locale would be a country so e.g. UK? Then it'd be just like the US (1,000).


This is correct, but if we're being pedantic (it is HN after all) the locale code for the UK is "gb". The language / locale would be fr-gb.

I work on this sort of thing for airline ticketing pages. fr-gb would mean the customer wants the page text to be in French, but they want to buy a ticket using the UK system (i.e. Using GBP instead of EUR as the currency if possible, and all the formatting differences that would be specific to "gb").

Quick edit: technically I guess your locale doesn't have to determine your store region, that's just how we do it. As far as I know there's nothing except development effort preventing us from allowing someone to book a flight in French, using GB locale, and with preference for the Japanese point-of-sale system.


I really appreciate websites that allow me to use "Denmark - English" and see prices and payment options I understand, in the language I understand best.


locale defines decimal formatting




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: