0

i have use the following string as value of the button

"Drag a column header here to group its column" with culture as en-US

how to change this string based on the different language settings/ culture .Is there any other way to achieve this by using Globalize.format to convert

1
  • You can user jquery i18n. I think there is a lots of library available in the net. You can use anyone or you can make your own in javascript. Commented Feb 24, 2014 at 5:24

1 Answer 1

0

You could set the localized instructions in an object like so:

var instructions = {
  "en" : "Drag a column header here to group its column",
  "fr" : "Faites glisser un en-tête de colonne ici pour groupe sa colonne",
  "cn" : "这里将一个列标题,集团将其列"
}

And assuming your button has an id of "#example_button", you could have a jQuery function like this :

function set_button_instruction_value(text) {
  $("#example_button").prop('value', text);
}

So if you saved your localization to a variable, such as "locale":

var locale = "en";

You can call this to change the value of the button:

set_button_instruction_value(instructions[locale]);

I don't think Globalize.format can directly determine how to set the button text unless you wanted to set a locale based on the way a date is displayed.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi ,thank you for your answer . is it possible to use resx files to localize the string in javascript
is it possible to localize the string in javascript using toLocaleString() method
I'm not familiar with resx, but this question is similar to what you're asking for. The first answer is also similar to mine: stackoverflow.com/questions/104022/…
Also, toLocaleString() appears to also be a method for converting dates. It seems to me that you're confusing converting instruction strings with date strings. For example, Globalize.format and toLocaleString() methods are used with dates only, as far as I can tell. I can't think off the top of my head any JavaScript libraries that can parse and convert different languages, but I'm sure they exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.