ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

[multilingual] how to »insert« or redirect to language?

March 15, 2010 11:11am

Subscribe [2]
  • #1 / Mar 15, 2010 11:11am

    klick

    49 posts

    hi.

    i did set up a simple site using ee 1.6+ which now turned into a multilingual project. i used the alternative method as found in the wiki to set up my multilingual site.

    everything went fine so far 😊
    theres just one problem left though:

    i want to redirect users which are using the old url (like google-cached) to the new url with the default lang-segment.

    ie:

    http://example.com/products/product-1

    should redirect to

    http://example.com/fr/products/product-1

    so i am basically looking for a way to either insert the language segment into the url OR to redirect to the new url.

    i searched the forum but honestly do not now what exactly to look for.
    could someone of you at least push me in the right direction?

    thanks a lot.

  • #2 / Mar 15, 2010 9:39pm

    ChiefAlchemist

    913 posts

    What if you put the new language at the end of the URI? If it’s there, use it. Else it’s the regular “default” site.

  • #3 / Mar 16, 2010 8:27am

    klick

    49 posts

    hi chief.

    thanks for your reply.

    What if you put the new language at the end of the URI? If it’s there, use it. Else it’s the regular “default” site.

    well, that’s the way i did it before. i’ll stick with the alternative version since it’s way more elegant and integrates better with the site.

    anyway, for now i solved the issue using redirect techniques in my htaccess file.

    i’d rather go with some ee–php or so solution since there’s a lot of stuff coming down the road for this project like landing pages and other things and mod_rewrite is still rocket science for me :D

    thanks though.

  • #4 / Mar 16, 2010 8:33am

    klick

    49 posts

    Else it’s the regular “default” site.

    that’s true. the problem here is the language switcher which just replaces the language segment in the url with the chosen one (ie: /de/ will be replaced with /en/).

    when theres no »de« or »en« segment present clicking the language switcher messes up the url like so:

    http://example.com/products/product-1

    turns into

    http://example.com/product-1

    returning a 404.

    cheers.

  • #5 / Mar 16, 2010 9:52am

    ChiefAlchemist

    913 posts

    Oh, so you’re using a plugin/add-on then?

    As for htaccess. I hear ya. I wish I had time to really get to know it better. Very powerful, but so is nuclear power and I don’t get near that either 😊

  • #6 / Mar 16, 2010 12:11pm

    klick

    49 posts

    Oh, so you’re using a plugin/add-on then?

    nope. just the alternative method as mentioned in the initial post 😊

  • #7 / Mar 16, 2010 1:50pm

    ChiefAlchemist

    913 posts

    Looked *really* quick. FWIW, I don’t think I would do it that way. As a matter of fact I was in another thread just the other day discussing this.

    My thoughts are already documented there:

    http://ellislab.com/forums/viewthread/108910/P0/

    Mind you, I’m no EE guru. I just think my idea is simple and it makes sense. In your case, if you just added the language code to the end of the URI and kept looking for it, you’d be ok. I think 😉

  • #8 / Mar 16, 2010 2:19pm

    klick

    49 posts

    thanks, but yea as i stated thats the way i used to do it in the »early times« lol 😊

    in my book the alternative method is way more elegant and it was much easier to turn my single-language-site into a multilingual version.
    for example ee doesn’t have to read the last segment and react to that, i can leave all my dynamic generated links untouched and so on.

    at the moment that language code is a variable, passed on in the background (as far i understood it), so {path="site_index"} will automatically generate proper links. i don’t have to attach anything to it in my templates. i just use {country_code} where needed and i’m done.

    plus, i wrote my own dictionary for the most used terms. all of this is taking advantage of that silent variable. in your version (which i used »back in the days« harhar) that statement at the end of each URI is just an appendix without any meaning. semantically that is.

    anyway both strategies maybe outdated already. i have not looked into plugins or extensions not to mention ee 2.0 …

    Mind you, I’m no EE guru.

    neither am i 😊
    (and excuse my broken english. that’s not my first language after all. so chances are that i completely misunderstood you there 😊)

  • #9 / Mar 16, 2010 3:05pm

    ChiefAlchemist

    913 posts

    Like I said, I just read it real quick. When I say subdirectories the first thing I thought of was hard coding. I’ll have to read it in detail but my impression was that while it works for one extra language adding a 3rd or 4th, etc. is going to mean a lot of work repeated.

    But I could be wrong. I’d have to look closer. My first gut impression was the approach was unorthodox and somewhat “forced”. It was “this will work but it’s not ideal”. I was more looking for ideal. Maybe I’m wrong about that method?

    English? Not to worry, I speak English and I don’t do so well myself 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases