Commit 2a08d696 authored by 神楽坂玲奈's avatar 神楽坂玲奈

i18n

parent 63c630a6
/bin/
/app/*.js
/app/*.js.map
/app/*.metadata.json
/node_modules/
/dist/
/cache/
......
This diff is collapsed.
......@@ -4,18 +4,18 @@ import {InstallConfig} from "./install-config";
import {SettingsService} from "./settings.sevices";
import {App} from "./app";
import {DownloadService} from "./download.service";
import {clipboard, remote, ipcRenderer} from "electron";
import {clipboard, remote} from "electron";
import * as path from "path";
import * as child_process from "child_process";
import {InstallService} from "./install.service";
declare var Notification;
declare var $;
@Component({
moduleId: module.id,
selector: 'app-detail',
templateUrl: 'app/app-detail.component.html',
styleUrls: ['app/app-detail.component.css'],
templateUrl: 'app-detail.component.html',
styleUrls: ['app-detail.component.css'],
})
export class AppDetailComponent implements OnInit {
@Input()
......
......@@ -9,7 +9,6 @@ import {remote} from "electron";
import "rxjs/Rx";
import {AppLocal} from "./app-local";
import * as ini from "ini";
import {platform} from "os";
const Aria2 = require('aria2');
const sudo = require('electron-sudo');
......
/**
* Created by zh99998 on 16/9/2.
*/
import {Component} from "@angular/core";
@Component({
moduleId: module.id,
selector: 'community',
templateUrl: 'app/community.component.html',
styleUrls: ['app/community.component.css'],
templateUrl: 'community.component.html',
styleUrls: ['community.component.css'],
})
export class CommunityComponent {
}
/**
* Created by weijian on 2016/10/26.
*/
import {Injectable, NgZone} from "@angular/core";
import {Http} from "@angular/http";
import {Observable} from "rxjs/Observable";
......
import {TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID} from "@angular/core";
import {remote} from "electron";
export async function getTranslationProviders(): Promise<Object[]> {
let locale = localStorage.getItem('locale');
if (!locale) {
locale = remote.app.getLocale();
localStorage.setItem('locale', locale);
}
const noProviders: Object[] = [];
if (!locale || locale === 'zh-CN') {
return noProviders;
}
const translationFile = `./locale/messages.${locale}.xlf`;
try {
let translations = await getTranslationsWithSystemJs(translationFile);
return [
{provide: TRANSLATIONS, useValue: translations},
{provide: TRANSLATIONS_FORMAT, useValue: 'xlf'},
{provide: LOCALE_ID, useValue: locale}
]
} catch (error) {
return noProviders
}
}
declare var System: any;
function getTranslationsWithSystemJs(file: string) {
return System.import(file + '!text'); // relies on text plugin
}
/**
* Created by weijian on 2016/11/2.
*/
import {Injectable} from "@angular/core";
import {App} from "./app";
import {InstallConfig} from "./install-config";
......@@ -9,12 +8,12 @@ import * as path from "path";
import * as child_process from "child_process";
import * as mkdirp from "mkdirp";
import * as readline from "readline";
import * as fs from 'fs';
import * as fs from "fs";
import {EventEmitter} from "events";
import {AppLocal} from "./app-local";
import {Http} from "@angular/http";
import ReadableStream = NodeJS.ReadableStream;
import {AppsService} from "./apps.service";
import ReadableStream = NodeJS.ReadableStream;
@Injectable()
export class InstallService {
......@@ -36,29 +35,29 @@ export class InstallService {
createDirectory(dir: string) {
return new Promise((resolve, reject)=> {
return new Promise((resolve, reject) => {
mkdirp(dir, resolve);
})
}
getComplete(app: App): Promise<App> {
return new Promise((resolve, reject)=> {
this.eventEmitter.once(app.id, (complete)=> {
return new Promise((resolve, reject) => {
this.eventEmitter.once(app.id, (complete) => {
resolve();
});
});
}
extract(file: string, destPath: string) {
return new Promise((resolve, reject)=> {
return new Promise((resolve, reject) => {
let tarProcess = child_process.spawn(this.tarPath, ['xvf', file, '-C', destPath]);
let rl = readline.createInterface({
input: <ReadableStream>tarProcess.stderr,
});
rl.on('line', (input)=> {
rl.on('line', (input) => {
console.log(input);
});
tarProcess.on('exit', (code)=> {
tarProcess.on('exit', (code) => {
if (code === 0) {
resolve();
} else {
......@@ -72,26 +71,26 @@ export class InstallService {
let action = app.actions.get('install');
if (action) {
let env = Object.assign({}, action.env);
let command:string[] = [];
let command: string[] = [];
command.push(path.join(appPath, action.execute));
command.push(...action.args);
let open = action.open;
if (open) {
let openAction:any = open.actions.get("main");
let openAction: any = open.actions.get("main");
env = Object.assign(env, openAction.env);
command.unshift(...openAction.args);
command.unshift(path.join((<AppLocal>open.local).path, openAction.execute));
}
return new Promise((resolve, reject)=> {
return new Promise((resolve, reject) => {
let child = child_process.spawn(<string>command.shift(), command, {
env: env,
stdio: 'inherit',
shell: true,
});
child.on('error', (error)=> {
child.on('error', (error) => {
console.log(error);
});
child.on('exit', (code)=> {
child.on('exit', (code) => {
if (code === 0) {
resolve();
} else {
......@@ -112,7 +111,7 @@ export class InstallService {
let backupPath = path.join((<AppLocal>app.local).path, "backup");
await this.createDirectory(backupPath);
for (let file of files) {
await new Promise((resolve, reject)=> {
await new Promise((resolve, reject) => {
let oldPath = path.join((<AppLocal>app.local).path, file);
let newPath = path.join(backupPath, file);
fs.rename(oldPath, newPath, resolve);
......@@ -126,7 +125,7 @@ export class InstallService {
checksumUrl = this.checksumUri + app.id + "-" + process.platform;
}
let checksumMap: Map<string,string> = await this.http.get(checksumUrl)
.map((response)=> {
.map((response) => {
let map = new Map<string,string>();
for (let line of response.text().split('\n')) {
if (line !== "") {
......@@ -142,7 +141,7 @@ export class InstallService {
async doInstall() {
for (let app of this.installQueue.keys()) {
let depInstalled = app.findDependencies()
.every((dependency)=>dependency.isInstalled());
.every((dependency) => dependency.isInstalled());
if (depInstalled && !this.installingQueue.has(app)) {
this.installingQueue.add(app);
let options = <InstallConfig>this.installQueue.get(app);
......@@ -194,15 +193,15 @@ export class InstallService {
}
deleteFile(file: string): Promise<string> {
return new Promise((resolve, reject)=> {
fs.lstat(file, (err, stats)=> {
return new Promise((resolve, reject) => {
fs.lstat(file, (err, stats) => {
if (err) return resolve(path);
if (stats.isDirectory()) {
fs.rmdir(file, (err)=> {
fs.rmdir(file, (err) => {
resolve(file);
});
} else {
fs.unlink(file, (err)=> {
fs.unlink(file, (err) => {
resolve(file);
});
}
......@@ -229,7 +228,7 @@ export class InstallService {
await this.deleteFile(oldFile);
if (app.parent) {
let backFile = path.join((<AppLocal>app.local).path, "backup", file);
await new Promise((resolve, reject)=> {
await new Promise((resolve, reject) => {
fs.rename(backFile, oldFile, resolve);
});
}
......
......@@ -14,7 +14,7 @@
flex-shrink: 0;
}
#apps{
#apps {
/*background-color: darkslategray;*/
width: 280px;
flex-shrink: 0;
......
......@@ -3,21 +3,21 @@
*/
import {Component, OnInit, ElementRef, ViewChild} from "@angular/core";
import {AppsService} from "./apps.service";
import {LoginService, User} from "./login.service";
import {LoginService} from "./login.service";
import {App, Category} from "./app";
import {DownloadService} from "./download.service";
import {InstallService} from "./install.service";
import {Http, URLSearchParams} from "@angular/http";
import * as path from 'path';
import * as path from "path";
import {InstallConfig} from "./install-config";
import {AppLocal} from "./app-local";
import {UrlResolver} from "@angular/compiler";
import WebViewElement = Electron.WebViewElement;
@Component({
moduleId: module.id,
selector: 'lobby',
templateUrl: 'app/lobby.component.html',
styleUrls: ['app/lobby.component.css'],
templateUrl: 'lobby.component.html',
styleUrls: ['lobby.component.css'],
})
export class LobbyComponent implements OnInit {
......
......@@ -8,9 +8,10 @@ import * as querystring from "querystring";
import * as url from "url";
@Component({
moduleId: module.id,
selector: 'login',
templateUrl: 'app/login.component.html',
styleUrls: ['app/login.component.css'],
templateUrl: 'login.component.html',
styleUrls: ['login.component.css'],
})
export class LoginComponent {
url;
......
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {getTranslationProviders} from "./i18n-providers";
import {MyCard} from "./mycard.module";
//enableProdMode();
platformBrowserDynamic().bootstrapModule(MyCard);
getTranslationProviders().then(providers => {
const options = {providers};
platformBrowserDynamic().bootstrapModule(MyCard, options);
});
......@@ -10,17 +10,17 @@
</li>
-->
<li *ngIf="loginService.logged_in" [ngClass]="{active: currentPage === 'lobby'}" class="nav-item">
<a (click)="currentPage='lobby'" class="nav-link" href="#">{{'library'| translate}}<span class="sr-only">(current)</span></a>
<a i18n (click)="currentPage='lobby'" class="nav-link" href="#">游戏</a>
</li>
<li *ngIf="loginService.logged_in" [ngClass]="{active: currentPage === 'community'}" class="nav-item">
<a (click)="currentPage='community'" class="nav-link" href="#">{{'community'| translate}}</a>
<a i18n (click)="currentPage='community'" class="nav-link" href="#">社区</a>
</li>
</ul>
<div class="navbar-right">
<div id="user" *ngIf="loginService.logged_in">
<a href="#" class="profile"><img id="avatar" [src]="loginService.user.avatar_url" alt="image"></a>
<a href="#" class="profile item" id="username">{{loginService.user.username}}</a>
<a href="#" (click)="loginService.logout()" class="item">切换账号</a>
<a i18n href="#" (click)="loginService.logout()" class="item">切换账号</a>
</div>
<div id="window-buttons" *ngIf="platform != 'darwin'">
<i (click)="currentWindow.minimize()" class="fa fa-minus"></i>
......@@ -33,5 +33,4 @@
<login class="page" *ngIf="!loginService.logged_in"></login>
<store class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'store'"></store>
<lobby class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'lobby'"></lobby>
<webview class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'community'"
src="https://ygobbs.com"></webview>
\ No newline at end of file
<webview class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'community'" src="https://ygobbs.com"></webview>
\ No newline at end of file
import {Component, Renderer, ChangeDetectorRef, OnInit} from "@angular/core";
import {TranslateService} from "ng2-translate";
import {ipcRenderer, remote} from "electron";
import {remote} from "electron";
import {LoginService} from "./login.service";
const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater');
@Component({
moduleId: module.id,
selector: 'mycard',
templateUrl: 'app/mycard.component.html',
styleUrls: ['app/mycard.component.css'],
templateUrl: 'mycard.component.html',
styleUrls: ['mycard.component.css'],
})
......@@ -23,17 +23,11 @@ export class MyCardComponent implements OnInit {
}
constructor(private renderer: Renderer, private translate: TranslateService, private loginService: LoginService, private ref: ChangeDetectorRef) {
renderer.listenGlobal('window', 'message', (event) => {
console.log(event);
// Do something with 'event'
});
// this language will be used as a fallback when a translation isn't found in the current language
translate.setDefaultLang('en-US');
// the lang to use, if the lang isn't available, it will use the current loader to get them
translate.use(remote.app.getLocale());
constructor(private renderer: Renderer, private loginService: LoginService, private ref: ChangeDetectorRef) {
// renderer.listenGlobal('window', 'message', (event) => {
// console.log(event);
// // Do something with 'event'
// });
this.currentWindow.on('maximize', () => ref.detectChanges());
this.currentWindow.on('unmaximize', () => ref.detectChanges());
......
......@@ -11,14 +11,13 @@ import {RosterComponent} from "./roster.component";
import {CommunityComponent} from "./community.component";
import {YGOProComponent} from "./ygopro.component";
import {AppsService} from "./apps.service";
import {TranslateModule} from "ng2-translate";
import {SettingsService} from "./settings.sevices";
import {LoginService} from "./login.service";
import {DownloadService} from "./download.service";
import {InstallService} from "./install.service";
@NgModule({
imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule, TranslateModule.forRoot()],
imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule],
declarations: [
MyCardComponent, LoginComponent, StoreComponent, LobbyComponent,
CommunityComponent, AppDetailComponent, RosterComponent, YGOProComponent,
......
......@@ -3,9 +3,10 @@
*/
import {Component} from "@angular/core";
@Component({
moduleId: module.id,
selector: 'roster',
templateUrl: 'app/roster.component.html',
styleUrls: ['app/roster.component.css'],
templateUrl: 'roster.component.html',
styleUrls: ['roster.component.css'],
})
export class RosterComponent {
}
/**
* Created by weijian on 2016/10/24.
*/
import {Injectable} from "@angular/core";
import {remote} from "electron";
import * as path from "path";
......
......@@ -3,9 +3,10 @@
*/
import {Component} from "@angular/core";
@Component({
moduleId: module.id,
selector: 'store',
templateUrl: 'app/store.component.html',
styleUrls: ['app/store.component.css'],
templateUrl: 'store.component.html',
styleUrls: ['store.component.css'],
})
export class StoreComponent {
}
......@@ -67,9 +67,10 @@ interface Room {
}
@Component({
moduleId: module.id,
selector: 'ygopro',
templateUrl: 'app/ygopro.component.html',
styleUrls: ['app/ygopro.component.css'],
templateUrl: 'ygopro.component.html',
styleUrls: ['ygopro.component.css'],
})
export class YGOProComponent implements OnInit {
@Input()
......
{
"library": "游戏",
"community": "社区",
"settings": "设置",
"cancel": "取消",
"install": "安装",
"uninstall": "卸载",
"mods":"附加模块",
"general": "常规",
"updates": "更新",
"local files": "本地文件",
"uninstall confirm": "这将删除所有本地内容,确认执行?",
"browse": "浏览",
"install_path": "安装路径",
"shortcut": "快捷方式",
"create_shortcut": "创建应用程序快捷方式",
"create_desktop_shortcut": "创建桌面快捷方式",
"additions": "附加内容"
}
......@@ -19,6 +19,7 @@
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
document.locale = require('electron').remote.app.getLocale();
System.import('app')
</script>
</head>
......
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="zh-CN" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="a8cae935472a05e1c8c9be436bb7b1bdea96a54a" datatype="html">
<source>安装</source>
<target>Install</target>
</trans-unit>
<trans-unit id="e6194d8a9c8da57b667847cd80f1da563f2c2b1e" datatype="html">
<source>导入</source>
<target>Import</target>
</trans-unit>
<trans-unit id="2fe99d94b20d6f8aba7814d8657037ec9d69d36c" datatype="html">
<source>正在安装...</source>
<target>Installing...</target>
</trans-unit>
<trans-unit id="e5ee7e692c816893b6fd2f9375e6d8303cd794cd" datatype="html">
<source>等待安装...</source>
<target>Pending...</target>
</trans-unit>
<trans-unit id="d3852e0147360b29d0d6076e95dd1ad0098a60db" datatype="html">
<source>运行</source>
<target>Start</target>
</trans-unit>
<trans-unit id="67adbad4f646bb8e1c440522bafea8fe5f7e6bfd" datatype="html">
<source>设置</source>
<target>Custom</target>
</trans-unit>
<trans-unit id="3d6cad40e26f99e39bc6f5925a890ba83b67ce5b" datatype="html">
<source>联机</source>
<target>Networking</target>
</trans-unit>
<trans-unit id="5eadb60473a54773298ee679a4ce6a19d9c2f31c" datatype="html">
<source>复制</source>
<target>Copy</target>
</trans-unit>
<trans-unit id="95d5e106e679433bec012420b1ab9334c294bc7e" datatype="html">
<source>选择服务器</source>
<target>server</target>
</trans-unit>
<trans-unit id="63346eb53d54138db02c1713ae58f73bb1b8786f" datatype="html">
<source>新闻</source>
<target>News</target>
</trans-unit>
<trans-unit id="b1c134df688af90e436e49f6d3e9f6960f9497c6" datatype="html">
<source>了解更多</source>
<target>More Info</target>
</trans-unit>
<trans-unit id="3ebbe3f1c691ec3184ac8c7a5f360706501e6b50" datatype="html">
<source>名称</source>
<target>Name</target>
</trans-unit>
<trans-unit id="d58ff4f339ad18d82b08fb0615ba8c1cf373a4a2" datatype="html">
<source>操作</source>
<target>Action</target>
</trans-unit>
<trans-unit id="e090f6d9d8129a7b8b92387f05f37eb4b44c0b4e" datatype="html">
<source>卸载</source>
<target>Uninstall</target>
</trans-unit>
<trans-unit id="8d0792a89fc399aafb40cc1228cb8c04a2056883" datatype="html">
<source>本地文件</source>
<target>Local Files</target>
</trans-unit>
<trans-unit id="628c76783ac32e6c8b2ea9134397b8cb82a82cd6" datatype="html">
<source>浏览本地文件</source>
<target>Browse</target>
</trans-unit>
<trans-unit id="6d582ed48c57c91fc7cf10f36f3869cd33808d1d" datatype="html">
<source>校验完整性</source>
<target>Verify integrity</target>
</trans-unit>
<trans-unit id="4809edca33b1a07d7d6e8905287d3825e676f2c8" datatype="html">
<source>安装 <x id="INTERPOLATION"/></source>
<target>Install <x id="INTERPOLATION"/></target>
</trans-unit>
<trans-unit id="f8e60167c7a0871ccf40ed2a0750311411dfd665" datatype="html">
<source>即将开始安装 <x id="INTERPOLATION"/></source>
<target>Preparing Install <x id="INTERPOLATION"/></target>
</trans-unit>
<trans-unit id="63a6c9b023e9e9f8ddfba70b0e24931008fa2510" datatype="html">
<source>安装位置</source>
<target>Path</target>
</trans-unit>
<trans-unit id="0b96c54bf810c6deb2c32253bf16b86d3c90da94" datatype="html">
<source>快捷方式</source>
<target>Shortcuts</target>
</trans-unit>
<trans-unit id="8aa0a41ee6809b972d3904d96607ba5e6dc48fd9" datatype="html">
<source>创建 LaunchPad 快捷方式</source>
<target>Create Launchpad Shortcut</target>
</trans-unit>
<trans-unit id="da32e99069864644f0419f67858d93815e029b02" datatype="html">
<source>创建开始菜单快捷方式</source>
<target>Create Start Menu Shortcut</target>
</trans-unit>
<trans-unit id="d8a2d9a9f8854ad118381e6e30a41dc1959a4f0b" datatype="html">
<source>创建桌面快捷方式</source>
<target>Create Desktop Shortcut</target>
</trans-unit>
<trans-unit id="2ba33dd61b1ac70666322680f248e5336b3ee69a" datatype="html">
<source>依赖:</source>
<target>Dependencies</target>
</trans-unit>
</body>
</file>
</xliff>
......@@ -12,7 +12,8 @@
"start": "tsc && electron .",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w"
"tsc:w": "tsc -w",
"i18n": "ng-xi18n"
},
"license": "UNLICENSED",
"dependencies": {
......@@ -27,30 +28,26 @@
"@angular/router-deprecated": "latest",
"@angular/upgrade": "latest",
"angular2-in-memory-web-api": "latest",
"aria2": "latest",
"bootstrap": "next",
"core-js": "latest",
"rxjs": "5.0.0-beta.12",
"systemjs": "latest",
"zone.js": "^0.6.21",
"electron-auto-updater": "latest",
"electron-cookies": "latest",
"electron-sudo": "mycard/electron-sudo#mycard",
"bootstrap": "next",
"tether": "latest",
"font-awesome": "latest",
"aria2": "latest",
"ini": "latest",
"mkdirp": "latest",
"ng2-translate": "latest",
"raw-socket": "latest",
"reflect-metadata": "latest",
"regenerator-runtime": "latest",
"rxjs": "5.0.0-beta.12",
"systemjs": "latest",
"tether": "latest",
"zone.js": "latest"
"raw-socket": "latest"
},
"devDependencies": {
"concurrently": "latest",
"@angular/compiler-cli": "latest",
"@angular/platform-server": "latest",
"electron": "latest",
"electron-builder": "latest",
"electron-rebuild": "latest",
"lite-server": "latest",
"typescript": "latest",
"typings": "latest"
},
......
/*
SystemJS Text plugin from
https://github.com/systemjs/plugin-text/blob/master/text.js
*/
exports.translate = function(load) {
if (this.builder && this.transpiler) {
load.metadata.format = 'esm';
return 'exp' + 'ort var __useDefault = true; exp' + 'ort default ' + JSON.stringify(load.source) + ';';
}
load.metadata.format = 'amd';
return 'def' + 'ine(function() {\nreturn ' + JSON.stringify(load.source) + ';\n});';
}
......@@ -5,6 +5,7 @@
// map tells the System loader where to look for things
var map = {
'app': 'app', // 'dist',
'text': 'systemjs-text-plugin.js',
'@angular': 'node_modules/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment