turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

Not working with Russian language #266

Closed marspd closed 8 years ago

marspd commented 8 years ago

HI Guys I've used your excellent code and have my site working with multiple languages (English, French, German and Spanish). However, I also want to work with Russian but for some reason the language will not work.

When the language is chosen from the menu I run the following code on my MVC site

` public ActionResult SetLanguage(string langtag, string returnUrl) { // If valid 'langtag' passed. i18n.LanguageTag lt = i18n.LanguageTag.GetCachedInstance(langtag); if (lt.CultureInfo != null) { // Set persistent cookie in the client to remember the language choice. Response.Cookies.Add(new HttpCookie("i18n.langtag") { Value = lt.ToString(), HttpOnly = true, Expires = DateTime.UtcNow.AddYears(1) }); } // Otherwise...delete any 'language' cookie in the client. else { var cookie = Response.Cookies["i18n.langtag"]; if (cookie != null) { cookie.Value = null; cookie.Expires = DateTime.UtcNow.AddMonths(-1); } } // Update PAL setting so that new language is reflected in any URL patched in the // response (Late URL Localization). i18n.HttpContextExtensions.SetPrincipalAppLanguageForRequest(HttpContext, lt);

       `

I've checked the context and the language 'ru' is placed in element 0 or the items array. However, on the next request I check for the language with the following code

var language = this.HttpContext.GetPrincipalAppLanguageForRequest().GetLanguage();

and this works fine for all the languages other than Russian.

If I look in the context items array 'i18n.UserLanguages' element 0 has been replaced with 'en' for English.

I've checked that the cookie is being saved and the correct cookie language value is being passed on the request.

Any ideas what the issue might be please?

Regards Paul

turquoiseowl commented 8 years ago

I haven't heard of there being anything special with ru.

A couple of things to try before delving too far:

  1. Ensure the browser cache is not causing odd things to happen. E.g. clear cookie cache and get the browser to completely 'forget' about the site. (E.g. on FF, right-click the entry for you site in the History pane and select 'Forget About this Site'.)
  2. Try adopting the language files from a non-default language that does work e.g. copy locale/fr to locale/ru
marspd commented 8 years ago

Hi Martin Thanks for the very quick response and the fix. It was indeed a problem with my language files and is now fixed.