views:

374

answers:

1

I am using jquery code to handle language translation, I have in my previous posts, gotten the code to handle most text and ajax translations.

And this code even works 100% in firefox, but when testing on google chrome 5.0.365.2 Dev

            $("input:button,input:submit").each(function() {
            var value = $(this).val();
            // check if there is value
            if (value != undefined) {
                for (var x = 0; x < en_count; x++) {
                    var from = en_lang[x];
                    var to = toCache[x];
                    // if node has data translated skip it
                    var ist = $(this).data('translated');
                    if (ist != 'yes') {
                        if (value.match(from)) {
                            value = to;
                            $(this).attr('value',to);
                        }
                    }
                }
            }
        });

Before this code, I create 2 array's 1 for english and 1 for an other language.

en_lng contains the array for english text on this page. toCache contains the array for the other language, that i am translating to.

To help make sure not to translate a piece of text more than once, I am using the data property, and storing the value of 'translated'.

So in the end, this code is just for translating input button/submit text.

Thank You....

A: 

I've just made a test in Firefox and it seems the if there is no value for an input it returns an empty string, not undefined. Thus it will always work in Firefox (I can't test Chrome at the moment.)

Try alerting the value of value before the if statement.

Jeremy
I did, and it did seem to be passing the a valid value. I think there may be a google chrome dom problem with the method used to replace text....But i have been googling all morning to find a reference/wiki on google chrome dom.
crosenblum
Do you know how far Chrome steps into your code?
Jeremy