Get started with angular-gettext CDN
MIT licensed
Angular-gettext: Library for Angular internationalization, managing translations simply.
Tags:- angular
- gettext
Stable version
Copied!
How to start using angular-gettext CDN
import { Component } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { getText } from 'angular-gettext';
// Set up the TranslateModule with the HttpLoader
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
@Component({
selector: 'app-root',
template: `
<p>{{ 'WELCOME_MESSAGE' | translate }}</p>
`
})
export class AppComponent {
constructor(private translate: TranslateService) {
// Initialize the TranslateService with the HttpLoader
translate.setDefaultLang('en');
translate.use(HttpLoaderFactory);
// Load translations asynchronously
translate.get('messages').subscribe((messages: any) => {
translate.addLangs(['en', 'fr']);
translate.registerTranslation('en', messages);
translate.registerTranslation('fr', messages);
});
}
}
// Define the messages for the translations
const messages = {
'WELCOME_MESSAGE': getText('Welcome to Angular Gettext!')
};
Copied!
Copied!
All versions
0.0.1
0.0.2
0.0.3
0.0.4
0.0.5
0.0.6
0.0.7
0.1.0
0.1.1
0.1.2
0.1.3
0.1.4
0.2.0
0.2.1
0.2.2
0.2.3
0.2.4
0.2.5
0.2.6
0.2.7
0.2.8
0.2.9
0.3.0
0.4.0
1.0.0
1.0.0-alpha.1
1.0.1
1.1.0
1.1.1
1.1.2
1.1.3
1.1.4
2.0.0
2.0.1
2.0.2
2.0.3
2.0.4
2.0.5
2.1.0
2.1.1
2.1.2
2.2.0
2.2.1
2.3.0
2.3.1
2.3.10
2.3.11
2.3.2
2.3.3
2.3.4
2.3.5
2.3.6
2.3.7
2.3.8
2.3.9
2.4.0
2.4.1
*** 2.4.2