-2
I’m using the i18n at the angle as the image below:
In app.component.ts is like this:
import { Component } from "@angular/core";
import { TranslateService } from "@ngx-translate/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
public translate : any;
constructor(translate: TranslateService) {
translate.addLangs(["pt", "en"]);
translate.setDefaultLang("pt");
const browserLang = translate.getBrowserLang();
translate.use(browserLang.match(/pt|en/) ? browserLang : "pt");
}
}
To call what is described in in8, I do so in html:
<span>{{ 'SISTEMA' | translate }} {{ 'NOME_DO_SISTEMA' | translate }}</span>
In the English json it is like this:
{
"NOME_DO_SISTEMA": "from medical clinic",
}
In the Portuguese json it looks like this:
{
"NOME_DO_SISTEMA": "de clinica médica",
}
Accurate if user changes language, changes file according to language set.
I did so:
<option *ngFor="let lang of translate.getLangs()" [value]="lang" [selected]="lang === translate.currentLang">
{{ lang }}</option>
</select>
But has error according to image.
I’m using @ngx-Translate/http-Loader.
What can it be ?
I believe so, I’ll put the code
– Guilherme Costa Lopes