Giter VIP home page Giter VIP logo

Comments (10)

tipiirai avatar tipiirai commented on June 16, 2024

thanks. how did you end up supplying undefined value on the fist place? do you generate localized strings programmatically?

from jquerytools.

chemerisuk avatar chemerisuk commented on June 16, 2024

Simple test case is:

  1. Create a new validation function WITHOUT message;
  2. Populate message later with localize function.

As for your question I would say yes, validation messages are populated from server strings because of consistency on client and server side.

Also, I would like to say that in general not sure if switching languages on client-side, that validator plugin has now, is necessary functionality.

from jquerytools.

tipiirai avatar tipiirai commented on June 16, 2024

ok. thanks for the scenario. I have now pushed your change to github and will be public on v.1.2.2.

how would you change the language yourself?

from jquerytools.

chemerisuk avatar chemerisuk commented on June 16, 2024

I think it's better strategy to switch languages on server-side and to populate validator by this already localized strings. Such scenario grants consistency of error messages on both (client and server) sides.

You know, I saw client-side localizing of validation messages in another jquery.validate plugin that used before. It uses different implementation, but the idea is the same. And still don't understand if it's a necessary functionality.

from jquerytools.

tipiirai avatar tipiirai commented on June 16, 2024

the problem with populating a different kind of validator for each end user is mostly performance. It would be harder to combine validator with other tools to a single file and do minification and take advantage of the global cache (such as cdn.flowplayer.org).

I understand your point but for now the localization stays on the client side.

thanks!

from jquerytools.

chemerisuk avatar chemerisuk commented on June 16, 2024

I guess it may be misunderstanding here. Default messages for each rule (in english for most cases) always must be inside of js file on client side. But my opinion is that localizing strings is part of server's work.

I don't want to remove existing functionality, just interesting in what is the reason.

from jquerytools.

tipiirai avatar tipiirai commented on June 16, 2024

You can (and should) do the localization on the server side. However the way of doing it is now external to the validator.js by using the $.validator.localize() static method. In my opinnion this is a good way to do it. You can setup the validation in your site-globals.js file which can be generated dynamically depending on the language of the user.

from jquerytools.

chemerisuk avatar chemerisuk commented on June 16, 2024

Ok, now it's clear. The reason is performance and ability to cache error message strings. Thanks for the explanation!

from jquerytools.

tipiirai avatar tipiirai commented on June 16, 2024

and most importantly to cache the actual tools. when being served from cdn.flowplayer.org your end users may already have the right file on their computer.

from jquerytools.

chemerisuk avatar chemerisuk commented on June 16, 2024

yes, you are right.

After a little researching I think that the best solution for the topic is to generate html page with just 'script' tag where to put all localized messages and to setup cache header for it on server. This would be pretty easy and fast, because generating of several language-specific js files before deploying seems like not thsimplest way.

from jquerytools.

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.