Ctrl + K
Get StartedStylesCoreCompsCDK
Translation

Translation

This document describes how to use the ACoreX i18n (internationalization) system within your Angular applications. ACoreX i18n provides a streamlined way to manage translations and display localized content, with built-in support for Farsi (fa-IR) and English (en-US) out of the box.

Default Translation Files

ACoreX includes default translation files for Farsi (fa/common.json) and English (en/common.json).

Importing and Injecting AXTranslationService

product-details.component.ts

Using translate pipe

product-details.page.html

Setting the Active Language

Use setActiveLang to change the active language:

product-details.component.ts

Getting the Active and Default Languages

getActiveLang() : Returns the currently active language (e.g., "fa", "en").

getDefaultLang() : Returns the default language configured for the application.

product-details.component.ts

Observing Language Changes

Subscribe to the langChanges$ observable to be notified of language changes:

product-details.component.ts

Customizing and Extending Translations (with Scopes)

Translation files should be placed in the following structure:

  src/assets/i18n/
      └── ${lang}/
          └── ${scope}.json
  

Here are example product.json files demonstrating interpolation:

src/assets/i18n/en/product.json
src/assets/i18n/fa/product.json

Use ${lang} (e.g., en, fa) for the language code and ${scope} (e.g., common, products).

product-details.page.html

Translating in Component Code

product-details.component.ts
On this page