@tolgee/ngx
v6.6.0
Published
Angular integration of Tolgee localization tool
Readme
Tolgee is an open-source alternative to Crowdin, Phrase, or Lokalise
What's Tolgee for Angular?
Angular integration library of Tolgee. With this package. It's super simple to add i18n to your Angular app! For more information about using Tolgee with Angular, visit the docs 📖.
Quick links
- Tolgee for Angular docs
- Tolgee JS SDK docs
- Tolgee Website
- Product (Learn more about the great features)
- Tolgee platform docs
Installation
npm install @tolgee/ngxThen use the library in your app.module.ts. You have to add NgxTolgeeModule to your imports section and
add factory provider for TOLGEE_INSTANCE token returning your Tolgee instance.
...
import {
DevTools,
NgxTolgeeModule,
Tolgee,
TOLGEE_INSTANCE,
FormatSimple
} from '@tolgee/ngx';
...
@NgModule({
declarations: [
...
],
imports: [
NgxTolgeeModule,
...
],
providers: [
{
provide: TOLGEE_INSTANCE,
useFactory: () => {
return Tolgee()
.use(DevTools())
.use(FormatSimple())
.init({
language: 'en'
// for development
apiUrl: environment.tolgeeApiUrl,
apiKey: environment.tolgeeApiKey,
// for production
staticData: {
...
}
});
},
},
],
bootstrap: [AppComponent],
})
export class AppModule {}Usage
Translating using pipe:
<h1>{{'hello_world' | translate}}</h1>Or using t attribute
<h1 t key="providing_default_values"></h1>Prerequisites
- You have some Angular-based project
- You have generated an API key from Tolgee Cloud or a self-hosted Tolgee instance.
Why to use Tolgee?
Tolgee saves a lot of time you would spend on localization tasks otherwise. It enables you to provide perfectly translated software.
Features
- All-in-one localization solution for your JS application 🙌
- Out-of-box in-context localization 🎉
- Automated screenshot generation 📷
- Translation management platform 🎈
- Open-source 🔥
Read more on the Tolgee website
Development
We welcome your PRs.
To develop the package locally:
- Clone the repository
- Install the packages in the repository root
pnpm install- Run the development script
pnpm develop:ngxThis runs the development suite of this monorepo for the ngx integration. The changes in each dependency package are
automatically built and propagated to the test application, which you can open and play within the browser.
Testing
To run Jest tests of this package, execute
npm run testIn the /packages/ngx directory.
End-to-end (e2e) testing
To run the e2e tests, simply execute
pnpm run e2e run ngxTo open and play with e2e tests, run:
pnpm run e2e open ngx