MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

UI for user to change locale  (Mono Support )

Viewed 17489 time(s), 17 post(s) 7/18/2014 10:18:52 AMby Zoomicon

Related topics

Zoomicon

Zoomicon

7/18/2014 10:18:54 AM

Just posted this, but it got eaten up???

Posting again:

http://www.codeproject.com/Articles/9701/Changing-web-application-Culture-on-the-fly

Is there any functionality like the above? That is to show UI to the user to override the language picked based on OS/Browser Languages setting, since many users don't know how to change those settings, or are not allowed to (some labs/internet cafes disable the internet options dialog for example)

so the logic would be that your site would check the list of browser languages (HttpRequest.UserLanguages) and pick looking from top (most preferred) to bottom if one of those is supported by the current page and pick it, unless the user has overridden from the UI the language.

This content has not been rated yet. 
2793 Reputation 345 Total posts
khorvat

khorvat

7/18/2014 12:36:15 PM
Hi,

I'm not sure if Language Changer Web Part will do what you need but it will change the current language of the page and MonoX will use the selected language for fetching the content and URL rewriting.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
Zoomicon

Zoomicon

7/18/2014 3:17:51 PM

I have two issues:

1) from what I understand it doesn't try to use HttpRequest.UserLanguages to see if one of the available languages should be selected by default . It would select using that scheme if user hasn't overridden the setting manually using the webpart's UI. It could keep the info that user has selected other language from the UI at either the session or even better somewhere in user profile data. In the second case one could maybe show the selector only at the user profile page (or have separate dropdown-style selector there that persists the same setting) and have the webpart available but invisible in other pages so that user only selects language override from their profile (having option to keep a default setting to try to use the browser/OS preferred languages list)

2) I want some pages like blogs and discussions to show the same (the English stuff) and mainly have the front page and some manual/help pages be localized. If I put ASP.net script inside those webpages to change UICulture to English will the selector read/show that setting or does it keep its current value elsewhere and will turn my setting back again for those pages?

Alternatively would it work OK if I put the selector inside some pages (instead of the header) or use different header for some pages that doesn't contain the language selector? In that case would it keep the language for the session (if the control is missing at page X and at login page user has selected say Spanish) when I visit page X? Or will it show English (as I'd like to for those pages)? (the default lang of the site)

This content has not been rated yet. 
2793 Reputation 345 Total posts
vzakanj

vzakanj

7/29/2014 11:51:52 AM
Hi Zoomicon,
the way localization is handled in MonoX is through the language URL parameters which are used when localization settings are set in the database. MonoX does not use the HttpRequest.UserLanguages to infer the language from browser settings, nor does it support multiple localizations at the same time for different pages (the localization used is for for all pages).

What's important to note is that Language Changer Web Part works by setting the appropriate URL params and does not store anything in the user session.

To achieve what you want, you would need to implement custom functionality which would handle and set the URL parameters for different pages and users, as well as implement the handling of HttpRequest.UserLanguages.

Regards,
Vedran
This content has not been rated yet. 
345 Reputation 61 Total posts
Zoomicon

Zoomicon

7/29/2014 2:41:55 PM

"setting the appropriate URL params" - are these documented somewhere?

This content has not been rated yet. 
2793 Reputation 345 Total posts
vzakanj

vzakanj

7/30/2014 3:29:43 PM
Hi Zoomicon,
this is not documented, but the parameter taking the culture to be used with the page can be seen in the web.config rewriting rules - the set of rules with the "lng" param at the start of the url rewriter configuration section.

Regards,
Vedran



This content has not been rated yet. 
345 Reputation 61 Total posts
Zoomicon

Zoomicon

8/19/2014 1:35:29 PM

btw, do you have any plans to upload MonoX resources to https://www.transifex.com/ and http://www.getlocalization.com/ so that users can collaboratively localize it to many languages?

transifex also has a client you can integrate with your version control / build systems to pull localization from it and it can also pull .resx from your version control (see some links I've gathered about it at: https://www.dropbox.com/sh/3vtcbocdrinsq6r/AABY7-4xKCCbo7kEJa7sm94sa)

This content has not been rated yet. 
2793 Reputation 345 Total posts
Zoomicon

Zoomicon

8/19/2014 1:43:18 PM

I think I will do the following at http://social.clipflair.net

at the Home page and other pages (e.g. FAQ, Manual etc.) made mostly of editor webparts where there will be localized content I'll have the language selector at the master page. Other pages (e.g. the user groups and forums) will use different master page that will not have a language selector bar (since they will only have English content that is shared between all language views)

to cater for the localized URLs of the menu, e.g. when one tries to go from menu on the home page to say the forums area (e.g. from our Contribute/Suggest material menu) I will put in all pages that will be English-only some javascript that will check [say using regular epxressions] the current document's address for the lng param and remove it, then only if the address string was changed [to avoid infinite loop] it will refresh the page by setting the new address without the lng param). That way I won't have to touch codebehind etc.

This content has not been rated yet. 
2793 Reputation 345 Total posts
Zoomicon

Zoomicon

8/19/2014 2:11:13 PM

based on http://stackoverflow.com/questions/15403122/regular-expression-to-detect-iso-language-code the regular expression for the document.location part to be removed at those pages which aren't going to be localized should be /lng/[a-z]{2}-[A-Z]{2} (one can easily test it at http://regexpal.com - it highlights the /lng/xx-XX part)

note that the first part is small letters, the 2nd is capitalized (guess that's the official format)

This content has not been rated yet. 
2793 Reputation 345 Total posts
1 2