Angular ngx-translate wrapper for support default translate and prefixed translations
npm install nga-translateA wrapper for ngx-translate library that supports default and prefixed translations.




ngaTranslate is an Angular library that provides pipes and directives to simplify text translation in Angular applications.
It is a wrapper for the popular ngx-translate library and adds useful features such as default translations and prefix-based translations.
---
To install ngaTranslate, run the following command in your terminal:
``bash`
npm install nga-translate --save
---
The ngaTranslate pipe can be used to translate text inside Angular templates.
It accepts up to three arguments:
- Translation key
- Default translation (string or object, used if key is not found)
- Params (object, for dynamic values)
#### Examples
`html`
{{ 'key' | ngaTranslate }} {{ 'key' | ngaTranslate : 'default translate' }} {{ 'key' | ngaTranslate : 'default translate' : { p1: 'value' }
}} {{ 'key' | ngaTranslate : 'default translate [{ p1 }]' : { p1: 'value' } }} {{ 'key' | ngaTranslate : { en: 'Hello [{ p1 }]', fr:
'Bonjour [{ p1 }]' } : { p1: 'value' } }}
You can also use the pipe with only default values (without an explicit key):
`html`
{{ { en: 'default translate' } | ngaTranslate }} {{ { en: 'default translate [{ p1 }]' } | ngaTranslate : { p1: 'value' } }} {{ { en:
'default [{ p1 }]', fr: 'par défaut [{ p1 }]' } | ngaTranslate : { p1: 'value' } }}
---
The ngaTranslate directive can be used directly on elements.
It supports both a translation key and the element’s content (as default translation).
#### Examples
` Hello, world! Hello, world! Hello, [{ p1 }] { en: 'Hello, [{ p1 }]', fr: 'Bonjour, [{ p1 }]' }html`
---
The ngaTranslatePrefix directive allows you to define a translation prefix for all child elements.
This is useful for grouping translations under a common namespace.
#### Examples
` html`
#### Note:
If the key starts with a dot (.), the prefix will be ignored, and the translation will resolve from the root namespace.
---
1. Simplified syntax – Easier and cleaner than raw ngx-translate usage.
2. Default translations – Specify fallbacks when keys are missing.
3. Contextual translations – Support for parameterized translations.
4. Prefix translations – Automatically prepend a prefix to all translation keys within a scope.
5. Root override – Use keys starting with .` to bypass the prefix.
---
We welcome contributions to ngaTranslate.
Feel free to open an issue or submit a pull request on GitHub.
---
ngaTranslate is licensed under the MIT License.