-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from tysonpaul89/issue-269
Issue 269
- Loading branch information
Showing
7 changed files
with
58 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/app/shared/modules/language-translation/language-translation.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* This module is used to language translations. | ||
* The translations are saved in a json file in /src/app/assets/i18n directory | ||
* Docs: https://www.codeandweb.com/babeledit/tutorials/how-to-translate-your-angular7-app-with-ngx-translate | ||
*/ | ||
import { NgModule } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
|
||
// import ngx-translate and the http loader | ||
import { | ||
TranslateLoader, | ||
TranslateModule, | ||
TranslateService | ||
} from '@ngx-translate/core'; | ||
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; | ||
|
||
// ngx-translate - required for AOT compilation | ||
export function HttpLoaderFactory(http: HttpClient) { | ||
return new TranslateHttpLoader(http); | ||
} | ||
|
||
@NgModule({ | ||
declarations: [], | ||
imports: [ | ||
TranslateModule.forRoot({ | ||
loader: { | ||
provide: TranslateLoader, | ||
useFactory: HttpLoaderFactory, | ||
deps: [HttpClient] | ||
} | ||
}) | ||
], | ||
exports: [ | ||
TranslateModule | ||
], | ||
}) | ||
export class LanguageTranslationModule { | ||
constructor( | ||
private translate: TranslateService, | ||
) { | ||
// Gets Default language from browser if available, otherwise set English ad default | ||
this.translate.addLangs(['en', 'fr', 'ur', 'es', 'it', 'fa', 'de', 'zh-CHS']); | ||
this.translate.setDefaultLang('en'); | ||
const browserLang = this.translate.getBrowserLang(); | ||
this.translate.use(browserLang.match(/en|fr|ur|es|it|fa|de|zh-CHS/) ? browserLang : 'en'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters