Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

How to Prepare an Angular Component for Translation

Learn how to mark Angular component templates and code for translation, provide context for translators, handle ICU messages, and extract locale files.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To prepare an Angular component for translation, mark fixed template text with i18n, mark translatable attributes with i18n-attribute, and wrap strings in component code with $localize. Add useful translator context, use ICU expressions for plural or choice-dependent messages, then extract the marked text with ng extract-i18n.

Mark fixed text in the component template

Add i18n to each element whose text content should be translated. For example:

As an Amazon Associate I earn from qualifying purchases.

<h1 i18n>Hello!</h1>

For text that should be translated without adding a visible wrapper element, use ng-container:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<ng-container i18n>Welcome back</ng-container>

Mark text-valued attributes

Use the matching i18n-{attribute} marker for an attribute containing user-facing text. For example, mark an image’s title with i18n-title:

<img src="help.png" title="Help" i18n-title>

Only mark text intended for localization; technical values such as image paths are not translation messages. See Angular’s template marking guidance.

Add context translators can use

Angular message metadata can include a meaning, a description, and a custom ID. The syntax is {meaning}|{description}@@{id}. Meaning distinguishes identical words used in different senses; description supplies context. For example:

<h1 i18n="site header|Introduction heading">Hello!</h1>

Descriptions help people understand a message, but do not affect its generated message ID. The same source text and meaning can be extracted once even when descriptions differ; a different meaning produces a different ID. Angular documents this behavior in its guide to managing marked text and custom IDs.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Name interpolations

When a message contains a value, give the placeholder a name that explains its role. For example, a username placeholder is more useful to a translator than an anonymous expression:

<p i18n>Hello, {{ username //i18n(ph="name") }}!</p>

Placeholder names clarify what changes inside the message; they do not replace the need to translate the surrounding sentence as a whole.

Mark strings in component code with $localize

For a string in TypeScript rather than a template, use Angular’s $localize tagged template literal. Its metadata uses the same meaning, description, and ID convention, with a colon-delimited form:

const heading = $localize`:site header|Introduction heading:Hello!`;

For interpolated code strings, provide explicit placeholder names when they help explain the value to translators. Angular’s $localize API documentation describes the tagged-string API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Represent plurals and choices as complete messages

Use ICU plural expressions when wording depends on a quantity and select expressions when it depends on a string choice. Include an other case so the message has a fallback. For example:

{minutes, plural, =0 {just now} =1 {one minute ago} other {{{ minutes }} minutes ago}}

The categories and grammar shown in an English example are not a universal set for every language. Give translators the complete message and its alternatives in context rather than splitting the English fragments into independently translated strings. Angular’s preparation guide covers ICU expressions.

Install localization support and extract the messages

Angular’s package guide documents ng add @angular/localize; it updates package and TypeScript configuration. By default, the package is placed in devDependencies. The --use-at-runtime option places it in dependencies; follow the requirements of the project’s Angular version and build configuration. See Add the localize package.

  1. From the project root, mark the template messages and code strings that need translation.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Run ng extract-i18n to create the source translation file. The default output is messages.xlf.

  3. If needed, configure the output format, filename, or directory with the extraction command’s options described in Angular’s translation-file guide.

  4. Use the extracted source file to create and translate a file for each target locale, including its plural and alternate-text expressions.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose message IDs with maintenance in mind

Angular generates IDs based on source text and meaning. Custom IDs are useful when a translation workflow requires a specific ID format or when a team wants IDs to carry application metadata. They also shift maintenance responsibility to the team: changing the source text does not change a custom ID, so an existing translation can become out of date.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep custom IDs unique. If different source strings share one custom ID, Angular can use the same extracted translation for both locations. Review extracted messages when source wording changes, especially where custom IDs are used. The details are in Angular’s guide to custom IDs.

Know what runtime translation loading does

$localize can evaluate messages using translations loaded at runtime, but loading another translation later does not update messages already processed. Angular’s loadTranslations API documents that this does not provide dynamic language switching without refreshing the browser. Treat runtime loading and extraction-based translated builds as distinct implementation approaches, not as interchangeable promises of live language switching.

Angular’s official internationalization overview provides the broader context for the framework’s localization workflow. The documentation reviewed for this guidance was accessed October 7, 2026; it does not identify a precise Angular release for every displayed instruction, so check the documentation for the version installed in your project.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.