Skip to content

Commit 7bf6888

Browse files
committed
i18n complete.
1 parent f5b08bd commit 7bf6888

9 files changed

Lines changed: 45 additions & 35 deletions

File tree

src/app/home/components/book-list.component.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,25 @@
5151
<ion-icon name="compass-outline"></ion-icon>README
5252
</button>
5353
<button class="action-button" mat-button *ngIf="book.downloaded" (click)="openBook(book)">
54-
<ion-icon name="book-outline"></ion-icon>{{'home.bookList.read' | translate}}
54+
<ion-icon name="book-outline"></ion-icon>{{'home.bookList.actions.read' | translate}}
5555
</button>
5656
<button class="action-button" id="{{ 'download-book-' + book.id }}" mat-button
5757
*ngIf="!book.downloaded" (click)="startDownload(book)">
58-
<ion-icon name="cloud-download-outline"></ion-icon>{{'home.bookList.download' | translate}}
58+
<ion-icon name="cloud-download-outline"></ion-icon>{{'home.bookList.actions.download' | translate}}
5959
</button>
6060
<button class="action-button"
61+
matTooltip="{{'home.bookList.tooltip.remove' | translate}}"
6162
id="{{ 'delete-book-' + book.id }}" mat-button (click)="openDeleteBookDialog(book)"
6263
*ngIf="!book.downloaded || !book.recycled"
6364
[disabled]="book.recycled">
64-
<ion-icon name="close-outline" sizme="small"></ion-icon>{{'home.bookList.remove' | translate}}
65+
<ion-icon name="close-outline" sizme="small"></ion-icon>{{'home.bookList.actions.remove' | translate}}
6566
</button>
66-
<button class="action-button" mat-button *ngIf="book.recycled" (click)="openDeleteBookDialog(book)">
67-
<ion-icon name="cog-outline" sizme="small"></ion-icon>{{'home.bookList.operation' | translate}}
67+
<button class="action-button"
68+
matTooltip="{{'home.bookList.tooltip.operation' | translate}}"
69+
mat-button
70+
*ngIf="book.recycled"
71+
(click)="openDeleteBookDialog(book)">
72+
<ion-icon name="cog-outline" sizme="small"></ion-icon>{{'home.bookList.actions.operation' | translate}}
6873
</button>
6974
</mat-card-actions>
7075

src/app/home/components/book-list.component.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ mat-card:hover {
1515
background-color: #4f4f4f;
1616
}
1717

18-
.action-button {
19-
visibility: hidden;
20-
}
21-
22-
mat-card-actions:hover .action-button{
23-
visibility: visible;
24-
}
25-
2618
.cate-chip:hover {
2719
cursor: pointer;
2820
}

src/app/home/components/reading-record-dialog.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class ReadingRecordDialog implements OnInit{
6767
}
6868

6969
readableDate = (date: Date) => {
70-
return getReadableDate(date);
70+
return getReadableDate(date, this.i18n.browserLang);
7171
}
7272

7373
moveTo = (path: string, sectionAnchor?: string) => {

src/app/home/components/search.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ export class SearchComponent implements OnInit {
4545
}
4646

4747
readableDate = (date: Date) => {
48-
return getReadableDate(parseISO(date.toString()));
48+
return getReadableDate(parseISO(date.toString()), this.i18n.browserLang);
4949
}
5050
}

src/app/home/home.page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,6 @@ export class HomePage implements OnInit, AfterViewInit {
371371
}
372372

373373
readableDate = (date: Date) => {
374-
return getReadableDate(date);
374+
return getReadableDate(date, this.i18n.browserLang);
375375
}
376376
}

src/app/i18n/i18n.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export class I18nService {
1313
) {
1414
translate.addLangs(this.languages);
1515
translate.setDefaultLang('en');
16-
//translate.use(this.browserLang.match(/zh|en/) ? this.browserLang : 'en');
17-
translate.use('en')
16+
translate.use(this.browserLang.match(/zh|en/) ? this.browserLang : 'en');
17+
//translate.use('en');
1818
}
1919

2020
get browserLang () {

src/app/vendor.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class MatPaginatorIntlHans extends MatPaginatorIntl {
4545
};
4646
}
4747

48-
export const getReadableDate = (date: Date): string => {
48+
export const getReadableDate = (date: Date, locale: string): string => {
4949
const now = new Date();
5050
const years = differenceInYears(now, date);
5151
const months = differenceInMonths(now, date);
@@ -54,12 +54,13 @@ export const getReadableDate = (date: Date): string => {
5454
const hours = differenceInHours(now, date);
5555
const minutes = differenceInMinutes(now, date);
5656

57-
if(years > 0) return `${years} 年前`;
58-
if(months > 0) return `${months} 个月前`;
59-
if(weeks > 0) return `${weeks} 周前`;
60-
if(days > 0) return `${days} 天前`;
61-
if(hours > 0) return `${hours} 小时前`;
62-
return `${minutes} 分钟前`;
57+
const isHans: boolean = /zh/.test(locale);
58+
if(years > 0) return `${years} ${isHans ? '年前' : 'years ago'}`;
59+
if(months > 0) return `${months} ${isHans ? '个月前' : 'months ago'}`;
60+
if(weeks > 0) return `${weeks} ${isHans ? '周前' : 'weeks ago'}`;
61+
if(days > 0) return `${days} ${isHans ? '天前' : 'days ago'}`;
62+
if(hours > 0) return `${hours} ${isHans ? '小时前': 'hours ago'}`;
63+
return `${minutes} ${isHans ? '分钟前' : 'minutes ago'}`;
6364
}
6465

6566
export interface ISearchHistory {

src/assets/i18n/en.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,17 @@
4646
"readTimes": "Readings",
4747
"modify": "Modify",
4848
"readingRecord": "Reading Record",
49-
"read": "Read",
50-
"download": "Download",
51-
"remove": "Remove",
52-
"operation": "Operation",
53-
"cloneErrorMsg": " - Error occured during downloading, Please remove it"
49+
"actions": {
50+
"read": "Read",
51+
"download": "Download",
52+
"remove": "Remove",
53+
"operation": "Operation"
54+
},
55+
"cloneErrorMsg": " - Error occured during downloading, Please remove it",
56+
"tooltip": {
57+
"remove": "Recycle/Remove this book",
58+
"operation": "Put this book back on shelf, or remove it"
59+
}
5460
},
5561
"deleteBook": {
5662
"remove": "Delete - ",

src/assets/i18n/zh.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,17 @@
4646
"readTimes": "次阅读",
4747
"modify": "修改",
4848
"readingRecord": "阅读记录",
49-
"read": "阅读",
50-
"download": "下载",
51-
"remove": "删除",
52-
"operation": "操作",
53-
"cloneErrorMsg": " - 无法下载,建议删除"
49+
"actions": {
50+
"read": "阅读",
51+
"download": "下载",
52+
"remove": "删除",
53+
"operation": "操作"
54+
},
55+
"cloneErrorMsg": " - 无法下载,建议删除",
56+
"tooltip": {
57+
"remove": "将本书移入回收站/删除",
58+
"operation": "将本书重新放回书架/彻底删除"
59+
}
5460
},
5561
"deleteBook": {
5662
"remove": "删除 - ",

0 commit comments

Comments
 (0)