v2
This commit is contained in:
+116
@@ -0,0 +1,116 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "ಅಕ್ಷರಗಳು", verb: "ಹೊಂದಲು" },
|
||||
file: { unit: "ಬೈಟ್ಗಳು", verb: "ಹೊಂದಲು" },
|
||||
array: { unit: "ವಸ್ತುಗಳು", verb: "ಹೊಂದಲು" },
|
||||
set: { unit: "ವಸ್ತುಗಳು", verb: "ಹೊಂದಲು" },
|
||||
map: { unit: "entries", verb: "ಹೊಂದಲು" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "ಇನ್ಪುಟ್",
|
||||
email: "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 ವಿಳಾಸ",
|
||||
mac: "MAC ವಿಳಾಸ",
|
||||
cidrv4: "IPv4 ವ್ಯಾಪ್ತಿಯ",
|
||||
cidrv6: "IPv6 ವ್ಯಾಪ್ತಿಯ",
|
||||
base64: "base64-encodedಸ್ಟ್ರಿಂಗ್",
|
||||
base64url: "base64url-encodedಸ್ಟ್ರಿಂಗ್",
|
||||
json_string: "JSONಸ್ಟ್ರಿಂಗ್",
|
||||
e164: "E.164 ಸಂಖ್ಯೆ",
|
||||
credit_card: "ಕ್ರೆಡಿಟ್ ಕಾರ್ಡ್ ಸಂಖ್ಯೆ",
|
||||
currency_code: "ಕರೆನ್ಸಿ ಕೋಡ್",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "ಇನ್ಪುಟ್",
|
||||
};
|
||||
// type names: missing keys = do not translate (use raw value via ?? fallback)
|
||||
const TypeDictionary = {
|
||||
// Compatibility: "nan" -> "NaN" for display
|
||||
nan: "NaN",
|
||||
// All other type names omitted - they fall back to raw values via ?? operator
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
return `ಅಮಾನ್ಯ ಇನ್ಪುಟ್: ನಿರೀಕ್ಷಿಸಲಾಗಿದೆ ${expected}, ಸ್ವೀಕರಿಸಿದನು ${received}`;
|
||||
}
|
||||
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 ?? "value"} ಹೊಂದಲು ${adj}${issue.maximum.toString()} ${sizing.unit ?? "ಅಂಶಗಳು"}`;
|
||||
return `ತುಂಬಾ ದೊಡ್ಡದು: ನಿರೀಕ್ಷಿಸಲಾಗಿದೆ ${issue.origin ?? "value"} ಎಂದು ${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;
|
||||
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 `ಅಮಾನ್ಯ ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `ಅಮಾನ್ಯ ಸಂಖ್ಯೆ: ಬಹುಸಂಖ್ಯೆಯಾಗಿರಬೇಕು ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `ಗುರುತಿಸಲಾಗದ ಕೀ ${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `ಅಮಾನ್ಯವಾದ ಕೀ ಇನ್ ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `ಅಮಾನ್ಯ ತಾರತಮ್ಯ ಮೌಲ್ಯ. ನಿರೀಕ್ಷಿಸಲಾಗಿದೆ ${opts}`;
|
||||
}
|
||||
return "ಅಮಾನ್ಯ ಇನ್ಪುಟ್";
|
||||
case "invalid_element":
|
||||
return `ರಲ್ಲಿ ಅಮಾನ್ಯ ಮೌಲ್ಯ ${issue.origin}`;
|
||||
default:
|
||||
return `ಅಮಾನ್ಯ ಇನ್ಪುಟ್`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user