Localization

Design localized applications with external message catalogs and locale-aware formatting.

Lesson content

đŸŽ¯ Goal By the end of this lesson, you'll understand: What is Localization? What is Internationalization (i18n)? Difference between Localization and Internationalization Why Localization is important How to implement Localization in Node.js Real-world examples Interview questions What is Localization? Localization (L10n) is the process of adapting an application to a specific language, region, or culture . It changes: Language Date Format Time Format Currency Number Format Simple Definition: Localization means showing content according to the user's language and region. What is Internationalization (i18n)? Internationalization (i18n) is the process of designing an application so it can support multiple languages without changing the source code. Simple Definition: Internationalization prepares the application for multiple languages. Why Do We Need Localization? Localization helps: Support users worldwide Improve user experience Increase accessibility Reach global markets Real-Life Example 🌍 Imagine an online shopping website. Customer from India │ â–ŧ Language → Hindi Currency → INR Date → DD/MM/YYYY Customer from USA │ â–ŧ Language → English Currency → USD Date → MM/DD/YYYY The application automatically adapts based on the user's locale. Internationalization vs Localization Internationalization (i18n) Localization (L10n) Prepares the app Adapts the app Developer task Translation & regional customization One-time design Can be done for each language/region Makes multi-language support possible Displays localized content Localization Diagram User │ â–ŧ Language Selected │ â–ŧ Translation File │ â–ŧ Localized Response Install i18n Package npm install i18n Folder Structure project/ │ ├── locales/ │ ├── en.json │ ├── hi.json │ └── fr.json │ ├── app.js └── package.json English Translation locales/en.json { "welcome": "Welcome" , "login": "Login Successful" } Hindi Translation locales/hi.json { "welcome": "⤏āĨā¤ĩā¤žā¤—ā¤¤ ā¤šāĨˆ" , "login": "⤞āĨ‰ā¤—ā¤ŋ⤍ ⤏ā¤Ģ⤞ ā¤šāĨā¤†" } Configure Localization const express = require ( "express" ); const i18n = require ( "i18n" ); const path = require ( "path" ); const app = express (); i18n . configure({ locales: [ "en" , "hi" ], defaultLocale: "en" , directory: path . join( __dirname , "locales" ) }); app . use( i18n . init); Return Localized Message app . get( "/" , ( req , res ) => { res . send( res . __( "welcome" )); }); If the selected language is: English Welcome Hindi ⤏āĨā¤ĩā¤žā¤—ā¤¤ ā¤šāĨˆ Change Language Using Query Parameter http://localhost:3000/?lang=hi Or programmatically req . setLocale( "hi" ); Multiple Languages locales/ en.json hi.json fr.json es.json de.json Localized API Response English { "message": "User Created Successfully" } Hindi { "message": "⤉ā¤Ē⤝āĨ‹ā¤—⤕⤰āĨā¤¤ā¤ž ⤏ā¤Ģā¤˛ā¤¤ā¤žā¤ĒāĨ‚⤰āĨā¤ĩ⤕ ā¤Ŧā¤¨ā¤žā¤¯ā¤ž ā¤—ā¤¯ā¤ž" } Date Localization const date = new Date (); console . log( date . toLocaleDateString( "en-US" ) ); console . log( date . toLocaleDateString( "hi-IN" ) ); Example Output 7/25/2026 25/7/2026 Currency Localization const amount = 1000 ; console . log( new Intl . NumberFormat( "en-US" , { style: "currency" , currency: "USD" } ) . format( amount ) ); Output $1,000.00 Number Localization const number = 1234567 ; console . log( number . toLocaleString( "en-US" ) ); console . log( number . toLocaleString( "hi-IN" ) ); Example Output 1,234,567 12,34,567 Request Flow User Request │ â–ŧ Language Detected │ â–ŧ Translation Loaded │ â–ŧ Localized Response Real-Life Example 🛒 Shopping Website Customer │ â–ŧ Choose Language │ â–ŧ English Hindi French │ â–ŧ Website Displays Selected Language Benefits of Localization ✅ Better User Experience ✅ Global Reach ✅ Easy Language Switching ✅ Improved Customer Satisfaction ✅ Professional Applications Common Localization Methods Method Example Query Parameter ?lang=hi Request Header Accept-Language: hi-IN Cookie Save user's language preference User Profile Store preferred language in the database Best Practices ✅ Store translations in separate files. ✅ Use translation keys instead of hardcoded text. ✅ Detect language from Accept-Language when possible. ✅ Keep translation keys consistent. ✅ Provide a default language. ❌ Don't hardcode user-facing text in your application. ❌ Don't mix different languages in the same translation file. Interview Question What is Localization? Answer Localization is the process of adapting an application to a specific language and region. What is Internationalization? Answer Internationalization is the process of designing an application so it can support multiple languages and regions. What is the difference between i18n and L10n? Answer i18n (Internationalization) prepares the application for multiple languages. L10n (Localization) translates and adapts the application for a specific language or region. What does res.__() do? Answer It retrieves the translated value for a given translation key based on the current locale. Best Practices Checklist ✅ Practice Recommended Translation Files ✅ Default Language ✅ Translation Keys ✅ Accept-Language Support ✅ Separate Locale Files ✅ Localized Dates & Currency ✅ Key Points ✅ Localization adapts an application to a specific language and region. ✅ Internationalization prepares the application for multiple languages. ✅ Store translations in separate locale files. ✅ Use translation keys instead of hardcoded text. ✅ Localize dates, numbers, and currencies using the Intl API. ✅ Always provide a default language. 🧠 Easy Formula Build Application │ â–ŧ Internationalization (i18n) │ â–ŧ Add Translation Files │ â–ŧ Localization (L10n) │ â–ŧ User Selects Language │ â–ŧ Localized Response i18n = Prepare App L10n = Translate App en.json = English hi.json = Hindi res.__() = Get Translation Intl = Format Dates, Numbers & Currency Remember: 🌍 Localization (L10n) = Adapt content for a specific language and region 🌐 Internationalization (i18n) = Prepare the app for multiple languages 📂 Store translations in separate locale files đŸ—Ŗī¸ Use translation keys instead of hardcoded text 📅 Use Intl for formatting dates, numbers, and currencies