Page 1 of 1

Miltilingual setup

Posted: 18 Jul 2016, 11:12
by GeoPal
Hello,
Wanted to share our decision how to make multilingual site with X3:

http://www.studiocreative.bg/en/

We have 2 directories with installed galleries and same content, translated in both languages. Also the link for different galleries is in the top right corner, which is just a regular menu item with URL.

If anyone has tried something else, pls share.
Best, G

Re: Miltilingual setup

Posted: 18 Jul 2016, 11:36
by mjau-mjau
GeoPal wrote:Hello,
Wanted to share our decision how to make multilingual site with X3:
http://www.studiocreative.bg/en/
Nice. Although it's not optimal to maintain two separate X3 installations, this is currently the best/easiest way to manage dual languages.

It would perhaps be more perfect if there was country flags beside of "EN" and "BG" ... and maybe the link should go to the SAME page for the other language ... which would simply require some javascript.

Re: Miltilingual setup

Posted: 19 Jul 2016, 23:03
by GGANG
mjau-mjau wrote:It would perhaps be more perfect if there was country flags beside of "EN" and "BG"
Hi Geopal,
I would like to see the country flags images instead of the letters "EN" "BG"
The visitor will be observed easily. :shock:
Thanks for great idea. :idea:

Re: Miltilingual setup

Posted: 20 Jul 2016, 07:33
by GeoPal
Hi Karl,
Any help/tips on how to put an image with link in the menu? I had several ideas but nothing worked.
Thank you in advance. I agree that with flags will be easier to comprehend .
Best, G

Re: Miltilingual setup

Posted: 20 Jul 2016, 11:26
by mjau-mjau
GeoPal wrote:Hi Karl,
Any help/tips on how to put an image with link in the menu? I had several ideas but nothing worked.
Thank you in advance. I agree that with flags will be easier to comprehend .
Best, G
Yep :/ Unfortunately, menu labels don't support <img> tags ... yet at least. You would have to inject an <img> by javascript, which would not be difficult. But that makes we think that the language buttons should perhaps not be part of the main menu anyway ... Instead, perhaps just a flag and very small text EN/BG. This could be added to footer for example, and set to absolute position with CSS.

Do you have any flag icons? They have some nice flags at Emojione (see "flags"). If you want, you can give me login to your panel, and I will try to implement a better solution for you ...

Re: Miltilingual setup

Posted: 21 Jul 2016, 05:45
by GeoPal
Thanks Karl, PM sent!
Best, G

Re: Miltilingual setup

Posted: 21 Jul 2016, 10:51
by mjau-mjau
Ok, check it out:
http://www.studiocreative.bg/projects/
http://www.studiocreative.bg/en/projects/

I made two changes:
1. Flag icons prepended dynamically.
2. Link is now dynamic, so that it changes to the sibling page that the visitor is currently on.

I see a problem though ... Not all URL's have symmetrical links, for example:
http://www.studiocreative.bg/en/news/fi ... -pirotska/
http://www.studiocreative.bg/news/първа ... -пиротска/

So likely we need to remove #2 dynamic links ... Let me know what you think.

All changes were added to settings -> custom -> CSS, and Javascript. PS! I also removed the "prevent right click" javascript you had under custom javascript, because this is already applied in a setting https://d.pr/i/8KzK.

Re: Miltilingual setup

Posted: 21 Jul 2016, 14:48
by GeoPal
Wow Karl,
Thanks! A lot! :shock:
I knew there would be a problem with links btw, as they are not in the same language. Well, :) No worries. We will see what we will decide with my partner.
Again, thanks! I can't stop recommending the gallery, not only because it's the best there is, but because of your attitude and attention to all the people asking this and that! Thanks, really!
Best, G

Re: Miltilingual setup

Posted: 02 Sep 2016, 15:56
by MikeR
Hello Karl,

The result is great !!

Can you explain to us how to do the same ?

Thank you

Re: Miltilingual setup

Posted: 03 Sep 2016, 08:33
by mjau-mjau
MikeR wrote:Can you explain to us how to do the same ?
You want to create two languages? ... or your question is to have two flag icons? To create two languages, you would follow the original post in this thread ...

Re: Miltilingual setup

Posted: 03 Sep 2016, 09:01
by MikeR
I have already 2 separate directory for the 2 languages. How add the flag for each language?
Thanks

Re: Miltilingual setup

Posted: 03 Sep 2016, 09:46
by mjau-mjau
MikeR wrote:How add the flag for each language?
It should be possible in next release (next week) to add the images directly to the page label (although they may not look nice unless you adjust height of images with custom CSS). Label input:
Code
<img src="/lang.png" /> lang
For now, below is the full hack as added to studiocreative.bg. You will need to adjust it:

1. Prepare your language images in root, for example /en.png and /bg.png.
2. For the where you have added the language-link, go to menu -> menu classes (bottom), and add the class "menu-lang":

3. Go to settings -> custom -> custom JS, add the following code (remove the lines with // comments):
Code
// the below code is only for adding the flag image
function x3_load(){
  // get the lang anchor link
  var menu_lang = $('li.menu-lang > a'),
    // get current url
    location = window.location.href.split('?')[0],
    // set flag code ('bg' or 'en') opposite language of current url
    flag = location.indexOf('/en') > -1 ? 'bg' : 'en';
  // prepend the img
  menu_lang.prepend('<img src="/' + flag + '.png" />');
}

// This function is only if you want the language link to dynamically mirror current page
function x3_load_page(){
  // dynamic language link
  setTimeout(function(){
    var menu_lang = $('li.menu-lang > a'),
        location = window.location.href.split('?')[0];
    if(location.indexOf('/en') > -1){
      // if language is secondary (en), create the link from current link, without '/en'
      menu_lang.attr('href', location.replace('/en', ''));
    } else {
      // if language is primary (bg), append /en
      menu_lang.attr('href', location.replace('.bg', '.bg/en'));
    }
  }, 500);
}
4. To adjust the flag icon image, I added this to settings -> custom -> custom CSS:
Code
li.menu-lang > a > img {
  height: 13px;
  margin: 0 5px 5px 0;
}
It may need to be adjusted though. Let me know if you need any help ...

Re: Miltilingual setup

Posted: 02 Jan 2017, 22:06
by GGANG
Hi Karl,

Please, I needs more explanation the custom JS for /en of X3 install. How to do with custom JS?
Now I have done for the root X3 primary language is Thai. English flag appear on a menu but when click it is not go.
I want secondary language is /en, I have prepare the same contents but different language.
and Should I have to put custom head?

Thank you,

Re: Miltilingual setup

Posted: 03 Jan 2017, 03:30
by mjau-mjau
@GGANG What is the link to the website in mention so I can take a look? Did you add the custom javascript, and add the "menu-lang" class to the languages menu item?

Re: Miltilingual setup

Posted: 04 Jan 2017, 01:07
by GGANG
Just sent you PM

Thank you,
Lek