diff --git a/package-lock.json b/package-lock.json index 8136dfed..7c1c84de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -268,6 +268,11 @@ "integrity": "sha1-w6DFRNYjkqzCgTpCyKDcb1j4aSI=", "dev": true }, + "@ngx-translate/core": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@ngx-translate/core/-/core-8.0.0.tgz", + "integrity": "sha1-dR/WtRLYDzp0jS3o38lt/vopr+A=" + }, "@schematics/angular": { "version": "0.0.45", "resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-0.0.45.tgz", diff --git a/package.json b/package.json index 98d73d90..c7bae3e7 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@angular/platform-browser": "4.4.6", "@angular/platform-browser-dynamic": "4.4.6", "@angular/router": "4.4.6", + "@ngx-translate/core": "8.0.0", "@swimlane/ngx-charts": "6.0.2", "@swimlane/ngx-datatable": "9.3.1", "@swimlane/ngx-dnd": "3.0.0", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 491dd3a0..29e2809f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; import { FuseSplashScreenService } from './core/services/splash-screen.service'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector : 'fuse-root', @@ -8,7 +9,18 @@ import { FuseSplashScreenService } from './core/services/splash-screen.service'; }) export class AppComponent { - constructor(private fuseSplashScreen: FuseSplashScreenService) + constructor( + private fuseSplashScreen: FuseSplashScreenService, + private translate: TranslateService + ) { + // Add languages + this.translate.addLangs(['en', 'tr']); + + // Set the default language + this.translate.setDefaultLang('en'); + + // Use a language + this.translate.use('en'); } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index ad6fbdb6..c125b9bd 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -21,6 +21,7 @@ import { ComponentsThirdPartyModule } from './main/content/components-third-part import { ServicesModule } from './main/content/services/services.module'; import { FuseAngularMaterialModule } from './main/content/components/angular-material/angular-material.module'; import { MarkdownModule } from 'angular2-markdown'; +import { TranslateModule } from '@ngx-translate/core'; const appRoutes: Routes = [ { @@ -69,6 +70,7 @@ const appRoutes: Routes = [ RouterModule.forRoot(appRoutes), SharedModule, MarkdownModule.forRoot(), + TranslateModule.forRoot(), InMemoryWebApiModule.forRoot(FuseFakeDbService, { delay : 0, diff --git a/src/app/core/modules/shared.module.ts b/src/app/core/modules/shared.module.ts index fe2787f2..bec7938c 100644 --- a/src/app/core/modules/shared.module.ts +++ b/src/app/core/modules/shared.module.ts @@ -19,8 +19,10 @@ import { FuseHljsComponent } from '../components/hljs/hljs.component'; import { FusePerfectScrollbarDirective } from '../directives/fuse-perfect-scrollbar/fuse-perfect-scrollbar.directive'; import { FuseIfOnDomDirective } from '../directives/fuse-if-on-dom/fuse-if-on-dom.directive'; import { FuseMaterialColorPickerComponent } from '../components/material-color-picker/material-color-picker.component'; +import { FuseTranslationLoaderService } from '../services/translation-loader.service'; import { CookieService } from 'ngx-cookie-service'; import { MarkdownModule } from 'angular2-markdown'; +import { TranslateModule } from '@ngx-translate/core'; @NgModule({ declarations : [ @@ -62,7 +64,8 @@ import { MarkdownModule } from 'angular2-markdown'; NgxDatatableModule, FuseIfOnDomDirective, FuseMaterialColorPickerComponent, - MarkdownModule + MarkdownModule, + TranslateModule ], entryComponents: [ FuseConfirmDialogComponent @@ -71,7 +74,8 @@ import { MarkdownModule } from 'angular2-markdown'; CookieService, FuseMatchMedia, FuseNavbarVerticalService, - FuseMatSidenavHelperService + FuseMatSidenavHelperService, + FuseTranslationLoaderService ] }) diff --git a/src/app/core/services/translation-loader.service.ts b/src/app/core/services/translation-loader.service.ts new file mode 100644 index 00000000..27283713 --- /dev/null +++ b/src/app/core/services/translation-loader.service.ts @@ -0,0 +1,27 @@ +import { Injectable } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; + +export interface Locale +{ + lang: string; + data: Object; +} + +@Injectable() +export class FuseTranslationLoaderService +{ + constructor(private translate: TranslateService) + { + } + + public loadTranslations(...args: Locale[]): void + { + const locales = [...args]; + + locales.forEach((locale) => { + // use setTranslation() with the third argument set to true + // to append translations instead of replacing them + this.translate.setTranslation(locale.lang, locale.data, true); + }); + } +} diff --git a/src/app/main/content/apps/mail/i18n/en.ts b/src/app/main/content/apps/mail/i18n/en.ts new file mode 100644 index 00000000..1e3b4b34 --- /dev/null +++ b/src/app/main/content/apps/mail/i18n/en.ts @@ -0,0 +1,14 @@ +export const locale = { + lang: 'en', + data: { + 'MAIL': { + 'COMPOSE' : 'COMPOSE', + 'FOLDERS' : 'FOLDERS', + 'FILTERS' : 'FILTERS', + 'LABELS' : 'LABELS', + 'NO_MESSAGES' : 'There are no messages!', + 'SELECT_A_MESSAGE_TO_READ': 'Select a message to read', + 'SEARCH_PLACEHOLDER': 'Search for an e-mail or contact' + } + } +}; diff --git a/src/app/main/content/apps/mail/i18n/tr.ts b/src/app/main/content/apps/mail/i18n/tr.ts new file mode 100644 index 00000000..03a524de --- /dev/null +++ b/src/app/main/content/apps/mail/i18n/tr.ts @@ -0,0 +1,14 @@ +export const locale = { + lang: 'tr', + data: { + 'MAIL': { + 'COMPOSE' : 'YENİ E-POSTA', + 'FOLDERS' : 'KLASÖRLER', + 'FILTERS' : 'FİLTRELER', + 'LABELS' : 'ETİKETLER', + 'NO_MESSAGES' : 'Mesajiniz bulunmamakta!', + 'SELECT_A_MESSAGE_TO_READ': 'Okumak için bir mesaj seçin', + 'SEARCH_PLACEHOLDER' : 'E-mail yada bir kişi arayın' + } + } +}; diff --git a/src/app/main/content/apps/mail/mail-details/mail-details.component.html b/src/app/main/content/apps/mail/mail-details/mail-details.component.html index c85a005f..87b785b2 100644 --- a/src/app/main/content/apps/mail/mail-details/mail-details.component.html +++ b/src/app/main/content/apps/mail/mail-details/mail-details.component.html @@ -1,6 +1,10 @@