localization
Get localized month name using native JS
You are already close: var getMonth = function(idx) { var objDate = new Date(); objDate.setDate(1); objDate.setMonth(idx-1); var locale = “en-us”, month = objDate.toLocaleString(locale, { month: “long” }); return month; } console.log(getMonth(1)); console.log(getMonth(12));
Programmatic way to get all the available languages (in satellite assemblies)
You can programatically list the cultures available in your application // Pass the class name of your resources as a parameter e.g. MyResources for MyResources.resx ResourceManager rm = new ResourceManager(typeof(MyResources)); CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); foreach (CultureInfo culture in cultures) { try { ResourceSet rs = rm.GetResourceSet(culture, true, false); // or ResourceSet rs = rm.GetResourceSet(new CultureInfo(culture.TwoLetterISOLanguageName), … Read more
Multi-line strings in objective-c localized strings file
Just use the new lines directly. “email” = “Hello %@, Check out %@. Sincerely, %@”;
How to break lines in .yml localization files on rails?
This works for me: en: hello: “Hello world” bye: | Bye! See you! error: > Something happend. Try later. Usage: irb(main):001:0> I18n.t ‘bye’ => “Bye!\nSee you!\n” irb(main):002:0> I18n.t ‘error’ => “Something happend. Try later.\n”
Alternatives to gettext?
First of all I think gettext is one of the best at this point. You may take a look on Boost.Locale that may provide a better API and use gettext‘s dictionary model: http://cppcms.sourceforge.net/boost_locale/docs/ (not official part of Boost, still beta). Edit: If you don’t like gettext… These are translation technologies: OASIS XLIFF GNU gettext po/mo … Read more
Django: Display current locale in a template
I solved this by including code below in the template {% load i18n %} {% get_current_language as LANGUAGE_CODE %} and the variable LANGUAGE_CODE has the value you want (see also django docs for an example usage).
How can I determine a user’s locale within the browser?
The proper way is to look at the HTTP Accept-Language header sent to the server. This contains the ordered, weighted list of languages the user has configured their browser to prefer. Unfortunately this header is not available for reading inside JavaScript; all you get is navigator.language, which tells you what localised version of the web … Read more