MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Translating Dynamic Values, Pluralization, and Dates0%
Study Materials
React.js for AdvancedProgress 0%
1.1Control Props and Inversion of Control Pattern1.2State Reducer Pattern in Advanced React1.3Prop Getters and Flexible Design Systems1.4Headless UI Architecture and Accessibility Primitives
15.1Internationalization Setup with i18next and react-i18next15.2Translating Dynamic Values, Pluralization, and Dates15.3RTL (Right-to-Left) Language Layout Support
HomeTutorialsReact.js for AdvancedTranslating Dynamic Values, Pluralization, and Dates
RTL (Right-to-Left) Language Layout Support

Translating Dynamic Values, Pluralization, and Dates

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

Basic word-for-word string translation breaks down when handling grammatically complex linguistic rules. Different human languages possess completely different rules for pluralization (e.g. English has 2 plural forms, Arabic has 6, Japanese has 0), dynamic currency formatting, and localized calendar dates. Handling these correctly requires combining i18next with the native browser Intl API.


1. Enterprise Pluralization Rules

In English, pluralization is binary (1 item vs many items). In other languages (Russian, Polish, Arabic), nouns change forms based on specific numerical remainder patterns:

1// public/locales/en/common.json
2{
3 "itemCount_one": "You have {{count}} item in your cart",
4 "itemCount_other": "You have {{count}} items in your cart",
5 "itemCount_zero": "Your shopping cart is completely empty"
6}

When invoking t(), pass count:

1// React automatically selects the correct linguistic plural form!
2<p>{t("itemCount", { count: items.length })}</p>

2. Number and Currency Localization via Intl.NumberFormat

Never format currency with hardcoded dollar signs ($${amount}). Different countries format numbers differently (e.g. $1,250.50 in the US vs 1.250,50 € in Germany):

1export function formatCurrency(amount: number, locale: string, currency: string = "USD"): string {
2 return new Intl.NumberFormat(locale, {
3 style: "currency",
4 currency: currency,
5 minimumFractionDigits: 2,
6 }).format(amount);
7}
8 
9// In en-US: formatCurrency(1250.5, "en-US", "USD") ──► "$1,250.50"
10// In de-DE: formatCurrency(1250.5, "de-DE", "EUR") ──► "1.250,50 €"

3. Date & Time Localization via Intl.DateTimeFormat

Formatting dates directly with string concatenation generates confusing timestamps (is 05/06/2026 May 6 or June 5?). Use Intl.DateTimeFormat:

1import React from "react";
2import { useTranslation } from "react-i18next";
3 
4export function TransactionDateBadge({ timestamp }: { timestamp: Date }) {
5 const { i18n } = useTranslation();
6 
7 const formattedDate = new Intl.DateTimeFormat(i18n.language, {
8 dateStyle: "full",
9 timeStyle: "short",
10 }).format(timestamp);
11 
12 return <span className="text-xs font-mono text-slate-400">{formattedDate}</span>;
13}
14 
15// In en-US: "Tuesday, September 15, 2026 at 4:30 AM"
16// In de-DE: "Dienstag, 15. September 2026 um 04:30"
17// In ja-JP: "2026年9月15日火曜日 4:30"

4. Relative Time Formatting (Intl.RelativeTimeFormat)

For real-time feeds displaying "5 minutes ago" or "in 2 days":

1export function formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, locale: string) {
2 const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
3 return rtf.format(value, unit);
4}
5 
6// formatRelativeTime(-5, "minute", "en") ──► "5 minutes ago"
7// formatRelativeTime(-5, "minute", "es") ──► "hace 5 minutos"
8// formatRelativeTime(1, "day", "de") ──► "morgen"

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
Why is naive pluralization (count === 1 ? "item" : "items") considered an internationalization anti-pattern?
Question 2
How does i18next determine which plural translation key to use?
Question 3
Why should native browser Intl APIs (Intl.NumberFormat, Intl.DateTimeFormat) be preferred over heavy external formatting libraries?
Question 4
How does a German locale format the number 1234567.89 compared to US English?
Question 5
What does numeric: "auto" provide in Intl.RelativeTimeFormat?
Next Lesson

RTL (Right-to-Left) Language Layout Support

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Internationalization Setup with i18next and react-i18nextRTL (Right-to-Left) Language Layout Support

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master React.js for Advanced with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext