Internationalization and Localization

  • https://en.wikipedia.org/wiki/Internationalization_and_localization
  • g11n (Globalization)
    • The complete process of making a product ready for the entire world.
  • i18n (Internationalization)
    • Engineering the code framework to handle data dynamically using placeholders instead of hardcoded values
  • t9n (Translation)
    • Translation is strictly about changing text between languages
    • It is part of localization
    • English: Your total is one hundred dollars
    • French: Votre total est de cent dollars
  • l10n (Localization)
    • Localization incorporates translation but also injects functional regional logic
    • French: Votre total est de 92,00 € (changes currency accordingly)
  • g11n = i18n + l10n

Clock

Real-Time Clock (RTC)

sudo hwclock --show

System Clock

  • aka Software Clock
  • Once OS boots up and reads the RTC, the kernel takes over and counts time dynamically by tracking CPU interrupts or clock ticks
  • constantly synced using NTP (Network Time Protocol)
  • Linux stores system time using epoch
    • epoch represents number of non-leap seconds which have passed since 00:00:00 UTC on Thursday, 1 January 1970
    • Its precision can be seconds, milliseconds, nanoseconds
    • https://en.wikipedia.org/wiki/Unix_time
# epoch seconds
> date +%s         
1786188795
 
# epoch milliseconds
> date +%s%3N
1786188872644
 
# epoch nanoseconds
> date +%s%N
1786188884030439201
  • System clock uses following hardware under the hood
    • Timestamp counter (TSC)
      • It is CPU register
      • The TSC counts every single electrical cycle the CPU core executes
    • High Precision Event Timer (HPET)
      • It is a chip on motherboard
      • Ticks at an un-shifting, constant frequency
      • If the Linux kernel detects that your CPU cores are changing speeds dynamically due to heat or power-saving adjustments, The kernel will start using HPET
  • Clock drifting
    • If the clocks drift from network time, NTP resolves it using two methods:
      • Stepping
        • Instantly alters the system clock to match the correct time exactly
        • It breaks the monotonicity of time
        • It can cause crashes of databases, application logs etc.
        • Happens if time error > 128 ms
      • Slewing
        • Gradually adjusts the system clock rate until it matches the correct time without making any instant leaps
        • Time flows smoothly and never moves backward
# use date command for quick modifications
date
 
# modern command to manage global date time
# show date, time, timezone, NTP service status, RTC time
timedatectl

Timezone

  • Timezone related files
    • /usr/share/zoneinfo/
      • Pre-compiled binary rule files for every geographic region on Earth
    • /etc/localtime
      • System default timezone
      • Symlink to one of the timezone in /usr/share/zoneinfo/
      • Example symlink to /usr/share/zoneinfo/Asia/Kolkata
  • How timezone is evaluated
    • TZ variable (if set) —> /etc/localtime (if symlink present) —> UTC
# list timezones
timedatectl list-timezones
 
# see current timezone
date +"%Z %z"
timedatectl

Locale

  • locale command lists different settings for locale
    • LANG is default global blueprint
    • LC_* are specific categories
    • LC_ALL forcibly overwrites all categories
    • LANGUAGE defines a colon-separated list of fallback languages
  • To evaluate config for a category
    • LC_ALL (if set) —> LC_* (if set) —> LANG
  • For text translations (language, not locale)
    • LANGUAGE (if set, try for all fallbacks) —> LC_ALL —> LC_* —> LANG
  • Locale related files
    • /usr/share/i18n/locales/ (Source text files)
      • Human readable data
    • /usr/lib/locale/locale-archive (Binary database)
      • Single optimized binary used by programs
# current locale settings
> locale
LANG=en_IN
LANGUAGE=en_IN:en
LC_CTYPE="en_IN"
LC_NUMERIC="en_IN"
LC_TIME="en_IN"
LC_COLLATE="en_IN"
LC_MONETARY="en_IN"
LC_MESSAGES="en_IN"
LC_PAPER="en_IN"
LC_NAME="en_IN"
LC_ADDRESS="en_IN"
LC_TELEPHONE="en_IN"
LC_MEASUREMENT="en_IN"
LC_IDENTIFICATION="en_IN"
LC_ALL=
 
# list available locales
> locale -a
C
C.utf8
en_IN
en_IN.utf8
POSIX
 
# list available char maps (character sets)
> locale -m
 
# See raw formatting strings queried from locale database
> locale LC_TELEPHONE
+%c ;%a ;%l
 
00
91
UTF-8
  • Documentation on locale
# flags
man locale
# internal file syntax
man 5 locale
# specs and precedence rules
man 7 locale
  • Syntax
    • Language: ISO 639
    • Country code: ISO 3166
      • Uses 2-letter codes (ISO 3166-1 or ISO 3166 Alpha-2)
      • Maintained by International Organization for Standardization (ISO)
      • If omitted, master config will be used for example en (English)
      • examples: US, IN, DE
      • https://www.iso.org/obp/ui/#search
    • Character set: IANA Charset Registry
      • Maintained by Assigned Numbers Authority (IANA)
      • If omitted, system will guess based on language/region
        • for en_US, it will be ISO-8859-1 (Latin-1)
      • examples: UTF-8, ISO-8859-1 (Latin-1), ANSI_X3.4-1968 (ASCII)
      • https://www.iana.org/assignments/character-sets
language[_country-code][.character-set]
  • POSIX or C
    • They are special locales
    • They are aliases of each other
    • no language code or country code used
    • It completely bypasses locale system and uses source code text which is generally in english language
    • Character Set: ANSI_X3.4-1968 (ASCII)

Locale Categories

  • LC_COLLATE: Controls alphabetical sorting logic
    • A, B, a, b (Dictionary order)
    • A, B, C, ..., a, b, c (ASCII order)
  • LC_CTYPE: Character type and encoding
    • UTF-8 is encoding
    • Mapping between lowercase and uppercase
      • English (en_US): i —> I
      • Turkish (tr_TR): i —> İ
  • LC_TIME: Set date and time display
    • 03/07/2026 (India) vs 07/03/2026 (USA)
    • 14:30 (24 hour) vs 02:30 (12 hour)
  • LC_NUMERIC: Sets number punctuation
    • 1,234.56 (USA)
    • 1.234,56 (German)
  • LC_MONETARY
    • ₹100 (India)
    • 100 € (UK)
  • LC_MESSAGES: Sets language used for OS errors and warnings
    • Permission denied (English)
    • Permission refusée (French)
  • LC_PAPER: Sets physical paper dimensions
    • Letter (US)
    • A4 (India)
  • LC_NAME: Formats name and titles
    • Mr. John Smith (US)
    • Smith John (Hungary)
  • LC_ADDRESS: Formats mailing address
    • USA: City, State, ZIP code (New York, NY 10001)
    • Germany: ZIP code before City (10117 Berlin)
  • LC_TELEPHONE: Formats telephone numbers
    • (555) 123-4567 (USA)
    • +91 XXXXX-XXXXX (India)
  • LC_MEASUREMENT: Sets unit of measurement
    • USA: Miles, Pounds, Fahrenheit
    • India: Kilometers, Kilograms, Celsius