@ng-dot/translate
v23.191.0
Published
Reusable String operations for translation with Dynamic Markup
Downloads
37
Readme
@ng-dot/translate
Reusable String operations for translation with Dynamic Markup
Concept:
Define
- Short String as like Noun, Verb
- Sync Load
Text
- Long String as like Paragraph
- Async Load
Getting Start
language
will Auto-select from HTML[lang] Attribute. If it does not set in AppModule
.
import {NgModule} from '@angular/core';
import {TextModule} from '@ng-dot/translate';
@NgModule({
imports: [
TextModule.forRoot({
language: 'en'
})
]
})
export class AppModule {
}
Built-in Data
@NgModule({
imports: [
TextModule.forFeature({
words: {
en: {
FOO: 'foo',
BAR: 'bar'
}
}
})
]
})
export class LibModule {
}
Get define
value
import {DotTranslateService} from '@ng-dot/translate';
@Component({
template: `
FOO: {{'FOO' | ofDefine}}
BAR: {{'BAR' | ofDefine}}
`
})
export class FooComponent {
constructor(_translate: DotTranslateService) {
const foo = _translate.getDefine('FOO');
}
}
Get text
value
import {DotTranslateService} from '@ng-dot/translate';
@Component({
template: `
{{'foo' | ofText}}
{{'bar' | ofText}}
`
})
export class FooComponent {
foo: string;
bar: string;
constructor(_translate: DotTranslateService) {
_translate.text('foo')
.subscribe(foo => {
this.foo = foo;
});
_translate.text('bar')
.subscribe(bar => {
this.bar = bar;
});
}
}