aiji42 / zod-i18n

Useful for translating zod error messages.
https://zod-i18n.vercel.app
MIT License
623 stars 70 forks source link

List TODO comments for each language #34

Open aiji42 opened 1 year ago

aiji42 commented 1 year ago

Some languages have data that is not fully translated in some parts, which is marked with a TODO comment. By making a list and making it easy to check, we make it possible for the language user to easily notice and contribute to the translation.

lSelectral commented 1 year ago

@aiji42 Hello,

Would it be useful to create issues for each language that isn't complete with a template like below?


ZOD-I18N

English

aiji42 commented 1 year ago

It may indeed be useful. However, there are some situations that cannot be expressed by true/false. For example, when an update is made that allows for a detailed processing message by giving an option value, and that has not yet been addressed.

It would be nice to have this kind of expression, but it would probably be difficult on the markdown. Perhaps a dedicated documentation site is needed.

[ ]
[-] (with memo)
[x]
lSelectral commented 1 year ago

@aiji42 Hello, Come to think again, you are right. Managing by readme is really tiresome and doomed to be obsolete quickly.

I found a way to compare all files with english translation and find missing. Then we can write this missing fields to readme, documentation or where ever you want.

Result looks like this: ( This is real comparision between ENGLISH and SPANISH translation )

COMPARE RESULT OBJECT ```ts { "errors": { "too_small": { "array": { "exact": { "before": "Array must contain exactly {{minimum}} element(s)" } }, "string": { "exact": { "before": "String must contain exactly {{minimum}} character(s)" } }, "number": { "exact": { "before": "Number must be exactly {{minimum}}" } }, "date": { "exact": { "before": "Date must be exactly {{- minimum, datetime}}" } } }, "too_big": { "array": { "exact": { "before": "Array must contain exactly {{maximum}} element(s)" } }, "string": { "exact": { "before": "String must contain exactly {{maximum}} character(s)" } }, "number": { "exact": { "before": "Number must be exactly {{maximum}}" } }, "date": { "exact": { "before": "Date must be exactly {{- maximum, datetime}}" } } } } } ```

CODE TO COMPARE ```ts function compareObjects(obj1: any, obj2: any): any { const diff: any = {}; for (const key in obj1) { if (Object.prototype.hasOwnProperty.call(obj1, key)) { if (!(key in obj2)) { diff[key] = { before: obj1[key], after: undefined }; } else if (obj1[key] instanceof Object) { const nestedDiff = compareObjects(obj1[key], obj2[key]); if (Object.keys(nestedDiff).length > 0) { diff[key] = nestedDiff; } } } } return diff; } ```