jmalarcon / MIIS

Powerful file-based CMS for IIS - Your Markdown-based documentation or website in a few minutes!
https://miis.azurewebsites.net/
MIT License
31 stars 6 forks source link

Multilingual #23

Closed wstaelens closed 6 years ago

wstaelens commented 6 years ago

How can I configure MIIS to use multiple languages?

jmalarcon commented 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:

  1. Create a URL Rewrite rule to catch the current declared lang (using the Accept-Language header) and redirecting users to the specific lang folder.
  2. Add a 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

wstaelens commented 6 years ago

@jmalarcon:

miisedit folders

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?

jmalarcon commented 6 years ago

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.

wstaelens commented 6 years ago

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?)

jmalarcon commented 6 years ago

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

wstaelens commented 6 years ago

ok, i'll wait when it is there out of the box ;-)