Nearby lessons
122 of 125Java - Internationalization (I18N)
- What internationalization means
- How Java separates language from code
- The Locale class
- Resource bundles and properties files
Internationalization (I18N) is a core concept of the Java language. This lesson explains What is Internationalization?, Internationalization vs Localization and The Two Key Tools: Locale and ResourceBundle with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
What is Internationalization?
Internationalization means designing a program so that it can work in many languages and regions without changing the code. In short form it is written I18N — because the word Internationalization starts with I, ends with N, and has 18 letters in between.
Real-life example: an app written in English can also show its menus in Hindi, Telugu, French or Arabic — the code stays the same; only the language files change.
A related word is localization (L10N) — the actual work of translating a program into a specific language and making it fit that country's culture (date formats, currency, number formats).
Internationalization vs Localization
| Point | Internationalization (I18N) | Localization (L10N) |
|---|---|---|
| Full meaning | Designing the program to SUPPORT many languages | Actually ADAPTING it to one specific language/country |
| What you do | Write code so text lives in separate files | Create the translated files (Hindi, Telugu...) |
| Done by | Developers | Developers + translators |
| Relationship | The preparation (the ground work) | The translation (the result) |
The Two Key Tools: Locale and ResourceBundle
- Locale — identifies a language + country combination, like en_US (English, United States) or hi_IN (Hindi, India).
- ResourceBundle — loads the correct language file automatically, based on the Locale.
The idea: keep all text in separate files (called resource bundles), one per language. The program picks the right file at run time.
The Properties Files (Our Language Files)
Create one .properties file per language. Each file has key=value pairs.
The file name rule: messages is the base name, then _en, _hi is the locale, then .properties.
Using Locale and ResourceBundle
Numbers, Currency and Dates
The NumberFormat and DateFormat classes automatically show values according to the locale — including the correct currency symbol and date style.
The Benefit of I18N
- No code changes — to support a new language, just add a new properties file.
- One product, many markets — the same app sells worldwide.
- Easy translation — translators only edit the properties files, never the code.
The Locale Class — Constructors
A Locale can be built with one, two or three parts. The classic material uses all three forms:
| Constructor | Parts | Example |
|---|---|---|
| Locale(language) | Only language | new Locale("hi") |
| Locale(language, country) | Language + country | new Locale("hi", "IN") |
| Locale(language, country, variant) | Language + country + variant (OS/region detail) | new Locale("it", "IT", "win") |
Java also gives predefined constants like Locale.US, Locale.UK, Locale.ITALY — useful shortcuts when the locale you need is built-in.
- I18N = writing code that supports many languages; L10N = translating to one specific language.
- Locale = language + country (en_US, hi_IN).
- ResourceBundle loads the right properties file for the locale.
- Properties files hold key=value text, one file per language.
- NumberFormat / DateFormat render currency and dates per locale.
- Supporting a new language = adding one properties file, no code changes.