-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(lang): Added initial Tamil locale
#4237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import az from "./locales/az.js"; | ||
| import en from "./locales/en.js"; | ||
| import es from "./locales/es.js"; | ||
| import ta from "./locales/ta.js"; | ||
|
|
||
| export { az, es, en }; | ||
| export { az, es, en, ta }; | ||
This file contains hidden or 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,125 @@ | ||
| import type { $ZodStringFormats } from "../checks.js"; | ||
| import type * as errors from "../errors.js"; | ||
| import * as util from "../util.js"; | ||
|
|
||
| const Sizable: Record<string, { unit: string; verb: string }> = { | ||
| string: { unit: "எழுத்துக்கள்", verb: "கொண்டிருக்க வேண்டும்" }, | ||
| file: { unit: "பைட்டுகள்", verb: "கொண்டிருக்க வேண்டும்" }, | ||
| array: { unit: "உறுப்புகள்", verb: "கொண்டிருக்க வேண்டும்" }, | ||
| set: { unit: "உறுப்புகள்", verb: "கொண்டிருக்க வேண்டும்" }, | ||
| }; | ||
|
|
||
| function getSizing(origin: string): { unit: string; verb: string } | null { | ||
| return Sizable[origin] ?? null; | ||
| } | ||
|
|
||
| export const parsedType = (data: any): string => { | ||
| const t = typeof data; | ||
|
|
||
| switch (t) { | ||
| case "number": { | ||
| return Number.isNaN(data) ? "எண் அல்லாதது" : "எண்"; | ||
| } | ||
| case "object": { | ||
| if (Array.isArray(data)) { | ||
| return "அணி"; | ||
| } | ||
| if (data === null) { | ||
| return "வெறுமை"; | ||
| } | ||
|
|
||
| if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) { | ||
| return data.constructor.name; | ||
| } | ||
| } | ||
| } | ||
| return t; | ||
| }; | ||
|
|
||
| const Nouns: { | ||
| [k in $ZodStringFormats | (string & {})]?: string; | ||
| } = { | ||
| regex: "உள்ளீடு", | ||
| email: "மின்னஞ்சல் முகவரி", | ||
| url: "URL", | ||
| emoji: "emoji", | ||
| uuid: "UUID", | ||
| uuidv4: "UUIDv4", | ||
| uuidv6: "UUIDv6", | ||
| nanoid: "nanoid", | ||
| guid: "GUID", | ||
| cuid: "cuid", | ||
| cuid2: "cuid2", | ||
| ulid: "ULID", | ||
| xid: "XID", | ||
| ksuid: "KSUID", | ||
| datetime: "ISO தேதி நேரம்", | ||
| date: "ISO தேதி", | ||
| time: "ISO நேரம்", | ||
| duration: "ISO கால அளவு", | ||
| ipv4: "IPv4 முகவரி", | ||
| ipv6: "IPv6 முகவரி", | ||
| cidrv4: "IPv4 வரம்பு", | ||
| cidrv6: "IPv6 வரம்பு", | ||
| base64: "base64-encoded சரம்", | ||
| base64url: "base64url-encoded சரம்", | ||
| json_string: "JSON சரம்", | ||
| e164: "E.164 எண்", | ||
| jwt: "JWT", | ||
| template_literal: "input", | ||
| }; | ||
|
|
||
| const error: errors.$ZodErrorMap = (issue) => { | ||
| switch (issue.code) { | ||
| case "invalid_type": | ||
| return `தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${issue.expected}, பெறப்பட்டது ${parsedType(issue.input)}`; | ||
| case "invalid_value": | ||
| if (issue.values.length === 1) return `தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${util.stringifyPrimitive(issue.values[0])}`; | ||
| return `தவறான விருப்பம்: எதிர்பார்க்கப்பட்டது ${util.joinValues(issue.values, "|")} இல் ஒன்று`; | ||
| case "too_big": { | ||
| const adj = issue.inclusive ? "<=" : "<"; | ||
| const sizing = getSizing(issue.origin); | ||
| if (sizing) { | ||
| return `மிக பெரியது: எதிர்பார்க்கப்பட்டது ${issue.origin ?? "மதிப்பு"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "உறுப்புகள்"} ஆக இருக்க வேண்டும்`; | ||
| } | ||
| return `மிக பெரியது: எதிர்பார்க்கப்பட்டது ${issue.origin ?? "மதிப்பு"} ${adj}${issue.maximum.toString()} ஆக இருக்க வேண்டும்`; | ||
| } | ||
| case "too_small": { | ||
| const adj = issue.inclusive ? ">=" : ">"; | ||
| const sizing = getSizing(issue.origin); | ||
| if (sizing) { | ||
| return `மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} ஆக இருக்க வேண்டும்`; // | ||
| } | ||
|
|
||
| return `மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${issue.origin} ${adj}${issue.minimum.toString()} ஆக இருக்க வேண்டும்`; | ||
| } | ||
| case "invalid_format": { | ||
| const _issue = issue as errors.$ZodStringFormatIssues; | ||
| if (_issue.format === "starts_with") return `தவறான சரம்: "${_issue.prefix}" இல் தொடங்க வேண்டும்`; | ||
| if (_issue.format === "ends_with") return `தவறான சரம்: "${_issue.suffix}" இல் முடிவடைய வேண்டும்`; | ||
| if (_issue.format === "includes") return `தவறான சரம்: "${_issue.includes}" ஐ உள்ளடக்க வேண்டும்`; | ||
| if (_issue.format === "regex") return `தவறான சரம்: ${_issue.pattern} முறைபாட்டுடன் பொருந்த வேண்டும்`; | ||
| return `தவறான ${Nouns[_issue.format] ?? issue.format}`; | ||
| } | ||
| case "not_multiple_of": | ||
| return `தவறான எண்: ${issue.divisor} இன் பலமாக இருக்க வேண்டும்`; | ||
| case "unrecognized_keys": | ||
| return `அடையாளம் தெரியாத விசை${issue.keys.length > 1 ? "கள்" : ""}: ${util.joinValues(issue.keys, ", ")}`; | ||
| case "invalid_key": | ||
| return `${issue.origin} இல் தவறான விசை`; | ||
| case "invalid_union": | ||
| return "தவறான உள்ளீடு"; | ||
| case "invalid_element": | ||
| return `${issue.origin} இல் தவறான மதிப்பு`; | ||
| default: | ||
| return `தவறான உள்ளீடு`; | ||
| } | ||
| }; | ||
|
|
||
| export { error }; | ||
|
|
||
| export default function (): { localeError: errors.$ZodErrorMap } { | ||
| return { | ||
| localeError: error, | ||
| }; | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -345,3 +345,4 @@ The following locales are available: | |
|
|
||
| - `az` — Azerbaijani | ||
| - `en` — English | ||
| - `ta` — Tamil | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be probably written as following
This way, upon merging one locale PR, another locale PR doesn't need to resolve conflict on the
exportbefore mering.@colinhacks Please share your thoughts on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would've been smart...I've been resolving these conflicts for an hour now 😅