Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
@lakea/gravity-translate-adapter-transloco
Advanced tools
An adapter for `GrTranslate` using [`Transloco`](https://ngneat.github.io/transloco/) as implementation.
An adapter for GrTranslate
using Transloco
as implementation.
Install the library using NPM:
npm install @lakea/gravity-translate-adapter-transloco @ngneat/transloco --save
Next, create a new file, translate-adapter-root.module.ts
which exposes an Angular's module with a default configuration.
import {NgModule} from '@angular/core';
import {GrTranslateAdapterTranslocoModule} from '@lakea/gravity-translate-adapter-transloco';
@NgModule({
imports: [
GrTranslateAdapterTranslocoModule.forRoot({
availableLangs: ['en', 'es'],
defaultLang: 'en',
reRenderOnLangChange: true,
prodMode: false, // get from your environments file
}),
],
})
export class TranslateAdapterRootModule {}
Import TranslateAdapterRootModule
to application root module like app.module.ts
.
You should import the TranslateAdapterRootModule once in your root module.
The TranslateAdapterRootModule
file imports the GrTranslateAdapterTranslocoModule
which has all Transloco
initial configs.
To configure transloco
library, read the docs here.
Going forward, you need to provide a global app config injector with baseUrl
property.
Add it to you app root module (maybe app.module.ts
):
providers: [
{
provide: 'APP_CONFIG',
useValue: {
// change for your app baseUrl
// (don't miss to deal with prod url)
baseUrl: 'http://localhost:4200'
},
},
]
baseUrl
is used byTranslocoLoader
to load translations file fromassets
.
Create your adapter implementation class extending GrTranslate
abstraction:
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {HashMap} from '@lakea/gravity/cdk';
import {GrTranslate} from '@lakea/gravity/translate';
@Injectable()
export class GrTranslateAdapter extends GrTranslate {
constructor() {
super();
}
public activeLanguageChanges$(): Observable<string> {
// YOUR IMPLEMENTATION
}
public changeActiveLanguage(lang: string): void {
// YOUR IMPLEMENTATION
}
public getActiveLanguage(): string {
// YOUR IMPLEMENTATION
}
public getAvailableLanguages(): string[] {
// YOUR IMPLEMENTATION
}
public translate<T = string | string[]>(key: T, options?: HashMap): Observable<T> {
// YOUR IMPLEMENTATION
}
}
So, provide it on your application root module (maybe app.module.ts
), like this:
providers: [
{
provide: GrTranslate,
useClass: GrTranslateAdapter,
}
]
FAQs
An adapter for `GrTranslate` using [`Transloco`](https://ngneat.github.io/transloco/) as implementation.
The npm package @lakea/gravity-translate-adapter-transloco receives a total of 4 weekly downloads. As such, @lakea/gravity-translate-adapter-transloco popularity was classified as not popular.
We found that @lakea/gravity-translate-adapter-transloco demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.