Skip to content

Commit

Permalink
feat(Locale): add language zh-hk
Browse files Browse the repository at this point in the history
* feat(Locale): Add zh-hk language support
Co-authored-by: aboutblank <[email protected]>
  • Loading branch information
haoxutong authored Mar 4, 2020
1 parent 1cd026e commit 3101978
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/config-provider/index.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Now support four languages: Simplified Chinese, Traditional Chinese, English and
import { ConfigProvider, DatePicker } from '@alifd/next';
import enUS from '@alifd/next/lib/locale/en-us';
// import zhCN from '@alifd/next/lib/locale/zh-cn';
// import zhHK from '@alifd/next/lib/locale/zh-hk';
// import zhTW from '@alifd/next/lib/locale/zh-tw';
// import jaJP from '@alifd/next/lib/locale/ja-jp';

Expand Down
1 change: 1 addition & 0 deletions docs/config-provider/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class App extends React.Component {
import { ConfigProvider, DatePicker } from '@alifd/next';
import enUS from '@alifd/next/lib/locale/en-us';
// import zhCN from '@alifd/next/lib/locale/zh-cn';
// import zhHK from '@alifd/next/lib/locale/zh-hk';
// import zhTW from '@alifd/next/lib/locale/zh-tw';
// import jaJP from '@alifd/next/lib/locale/ja-jp';

Expand Down
1 change: 1 addition & 0 deletions index-with-locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ next.locales = {};
next.locales['en-us'] = require('./lib/locale/en-us.js');
next.locales['ja-ja'] = require('./lib/locale/ja-jp.js');
next.locales['zh-cn'] = require('./lib/locale/zh-cn.js');
next.locales['zh-hk'] = require('./lib/locale/zh-hk.js');
next.locales['zh-tw'] = require('./lib/locale/zh-tw.js');

module.exports = next;
2 changes: 1 addition & 1 deletion scripts/build/export-api-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default ${exportName};
});

