Closed wstaelens closed 6 years ago
Just add a new folder for each language. If you want to redirect automatically to current user's declared lang in the browser (I hate when they do that), you'll need to use any of these methods:
Accept-Language
header) and redirecting users to the specific lang folder. global.asax
file to the site and in the Application_BeginRequest
event add a code similar to this one:string currentPreferredLang = HttpContext.Current.Request.UserLanguages[0].ToLower();
switch (currentPreferredLang)
{
case 'es':
case 'es-es':
Response.Redirect('/es/', false);
break;
case 'fr':
Response.Redirect('/fr/', false);
break;
default: //Default case, English (for example)
Response.Redirect('/en/', false);
}
Response.StatusCode = 302; //Non-permanent
Maybe in this event you should check this only for the default page in the root, and/or only during the first request, and so on.
I prefer to clearly show icons to change language and let users choose which one they want to use.
HTH
@jmalarcon:
can you create an example as it is not clear where to add this.
"Just add a new folder for each language." Where should I add this e.g. in my structure?
I've seen many (static and regular) sites that allow you to select a specific language, but if something is not translated it shows just the english/default content. Will this work also?
You can do whatever you want with the structure (it's not part of MIIS, and you need to implement it), but it seems to me that the best way would be to have the lang folders on the root and have a replica of the contents inside each one:
/root
|___ /en/
|___ /gettingstarted/
|___ /hands-on/
|___ /security/
|___ /setup/
|___ /es/
|___ /gettingstarted/
|___ /hands-on/
|___ /security/
|___ /setup/
|___ /fr/
|___ /gettingstarted/
|___ /hands-on/
|___ /security/
|___ /setup/
inside each language you need to maintain the contents in the corresponding language.
Programming the redirection on the first request it's something easy to do as I explained in my previous message.
hm ok. "I've seen many (static and regular) sites that allow you to select a specific language, but if something is not translated it shows just the english/default content."
how would this work?
(+ isn't this functionality that could be built-in my default in MIIS?)
This is not supported right now. Could it be? Yes, in some kind of convention-based feature, but currently is not and unfortunatelly I don't have the time right now to devote to add this feature (and have a lot of them in the pipeline to add before it, hopefully before this year's end).
Meanwhile the option is the one I specified in previous messages, which is pretty straightforward to implement.
HTH
ok, i'll wait when it is there out of the box ;-)
How can I configure MIIS to use multiple languages?