Skip to content

Commit

Permalink
Improved `addLangs()
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeAndWeb committed Nov 3, 2024
1 parent b07d36f commit 0818cec
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions projects/ngx-translate/src/lib/translate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,12 @@ export class TranslateService {
/**
* Add available languages
*/
public addLangs(langs: string[]): void {
langs.forEach((lang: string) => {
if (this.langs.indexOf(lang) === -1) {
this.langs.push(lang);
}
});
public addLangs(langs: string[]): void
{
const newLangs = langs.filter(lang => !this.langs.includes(lang));
if (newLangs.length > 0) {
this.langs = [...this.langs, ...newLangs];
}
}

/**
Expand Down

0 comments on commit 0818cec

Please sign in to comment.