i18n is applied

This commit is contained in:
병준 박 2019-12-18 13:44:26 +09:00
parent db0c720f17
commit 26d112bd55
11 changed files with 65 additions and 14 deletions

View File

@ -98,7 +98,7 @@ autoUpdater.autoDownload = false;
autoUpdater.logger = log;
const ucapMessengerLauncher = new AutoLaunch({
name: app.getName()
name: app.name
});
app.on(ElectronAppChannel.SecondInstance, (event, args, workingDirectory) => {
@ -412,9 +412,9 @@ ipcMain.on(FileChannel.ReadFile, (event: IpcMainEvent, ...args: any[]) => {
try {
fse.readFile(root(args[0]), (err, data) => {
if (!!err) {
event.returnValue = null;
event.returnValue = err;
} else {
event.returnValue = new Blob([data]);
event.returnValue = data;
}
});
} catch (error) {

View File

@ -4,10 +4,13 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
export async function createTranslateLoader(nativeService: NativeService) {
// tslint:disable-next-line: variable-name
import { environment } from '../environments/environment';
export function createTranslateLoader(nativeService: NativeService) {
const translateLoader = nativeService.getTranslateLoader(
'./assets/i18n/',
environment.production
? './assets/i18n/'
: '/projects/ucap-webmessenger-app/src/assets/i18n/',
'.json'
);

View File

@ -1,6 +1,6 @@
<div>
<div class="current-head">
<h3>그룹</h3>
<h3>{{ 'group.label' | translate }}</h3>
<div class="btn-box">
<button
mat-icon-button

View File

@ -24,6 +24,7 @@ import {
NotificationSetting
} from '@ucap-webmessenger/ui-settings';
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
import { TranslateService } from '@ngx-translate/core';
export interface MessengerSettingsDialogData {}
@ -50,6 +51,7 @@ export class MessengerSettingsDialogComponent implements OnInit {
private localStorageService: LocalStorageService,
private ucapTranslateService: UCapTranslateService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private translateService: TranslateService,
private store: Store<any>,
@Inject(DOCUMENT) private document: Document,
private renderer2: Renderer2
@ -78,6 +80,7 @@ export class MessengerSettingsDialogComponent implements OnInit {
);
}
if (this.appUserInfo.settings.general.locale !== setting.locale) {
this.translateService.use(setting.locale);
}
if (
this.appUserInfo.settings.general.hrInfoLocale !== setting.hrInfoLocale

View File

@ -40,6 +40,8 @@ import { MatChipsModule } from '@angular/material/chips';
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
import { TranslateModule } from '@ngx-translate/core';
import { UCapUiModule } from '@ucap-webmessenger/ui';
import { UCapUiAccountModule } from '@ucap-webmessenger/ui-account';
import { UCapUiChatModule } from '@ucap-webmessenger/ui-chat';
@ -92,6 +94,8 @@ import { DIALOGS } from './dialogs';
PerfectScrollbarModule,
TranslateModule,
UCapUiModule,
UCapUiAccountModule,
UCapUiChatModule,

View File

@ -16,12 +16,12 @@ export class AppService {
private sessionStorageService: SessionStorageService,
private appNotificationService: AppNotificationService,
private appNativeService: AppNativeService,
// private translateService: TranslateService,
private translateService: TranslateService,
private ucapTranslateService: UCapTranslateService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService
) {
// this.translateService.setDefaultLang('ko');
// this.translateService.use('ko');
this.translateService.setDefaultLang('ko');
this.translateService.use('ko');
this.ucapTranslateService.setDefaultLang('ko');
this.ucapTranslateService.use('ko');

View File

@ -9,6 +9,7 @@ import { LocalStorageService } from '@ucap-webmessenger/web-storage';
import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type';
import { environment } from '../../../../environments/environment';
import { TranslateService } from '@ngx-translate/core';
@Injectable()
export class Effects {
@ -23,6 +24,8 @@ export class Effects {
environment.customConfig.appKey
);
this.translateService.use(appUserInfo.settings.general.locale);
this.ucapTranslateService.use(
appUserInfo.settings.general.hrInfoLocale
);
@ -32,6 +35,7 @@ export class Effects {
);
constructor(
private actions$: Actions,
private translateService: TranslateService,
private ucapTranslateService: UCapTranslateService,
private localStorageService: LocalStorageService
) {}

View File

@ -1 +1,17 @@
{}
{
"common": {
"search": "Search",
"searchWord": "Search word",
"useOnlyForSpecialCharacter": "Can only use Special characters: {{0}}"
},
"group": {
"label": "Group",
"addNew": "Add new group",
"expandMore": "Expand all groups",
"expandLess": "Collapse all groups",
"name": "Group name"
},
"chat": {},
"organization": {},
"message": {}
}

View File

@ -1 +1,17 @@
{}
{
"common": {
"search": "검색",
"searchWord": "검색어",
"useOnlyForSpecialCharacter": "특수문자는 {{0}}만 사용할 수 있습니다."
},
"group": {
"label": "그룹",
"addNew": "새 그룹 추가",
"expandMore": "그룹 전체 열기",
"expandLess": "그룹 전체 닫기",
"name": "그룹 이름"
},
"chat": {},
"organization": {},
"message": {}
}

View File

@ -166,7 +166,12 @@ export class ElectronNativeService implements NativeService {
readFile(path: string): Promise<Buffer> {
return new Promise<Buffer>((resolve, reject) => {
try {
resolve(this.ipcRenderer.sendSync(FileChannel.ReadFile, path));
const buffer = this.ipcRenderer.sendSync(FileChannel.ReadFile, path);
if (!!buffer) {
resolve(buffer);
} else {
reject(buffer as Error);
}
} catch (error) {
reject(error);
}

View File

@ -15,7 +15,7 @@ export class TranslateLoaderService implements TranslateLoader {
public getTranslation(lang: string): Observable<any> {
return new Observable<any>(subscriber => {
this.nativeService
.readFile(`${this.prefix}${lang}.${this.suffix}`)
.readFile(`${this.prefix}${lang}${this.suffix}`)
.then(buffer => {
subscriber.next(JSON.parse(buffer.toString('utf-8')));
})