Skip to content

Commit

Permalink
feat(trasnlate): [skip travis] translate few words
Browse files Browse the repository at this point in the history
  • Loading branch information
pengkobe committed Dec 20, 2018
1 parent 436f795 commit d5c4ee6
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ionic4-boilerplate",
"version": "0.1.0",
"version": "0.2.0",
"author": "pengkobe",
"homepage": "http://github.com/pengkobe/ionic4-boilerplate",
"scripts": {
Expand Down
10 changes: 4 additions & 6 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,28 @@
>
<ion-menu>
<ion-header>
<ion-toolbar> <ion-title>菜单</ion-title> </ion-toolbar>
<ion-toolbar> <ion-title> {{ 'HOME.Menu' | translate }} </ion-title> </ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-list-header> 功能点 </ion-list-header>

<ion-menu-toggle auto-hide="false">
<ion-item button (click)="navigate('/tabs')">
<ion-icon slot="start" name="home"></ion-icon>
<ion-label> 首页 </ion-label>
<ion-label> {{ 'HOME.Home' | translate }} </ion-label>
</ion-item>
</ion-menu-toggle>

<ion-menu-toggle auto-hide="false">
<ion-item button (click)="navigate('/tabs/(list:list)')">
<ion-icon slot="start" name="information-circle"></ion-icon>
<ion-label> 列表 </ion-label>
<ion-label> {{ 'HOME.List' | translate }} </ion-label>
</ion-item>
</ion-menu-toggle>

<ion-menu-toggle auto-hide="false">
<ion-item button (click)="navigate('/tabs/(test:test)')">
<ion-icon slot="start" name="hammer"></ion-icon>
<ion-label> 测试 </ion-label>
<ion-label> {{ 'HOME.Test' | translate }} </ion-label>
</ion-item>
</ion-menu-toggle>
</ion-list>
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</ion-toolbar>
</ion-header>
<ion-content padding>
<h3 class="home-title">Ionic Boilerplate</h3>
<h3 class="home-title">Ionic4 Boilerplate</h3>

<p>create by <a href="https://yipeng.info/">pengkobe</a> .</p>
<ion-menu-button secondary>{{ 'HOME.Toggle' | translate }}</ion-menu-button>

<ion-button secondary (click)="testCache()" [appTrackEventDirective]
[trackParams]="{ evtName:'点击获取随机数',parames: {cahceData:cacheData}}">点击获取随机数</ion-button>
[trackParams]="{ evtName:'GetRandomNumber',parames: {cahceData:cacheData}}"> {{ 'HOME.GetRandomNumber' | translate }} </ion-button>
<span> {{ cacheData }}</span>
</ion-content>
2 changes: 1 addition & 1 deletion src/app/pages/list/calendar/calendar.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ion-buttons slot="start">
<ion-back-button text="" defaultHref="list"></ion-back-button>
</ion-buttons>
<ion-title>Calendar 演示</ion-title>
<ion-title> {{ 'HOME.Calendar' | translate }} </ion-title>
</ion-toolbar>
</ion-header>

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/list/echarts/echarts.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ion-buttons slot="start">
<ion-back-button text="" defaultHref="list"></ion-back-button>
</ion-buttons>
<ion-title>Echarts 演示</ion-title>
<ion-title>Echarts</ion-title>
</ion-toolbar>
</ion-header>

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/list/ngrxtodo/ngrxtodo.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ion-toolbar>
<ion-buttons slot="start">
<ion-button (click)="backTolist()" >
<ion-icon slot="start" name="arrow-back"></ion-icon> 返回
<ion-icon slot="start" name="arrow-back"></ion-icon>
</ion-button>
</ion-buttons>
<ion-title>TODO</ion-title>
Expand Down
8 changes: 4 additions & 4 deletions src/app/pages/test/test.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<ion-row>
<ion-col col-12>
<ion-item>
<ion-icon name="musical-notes" item-start color="primary"></ion-icon>
<ion-icon name="keypad" item-start color="primary"></ion-icon>
<ion-label>{{ 'HOME.SwitchLanguage' | translate }}</ion-label>
<ion-select
[(ngModel)]="languageType"
Expand All @@ -44,9 +44,9 @@
okText="{{ 'HOME.confirm' | translate }}"
>
<ion-select-option value="zh" selected="true"
>{{ 'HOME.LanguageCH' | translate }}</ion-select-option
>中文</ion-select-option
>
<ion-select-option value="en">{{ 'HOME.LanguageEN' | translate }}</ion-select-option>
<ion-select-option value="en"> English </ion-select-option>
</ion-select>
</ion-item>
</ion-col>
Expand All @@ -55,7 +55,7 @@
<ion-row>
<ion-col col-12>
<ion-item>
<ion-icon name="bulb" item-start color="primary"></ion-icon>
<ion-icon name="moon" item-start color="primary"></ion-icon>
<ion-label>{{ 'HOME.Theme' | translate }}</ion-label>
<ion-toggle
(ionChange)="toggleAppTheme()"
Expand Down
15 changes: 10 additions & 5 deletions src/app/pages/test/test.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GlobalService } from '@services/global.service';
import { EmitService } from '@services/emit.service';
import { AppCenterAnalytics } from '@ionic-native/app-center-analytics/ngx';
import { QRScannerModal } from '@modals/qr-scanner/qr-scanner';
import { TranslateService } from '@ngx-translate/core';
declare var window;

@Component({
Expand Down Expand Up @@ -62,17 +63,18 @@ export class TestPage {
public globalservice: GlobalService,
public modalCtrl: ModalController,
public emit: EmitService,
private appCenterAnalytics: AppCenterAnalytics
private appCenterAnalytics: AppCenterAnalytics,
public translate: TranslateService
) {
this.emit.getActiveTheme().subscribe(val => this.selectedTheme = val);
}

ionViewDidLoad() {
console.log('ionViewDidLoad TestPage');
this.translate.get(this.globalservice.languageType).subscribe((res: string) => {
this.languageType = res ? res : 'zh';
});

this.languageType = this.globalservice.languageType
? this.globalservice.languageType
: 'zh';

if (window.cordova) {
window.cordova.getAppVersion.getVersionNumber().then(version => {
Expand All @@ -81,6 +83,7 @@ export class TestPage {
}
}


async open(format: boolean = false) {
const modal = await this.modalCtrl.create({
component: QRScannerModal,
Expand Down Expand Up @@ -131,8 +134,10 @@ export class TestPage {

setLanguageType(val) {
this.globalservice.languageType = val;
this.translate.get(val).subscribe((res: string) => {
this.languageType = res ? res : 'zh';
});
this.emit.eventEmit.emit('languageType');

this.appCenterAnalytics.setEnabled(true).then(() => {
this.appCenterAnalytics.trackEvent('setLanguageType', { languageType: val }).then(() => {
console.log('setLanguageType event tracked');
Expand Down
4 changes: 3 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"LanguageEN":"English",
"Theme":"Theme",
"Cancel":"Cancel",
"confirm":"OK"
"confirm":"OK",
"GetRandomNumber":"Get Random Number",
"Calendar":"Calendar"
}
}
4 changes: 3 additions & 1 deletion src/assets/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"LanguageEN":"英文",
"Theme":"皮肤切换",
"Cancel":"取消",
"confirm":"确定"
"confirm":"确定",
"GetRandomNumber":"点击获取随机数",
"Calendar":"日历"
}
}

0 comments on commit d5c4ee6

Please sign in to comment.