Skip to content

Commit

Permalink
feat: add Chinese(zh-TW) language support
Browse files Browse the repository at this point in the history
* feat: add Chinese(traditional) language support

* feat: add zh-TW to example page

* feat: fix option typo

* feat: add example files
  • Loading branch information
kane50613 authored Feb 27, 2023
1 parent d68dbfb commit 4523b03
Show file tree
Hide file tree
Showing 7 changed files with 424 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ z.setErrorMap(zodI18nMap({
- [Portuguese(pt)](https://github.com/aiji42/zod-i18n/blob/main/packages/core/locales/pt/zod.json)
- [Turkish(tr)](https://github.com/aiji42/zod-i18n/blob/main/packages/core/locales/tr/zod.json)
- [Chinese Simplified Chinese(zh-CN)](https://github.com/aiji42/zod-i18n/blob/main/packages/core/locales/zh-CN/zod.json)
- [Chinese Traditional Chinese(zh-TW)](https://github.com/aiji42/zod-i18n/blob/main/packages/core/locales/zh-TW/zod.json)

It is also possible to create and edit translation files. You can use [this English translation file](https://github.com/aiji42/zod-i18n/blob/main/packages/core/locales/en/zod.json) as a basis for rewriting it in your language.

Expand Down
1 change: 1 addition & 0 deletions examples/with-next-i18next/next-i18next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
"ar",
"pt",
"zh-CN",
"zh-TW",
"is",
"es",
"nl",
Expand Down
1 change: 1 addition & 0 deletions examples/with-next-i18next/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default function HookForm() {
<option value="pl">polski</option>
<option value="tr">Türkçe</option>
<option value="zh-CN">简体中文</option>
<option value="zh-TW">繁體中文</option>
</Select>
</InputGroup>
</Flex>
Expand Down
9 changes: 9 additions & 0 deletions examples/with-next-i18next/public/locales/zh-TW/common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"username": "使用者名稱",
"username_placeholder": "小明",
"email": "電子郵件",
"favoriteNumber": "喜歡的數字",
"submit": "送出"
}


104 changes: 104 additions & 0 deletions examples/with-next-i18next/public/locales/zh-TW/zod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"errors": {
"invalid_type": "期望輸入的是{{expected}},而輸入的是{{received}}",
"invalid_type_received_undefined": "必填的欄位",
"invalid_literal": "無效的輸入,請輸入 {{expected}}",
"unrecognized_keys": "無法識別物件的鍵值:{{- keys}}",
"invalid_union": "輸入格式錯誤",
"invalid_union_discriminator": "無效的識別符,請輸入 {{- options}}",
"invalid_enum_value": "無效的 '{{received}}' 值,請輸入 {{- options}}",
"invalid_arguments": "參數錯誤",
"invalid_return_type": "錯誤的回傳值類型",
"invalid_date": "錯誤的日期",
"custom": "格式錯誤",
"invalid_intersection_types": "交集類型無法合併",
"not_multiple_of": "必須是 {{multipleOf}} 的倍數",
"not_finite": "不能為無限值",
"invalid_string": {
"email": "{{validation}}格式錯誤",
"url": "{{validation}}格式錯誤",
"uuid": "{{validation}} 格式錯誤",
"cuid": "{{validation}} 格式錯誤",
"regex": "格式錯誤",
"datetime": "{{validation}} 格式錯誤",
"startsWith": "必須以 \"{{startsWith}}\" 開始",
"endsWith": "必須以 \"{{endsWith}}\" 結尾"
},
"too_small": {
"array": {
"inclusive": "至少需要包含 {{minimum}} 個元素",
"not_inclusive": "必須包含多於 {{minimum}} 個元素"
},
"string": {
"inclusive": "至少需要包含 {{minimum}} 個字元",
"not_inclusive": "必須包含多於 {{minimum}} 個字元"
},
"number": {
"inclusive": "必須大於或等於 {{minimum}}",
"not_inclusive": "必須大於 {{minimum}}"
},
"set": {
"exact": "無效的輸入",
"inclusive": "無效的輸入",
"not_inclusive": "無效的輸入"
},
"date": {
"inclusive": "日期必須晚於或等於 {{- minimum, datetime}}",
"not_inclusive": "日期必須晚於 {{- minimum, datetime}}"
}
},
"too_big": {
"array": {
"inclusive": "最多只能包含 {{maximum}} 個元素",
"not_inclusive": "必須少於 {{maximum}} 個元素"
},
"string": {
"inclusive": "最多只能包含 {{maximum}} 個字元",
"not_inclusive": "必須少於 {{maximum}} 個字元"
},
"number": {
"inclusive": "必須小於或等於 {{maximum}}",
"not_inclusive": "必須小於 {{maximum}}"
},
"set": {
"exact": "無效的輸入",
"inclusive": "無效的輸入",
"not_inclusive": "無效的輸入"
},
"date": {
"inclusive": "日期必須早於或等於 {{- maximum, datetime}}",
"not_inclusive": "日期必須早於 {{- maximum, datetime}}"
}
}
},
"validations": {
"email": "電子郵件",
"url": "連結",
"uuid": "uuid",
"cuid": "cuid",
"regex": "正則表達式",
"datetime": "datetime"
},
"types": {
"function": "函數",
"number": "數字",
"string": "字串",
"nan": "NaN",
"integer": "整數",
"float": "浮點數",
"boolean": "布林值",
"date": "日期",
"bigint": "Bigint",
"undefined": "未定義",
"symbol": "Symbol",
"null": "null",
"array": "陣列",
"object": "物件",
"unknown": "unknown",
"promise": "Promise",
"void": "void",
"never": "never",
"map": "Map",
"set": "Set"
}
}
104 changes: 104 additions & 0 deletions packages/core/locales/zh-TW/zod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"errors": {
"invalid_type": "期望輸入的是{{expected}},而輸入的是{{received}}",
"invalid_type_received_undefined": "必填的欄位",
"invalid_literal": "無效的輸入,請輸入 {{expected}}",
"unrecognized_keys": "無法識別物件的鍵值:{{- keys}}",
"invalid_union": "輸入格式錯誤",
"invalid_union_discriminator": "無效的識別符,請輸入 {{- options}}",
"invalid_enum_value": "無效的 '{{received}}' 值,請輸入 {{- options}}",
"invalid_arguments": "參數錯誤",
"invalid_return_type": "錯誤的回傳值類型",
"invalid_date": "錯誤的日期",
"custom": "格式錯誤",
"invalid_intersection_types": "交集類型無法合併",
"not_multiple_of": "必須是 {{multipleOf}} 的倍數",
"not_finite": "不能為無限值",
"invalid_string": {
"email": "{{validation}}格式錯誤",
"url": "{{validation}}格式錯誤",
"uuid": "{{validation}} 格式錯誤",
"cuid": "{{validation}} 格式錯誤",
"regex": "格式錯誤",
"datetime": "{{validation}} 格式錯誤",
"startsWith": "必須以 \"{{startsWith}}\" 開始",
"endsWith": "必須以 \"{{endsWith}}\" 結尾"
},
"too_small": {
"array": {
"inclusive": "至少需要包含 {{minimum}} 個元素",
"not_inclusive": "必須包含多於 {{minimum}} 個元素"
},
"string": {
"inclusive": "至少需要包含 {{minimum}} 個字元",
"not_inclusive": "必須包含多於 {{minimum}} 個字元"
},
"number": {
"inclusive": "必須大於或等於 {{minimum}}",
"not_inclusive": "必須大於 {{minimum}}"
},
"set": {
"exact": "無效的輸入",
"inclusive": "無效的輸入",
"not_inclusive": "無效的輸入"
},
"date": {
"inclusive": "日期必須晚於或等於 {{- minimum, datetime}}",
"not_inclusive": "日期必須晚於 {{- minimum, datetime}}"
}
},
"too_big": {
"array": {
"inclusive": "最多只能包含 {{maximum}} 個元素",
"not_inclusive": "必須少於 {{maximum}} 個元素"
},
"string": {
"inclusive": "最多只能包含 {{maximum}} 個字元",
"not_inclusive": "必須少於 {{maximum}} 個字元"
},
"number": {
"inclusive": "必須小於或等於 {{maximum}}",
"not_inclusive": "必須小於 {{maximum}}"
},
"set": {
"exact": "無效的輸入",
"inclusive": "無效的輸入",
"not_inclusive": "無效的輸入"
},
"date": {
"inclusive": "日期必須早於或等於 {{- maximum, datetime}}",
"not_inclusive": "日期必須早於 {{- maximum, datetime}}"
}
}
},
"validations": {
"email": "電子郵件",
"url": "連結",
"uuid": "uuid",
"cuid": "cuid",
"regex": "正則表達式",
"datetime": "datetime"
},
"types": {
"function": "函數",
"number": "數字",
"string": "字串",
"nan": "NaN",
"integer": "整數",
"float": "浮點數",
"boolean": "布林值",
"date": "日期",
"bigint": "Bigint",
"undefined": "未定義",
"symbol": "Symbol",
"null": "null",
"array": "陣列",
"object": "物件",
"unknown": "unknown",
"promise": "Promise",
"void": "void",
"never": "never",
"map": "Map",
"set": "Set"
}
}
Loading

1 comment on commit 4523b03

@vercel
Copy link

@vercel vercel bot commented on 4523b03 Feb 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

zod-i18n – ./

zod-i18n-git-main-aiji42.vercel.app
zod-i18n-aiji42.vercel.app
zod-i18n.vercel.app

Please sign in to comment.