// generate d.ts for locale
['zh-cn', 'en-us', 'ja-jp', 'zh-tw'].forEach(file => {
['zh-cn', 'en-us', 'ja-jp', 'zh-hk', 'zh-tw'].forEach(file => {
const localePath = path.join(cwd, 'lib', 'locale', `${file}.d.ts`);
fs.writeFileSync(
localePath,
Expand Down
1 change: 1 addition & 0 deletions scripts/init-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const options = {
'lib/en-us.js',
'lib/ja-jp.js',
'lib/zh-cn.js',
'lib/zh-hk.js',
'lib/zh-tw.js',
],
},
Expand Down
1 change: 1 addition & 0 deletions site/en-us/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Currently support Simplified Chinese, Traditional Chinese, English and Japanese:
import { ConfigProvider, DatePicker } from '@alifd/next';
import enUS from '@alifd/next/lib/locale/en-us';
// import zhCN from '@alifd/next/lib/locale/zh-cn';
// import zhHK from '@alifd/next/lib/locale/zh-hk';
// import zhTW from '@alifd/next/lib/locale/zh-tw';
// import jaJP from '@alifd/next/lib/locale/ja-jp';

Expand Down
2 changes: 2 additions & 0 deletions site/zh-cn/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| 语言名称 | 文件名 |
| -------- | -------- |
| 简体中文 | zh-cn |
| 繁体中文(香港) | zh-hk |
| 繁体中文 | zh-tw |
| 美式英语 | en-us |
| 日文 | ja-jp |
Expand Down Expand Up @@ -83,6 +84,7 @@ class App extends React.Component {
import { ConfigProvider, DatePicker } from '@alifd/next';
import enUS from '@alifd/next/lib/locale/en-us';
// import zhCN from '@alifd/next/lib/locale/zh-cn';
// import zhHK from '@alifd/next/lib/locale/zh-hk';
// import zhTW from '@alifd/next/lib/locale/zh-tw';
// import jaJP from '@alifd/next/lib/locale/ja-jp';

Expand Down
138 changes: 138 additions & 0 deletions src/locale/zh-hk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
export default {
momentLocale: 'zh-hk',
Timeline: {
expand: '展開',
fold: '收起',
},
Balloon: {
close: '關閉',
},
Card: {
expand: '展開',
fold: '收起',
},
Calendar: {
today: '今天',
now: '此刻',
ok: '確定',
clear: '清除',
month: '月',
year: '年',
prevYear: '上一年',
nextYear: '下一年',
prevMonth: '上個月',
nextMonth: '下個月',
prevDecade: '上十年',
nextDecade: '後十年',
yearSelectAriaLabel: '選擇年份',
monthSelectAriaLabel: '選擇月份',
},
DatePicker: {
placeholder: '請選擇日期',
datetimePlaceholder: '請選擇日期和時間',
monthPlaceholder: '請選擇月',
yearPlaceholder: '請選擇年',
weekPlaceholder: '請選擇周',
now: '此刻',
selectTime: '選擇時間',
selectDate: '選擇日期',
ok: '確定',
clear: '清除',
startPlaceholder: '起始日期',
endPlaceholder: '結束日期',
hour: '時',
minute: '分',
second: '秒',
},
Dialog: {
close: '關閉',
ok: '確認',
cancel: '取消',
},
Drawer: {
close: '關閉',
},
Message: {
closeAriaLabel: '關閉',
},
Pagination: {
prev: '上一頁',
next: '下一頁',
goTo: '到第',
page: '頁',
go: '確定',
total: '第{current}頁,共{total}頁',
labelPrev: '上一頁,當前第{current}頁',
labelNext: '下一頁,當前第{current}頁',
inputAriaLabel: '請輸入跳轉到第幾頁',
selectAriaLabel: '請選擇每頁顯示幾條',
pageSize: '每頁顯示:',
},
Input: {
clear: '清除',
},
Select: {
selectPlaceholder: '請選擇',
autoCompletePlaceholder: '請輸入',
notFoundContent: '無選項',
maxTagPlaceholder: '已選擇 {selected}/{total} 項',
selectAll: '全選',
},
Table: {
empty: '沒有數據',
ok: '確認',
reset: '重置',
asc: '升序',
desc: '降序',
expanded: '已展開',
folded: '已摺疊',
filter: '篩選',
selectAll: '全選',
},
TimePicker: {
placeholder: '請選擇時間',
clear: '清除',
hour: '時',
minute: '分',
second: '秒',
},
Transfer: {
items: '項',
item: '項',
moveAll: '移動全部',
searchPlaceholder: '請輸入',
moveToLeft: '撤銷選中元素',
moveToRight: '提交選中元素',
},
Upload: {
card: {
cancel: '取消',
addPhoto: '上傳圖片',
download: '下載',
delete: '刪除',
},
drag: {
text: '點擊或者拖動文件到虛線框內上傳',
hint: '支持 docx, xls, PDF, rar, zip, PNG, JPG 等類型的文件',
},
upload: {
delete: '刪除',
},
},
Search: {
buttonText: '檢索',
},
Tag: {
delete: '删除',
},
Rating: {
description: '評分選項',
},
Switch: {
on: '已打開',
off: '已關閉',
},
Tab: {
closeAriaLabel: '關閉',
},
};
4 changes: 3 additions & 1 deletion test/locale/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import assert from 'power-assert';
import US from '../../src/locale/en-us';
import JP from '../../src/locale/ja-jp';
import CN from '../../src/locale/zh-cn';
import HK from '../../src/locale/zh-hk';
import TW from '../../src/locale/zh-tw';

describe('Locale', () => {
it('should be the same keys', () => {
const usKeys = getKeys(US);
const jpKeys = getKeys(JP);
const cnKeys = getKeys(CN);
const hkKeys = getKeys(HK);
const twKeys = getKeys(TW);

assert(usKeys === jpKeys && jpKeys === cnKeys && cnKeys === twKeys);
assert(usKeys === jpKeys && jpKeys === cnKeys && cnKeys === hkKeys && hkKeys === twKeys);
});
});

Expand Down
1 change: 1 addition & 0 deletions types/locale/zh-hk.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './default';

0 comments on commit 3101978

Please sign in to comment.