Coder Social home page Coder Social logo

Allow type translations about ajv-i18n HOT 8 OPEN

ajv-validator avatar ajv-validator commented on June 19, 2024 3
Allow type translations

from ajv-i18n.

Comments (8)

epoberezkin avatar epoberezkin commented on June 19, 2024 1

Makes sense for type names. So it would require a map of type names for each language (and by default english will be used, if the map is not provided).

from ajv-i18n.

epoberezkin avatar epoberezkin commented on June 19, 2024 1

What do you mean by "and more"?

from ajv-i18n.

epoberezkin avatar epoberezkin commented on June 19, 2024 1

That's definitely more complex, it has to be somehow passed via ajv. Maybe ajv-errors can be extended to support i18n.

from ajv-i18n.

epoberezkin avatar epoberezkin commented on June 19, 2024

@siavashkavousi can you please clarify.

from ajv-i18n.

siavashkavousi avatar siavashkavousi commented on June 19, 2024

if we have the following message in en and my locale (fa)
en: should be {{=e.params.type}}
fa: 'فیلد باید {{=e.params.type}} باشد'

then I got
فیلد باید number باشد
like in english
should be number

as you can see number can be localized as well :)

from ajv-i18n.

siavashkavousi avatar siavashkavousi commented on June 19, 2024

I didn't quite integrate it in my application, but one more thing which I think can be localized is property names.
I mean by passing title instead of property name, messages looks better (in my application) which I think is not general.

from ajv-i18n.

adefrutoscasado avatar adefrutoscasado commented on June 19, 2024

Same problem here, is there any workaround? Being able to pass a translate function would be nice

from ajv-i18n.

FedeTommi avatar FedeTommi commented on June 19, 2024

I have the same problem too.

I had a look at the jtd.js and index.js and it seems like the problem is solved for the languages fi, nb, nl and pl.
Here a proposal for the languages German and Italian:

de: '{{#def.t}}muss {{? t == "number" }}eine Zahl{{?? t == "integer"}}eine ganze Zahl{{?? t == "string"}}ein Text{{?? t == "boolean"}} boolescher Wert{{??}}{{=t}}{{?}}{{=n}} sein',

it: '{{#def.t}}deve essere {{? t == "number" }}un numero{{?? t == "integer"}}un numero intero{{?? t == "string"}}un testo{{?? t == "boolean"}} booleano{{??}}{{=t}}{{?}}{{=n}}',

Would it be possible to add these?

from ajv-i18n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.