Advanced 15 min read

Internationalization Considerations

By the end of this lesson, you'll be able to:

  • Explain why hardcoded formats and text break for non-English users
  • Format numbers, dates, and currency using the user's locale
  • Combine Custom Labels with locale-aware formatting for fully internationalized components

Prerequisites: "Loading Third-Party JavaScript Libraries"

Why This Matters

A date rendered as 08/09/2026 is ambiguous — August 9th in the US date convention, but the 8th of September elsewhere. A hardcoded $ currency symbol is simply wrong for a user in another currency's locale. Real Salesforce orgs are frequently used by teams across many countries, and components need to adapt, not assume one locale.

@salesforce/i18n

import LOCALE from '@salesforce/i18n/locale';
import CURRENCY_CODE from '@salesforce/i18n/currency';

@salesforce/i18n exposes the running user's actual locale and currency settings — the values to feed into formatting, rather than a hardcoded assumption.

The Intl API

get formattedDate() {
    return new Intl.DateTimeFormat(LOCALE).format(new Date(this.record.createdDate));
}

get formattedAmount() {
    return new Intl.NumberFormat(LOCALE, { style: 'currency', currency: CURRENCY_CODE }).format(this.record.amount);
}

The browser-native Intl API (Intl.DateTimeFormat, Intl.NumberFormat) formats a value correctly for a given locale — passing in the user's real locale from @salesforce/i18n instead of hardcoding one produces output that's actually correct for that specific user.

Combining with Custom Labels

Locale-aware formatting (this lesson) handles numbers, dates, and currency; Custom Labels (Lesson 4) handle translatable text. A genuinely internationalized component needs both — correctly formatted data, and text that's actually translated for the user reading it.

Exercise

Write a formattedRevenue getter that formats this.revenue as currency using the user's actual locale and currency, imported from @salesforce/i18n.

Show hint

Use Intl.NumberFormat with style: "currency".

JAVASCRIPT

Exercise

Challenge: explain, as a comment, why a date rendered as "08/09/2026" is genuinely ambiguous without locale context.

Show hint

Think about the different date-ordering conventions used around the world.

JAVASCRIPT

Internationalization Considerations Quiz

1. What does @salesforce/i18n/locale provide?

2. What browser-native API is used for locale-aware number and date formatting?

3. Why is "08/09/2026" ambiguous without locale context?

4. What do Custom Labels and locale-aware formatting together provide?

5. What option configures Intl.NumberFormat to render a value as currency?

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

Salesforce orgs are frequently multi-national — locale-aware formatting and Custom Labels together are what make a component work correctly for every user, not just English-speaking ones in the US.