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
Using translate
pipe
Setting the Active Language
Use setActiveLang
to change the active language:
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.
Observing Language Changes
Subscribe to the langChanges$
observable to be notified of language changes:
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:
Use ${lang}
(e.g., en
, fa
) for the language code and ${scope}
(e.g., common
, products
).