murattunalı.

Locale.

A locale is the setting that defines a user’s language and region together and determines the formatting rules.

It differs from a language tag in scope: a language tag declares the language of the text, while a locale determines how numbers, dates, currency and sorting are formatted.

The difference shows in concrete examples. The decimal separator is a comma in Turkish and a full stop in English. Date order varies by country. Alphabetical sorting puts the Turkish letters ç, ğ, ı, ö, ş and ü in their own places — English sorting does not.

  1. Number format — decimal and thousands separators.
  2. Date and time — order and separator vary by country.
  3. Currency — symbol, position and separator.
  4. Sorting — alphabet rules are language-specific.
  5. Case conversion — Turkish’s dotted and dotless i require a special rule.

The last item is a trap: most programming languages’ default conversion does not know the Turkish rules and turns a capital dotless I into a dotted i. In slug generation and search comparisons that produces wrong results.

Modern browsers offer these formatters natively and they are more reliable than hand-written formatting code — because they keep the rules current. A hand-written date formatter goes silently wrong the day a rule changes.

A locale and a language tag are often confused but do different jobs: the tag declares the language of the text, the locale determines the formatting rules. A page can be in Turkish and still show dates in an international format.

Hand-written code for formatting is less reliable than the browser’s built-in functions — because it does not keep the rules current. When a country’s date format or currency symbol changes, hand-written code goes silently wrong.

Two items need special care for Turkish: alphabetical sorting and case conversion. Both give wrong results with the default settings and require a language-aware call.

  1. Number format — decimal and thousands separators vary by language.
  2. Date and time — order and separator by country.
  3. Currency — symbol, position and separator.
  4. Sorting — the Turkish alphabet wants its own rules.
  5. Case — Turkish’s dotted and dotless i require a special rule.

A note on implementation: formatting should be left to the browser’s built-in functions. A hand-written date or currency formatter goes silently wrong when a rule changes, and it takes months to notice.

SOURCES