Reusable String operations for translation with Dynamic Markup
npm install @ng-dot/translateDefine
Text
language will Auto-select from HTML[lang] Attribute. If it does not set in AppModule.
typescript
import {NgModule} from '@angular/core';
import {TextModule} from '@ng-dot/translate';
@NgModule({
imports: [
TextModule.forRoot({
language: 'en'
})
]
})
export class AppModule {
}
`
$3
`typescript
@NgModule({
imports: [
TextModule.forFeature({
words: {
en: {
FOO: 'foo',
BAR: 'bar'
}
}
})
]
})
export class LibModule {
}
`
$3
`typescript
import {DotTranslateService} from '@ng-dot/translate';
@Component({
template:
})
export class FooComponent {
constructor(_translate: DotTranslateService) {
const foo = _translate.getDefine('FOO');
}
}
`
$3
`typescript
import {DotTranslateService} from '@ng-dot/translate';
@Component({
template:
})
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;
});
}
}
``