1

I'm trying to use jquery-localize for localization of my small app. My wish is to use Danish language if the user is Danish, and English otherwise.

I tried doing nothing, but if an unknown language uses the app, then all strings are empty.

My current solution is this

chosenLanguage = window.navigator.userLanguage || window.navigator.language;
langSearch = new RegExp('^da', 'i');
if (chosenLanguage.match(langSearch)){
  // Do nothing
}
else {
  $("[data-localize]").localize("local", { language: "en" });
}

But this solution seems too complex to be correct. Any help or suggestions is appreciated!

2
  • What do you mean by jquery-localize? Commented Jan 20, 2013 at 16:24
  • @jukka-k-korpela Sorry... I forgot the link link Commented Jan 20, 2013 at 17:07

1 Answer 1

1

The jquery-localize library appears to be rather pritimive string customization tool, without even an idea of a fallback to a generic locale. Your current solution, too, is too simple rather than too complex. It relies on “browser language”, which need not have anything to do with the user’s language preferences. Instead, design and implement language switching. The usual way is to make the English version primary and provide some links or buttons for changing to other language(s).

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

2 Comments

Any tips on libraries or best practices?
@angak, in the simple scenario, you would have the page initially in English (you could do that using the localize function) and it would contain a button that calls the localize function to translate into Danish.

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.