-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(i18n): support i18n functionality (zh-CN, en-US currently)
close #427
- Loading branch information
1 parent
3e007a2
commit 552fa50
Showing
47 changed files
with
811 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { NzLocaleModule } from './nz-locale.module'; | ||
export { NZ_LOCALE } from './nz-locale.token'; | ||
export { NzLocaleService } from './nz-locale.service'; | ||
export * from './locales'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { NzLocale } from '../nz-locale.class'; | ||
import * as moment from 'moment'; | ||
|
||
const LOCALE = 'en-US'; | ||
|
||
moment.locale(LOCALE); | ||
|
||
export const enUS: NzLocale = { | ||
locale: LOCALE, | ||
|
||
Pagination: { | ||
itemsPerPage: '%num% / page', | ||
jumpTo: 'Goto', | ||
page: '', | ||
forwardPage: '%num% pages forward', | ||
backwardPage: '%num% pages backward', | ||
prevPage: 'Previous page', | ||
nextPage: 'Next page', | ||
firstPage: 'First page', | ||
lastPage: 'Last page: %page%', | ||
totalItems: '%total% items', | ||
}, | ||
|
||
DateTime: { | ||
clear: 'Clear', | ||
chooseMonth: 'Choose a month', | ||
chooseYear: 'Choose a year', | ||
chooseDecade: 'Choose a decade', | ||
nYear: '%num%', | ||
nMonth: '%num%', | ||
nDay: '%num%', | ||
prevYear: 'Previous year', | ||
nextYear: 'Next year', | ||
prevMonth: 'Previous month', | ||
nextMonth: 'Next month', | ||
prevDecade: 'Previous decade', | ||
nextDecade: 'Next decade', | ||
chooseTime: 'Select time', | ||
chooseDate: 'Select date', | ||
chooseTimePlease: 'Select time', | ||
chooseDatePlease: 'Select date', | ||
thisMoment: 'This moment', | ||
today: 'Today', | ||
ok: 'Ok', | ||
}, | ||
|
||
Modal: { | ||
okText: 'OK', | ||
cancelText: 'Cancel', | ||
understood: 'Got it', | ||
}, | ||
|
||
Table: { | ||
emptyText: 'No data', | ||
}, | ||
|
||
Select: { | ||
notFoundContent: 'Not Found', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './zh-CN'; | ||
export * from './en-US'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { NzLocale } from '../nz-locale.class'; | ||
import * as moment from 'moment'; | ||
|
||
const LOCALE = 'zh-CN'; | ||
|
||
moment.locale(LOCALE); | ||
|
||
export const zhCN: NzLocale = { | ||
locale: LOCALE, | ||
|
||
Pagination: { | ||
itemsPerPage: '%num% 条/页', | ||
jumpTo: '跳至', | ||
page: '页', | ||
forwardPage: '向前 %num% 页', | ||
backwardPage: '向后 %num% 页', | ||
prevPage: '上一页', | ||
nextPage: '下一页', | ||
firstPage: '第一页', | ||
lastPage: '最后一页: %page%', | ||
totalItems: '共 %total% 条', | ||
}, | ||
|
||
DateTime: { | ||
clear: '清除', | ||
chooseMonth: '选择月份', | ||
chooseYear: '选择年份', | ||
nYear: '%num%年', | ||
nMonth: '%num%月', | ||
nDay: '%num%日', | ||
prevYear: '上一年', | ||
nextYear: '下一年', | ||
prevMonth: '上个月', | ||
nextMonth: '下个月', | ||
prevDecade: '上一年代', | ||
nextDecade: '下一年代', | ||
chooseDecade: '选择年代', | ||
chooseTime: '选择时间', | ||
chooseDate: '选择日期', | ||
chooseTimePlease: '请选择时间', | ||
chooseDatePlease: '请选择日期', | ||
thisMoment: '此刻', | ||
today: '今天', | ||
ok: '确 定', | ||
}, | ||
|
||
Modal: { | ||
okText: '确定', | ||
cancelText: '取消', | ||
understood: '知道了', | ||
}, | ||
|
||
Table: { | ||
emptyText: '没有数据', | ||
}, | ||
|
||
Select: { | ||
notFoundContent: '无法找到', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
export class NzLocale { | ||
locale: string; // Present of this locale's lang code | ||
|
||
Pagination: { | ||
itemsPerPage: string; | ||
jumpTo: string; | ||
page: string; | ||
forwardPage: string; | ||
backwardPage: string; | ||
prevPage: string; | ||
nextPage: string; | ||
firstPage: string; | ||
lastPage: string; | ||
totalItems: string; | ||
}; | ||
|
||
DateTime: { | ||
clear: string; | ||
chooseMonth: string; | ||
chooseYear: string; | ||
nYear: string; | ||
nMonth: string; | ||
nDay: string; | ||
prevYear: string; | ||
nextYear: string; | ||
prevMonth: string; | ||
nextMonth: string; | ||
prevDecade: string; | ||
nextDecade: string; | ||
chooseDecade: string; | ||
chooseTime: string; | ||
chooseDate: string; | ||
chooseTimePlease: string; | ||
chooseDatePlease: string; | ||
thisMoment: string; | ||
today: string; | ||
ok: string; | ||
}; | ||
|
||
Modal: { | ||
okText: string; | ||
cancelText: string; | ||
understood: string; | ||
}; | ||
|
||
Table: { | ||
emptyText: string; | ||
}; | ||
|
||
Select: { | ||
notFoundContent: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { LoggerModule } from '../util/logger'; | ||
|
||
import { NZ_LOCALE } from './nz-locale.token'; | ||
import { zhCN } from './locales'; | ||
import { NZ_LOCALE_SERVICE_PROVIDER } from './nz-locale.service'; | ||
import { NzTranslatePipe } from './nz-translate.pipe'; | ||
|
||
@NgModule({ | ||
imports: [ LoggerModule ], | ||
declarations: [ NzTranslatePipe ], | ||
exports: [ NzTranslatePipe ], | ||
providers: [ | ||
{ provide: NZ_LOCALE, useValue: zhCN }, | ||
NZ_LOCALE_SERVICE_PROVIDER, | ||
], | ||
}) | ||
export class NzLocaleModule { } |
Oops, something went wrong.