Support » Plugins » implementation of localized error messages using the jQuery validation plugin

  • Resolved Will Brubaker

    (@willthewebmechanic)


    Automattic Happiness Engineer

    Howdy all!

    tl;dr: Any pointers on enqueuing language files related to the jQuery validation plugin in noconflict mode?

    localization files here

    I’m pretty fond of the jQuery validation plugin and use it often in projects. I have a plugin here in the public repo that uses it. I got a support request from a user recently that needed Dutch language error messages so I dug in to try to figure how to include that. The translated messages files are available BUT the challenge is that these files aren’t noconflict mode compatible (i.e. they use the global $ shortcut). I did a quick and dirty search/replace to get this particular user sorted out, but I’m wondering if anybody has any pointers on how to include these files.

    Lacking your own good ideas, perhaps dynamically creating a file based on $language = $_SERVER['HTTP_ACCEPT_LANGUAGE'] and then do something like file_get_contents( 'messages_' . $language . '.js' ) and wrap the result of that up in a noconflict wrapper. Thoughts on that approach?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Will Brubaker

    (@willthewebmechanic)

    Automattic Happiness Engineer

    sorry mods – should have been in the ‘hacks’ subforum 🙁

    Will Brubaker

    (@willthewebmechanic)

    Automattic Happiness Engineer

    resolved by

    1. Check if WPLANG is defined, if so, grab the first two characters of whatever WPLANG is set to.
    2. dynamically create a script with jQuery noconclict wrapper and then echo out the contents of the appropriate language file

    For a rough example, see the Awesome Surveys plugin v1.3

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘implementation of localized error messages using the jQuery validation plugin’ is closed to new replies.