views:

34

answers:

1

I'm using $lang = $_GET['lang']; and some arrays to change the language of the page. So my pages URL look like this when I select a language: ...index.php?lang=en (so my index page never changes neither my jquery files)

(more details in my previous post)

I'm using jQuery validate plugin to validate my form and a custom.js:

$(document).ready(function(){

    $("#sendmail").validate({
        rules: {
            FieldData0: {
                required: true
            },
            FieldData1: {
                required: true,
                email: true
            },
            FieldData2: {
                required: true
            }
        },
        messages: {
            FieldData0: {
                required: "Please enter your name"
            },
            FieldData1: {
                required: "Please enter your email address"
            },
            FieldData2: {
                required: "Please enter a message"
            }
        }
    });
})

How can I show different requirement warning for different languages in this case? Do I have to make a custom.js for every language and then use php if else statements, is the a better way?

+2  A: 

I would do this: Make a custom-en.js (and one for each language) then have something like the following for in the custom-en.js:

var messList = {
     mess1 : "This is message 1";
     ...
     reqMess1 : "Please enter your name";
}

then in your non-changing file you would have lines that look like this:

    messages: {
        FieldData0: {
            required: messList.reqMess1;
        },
Hogan