switching language
switching language
Hi,
I would like to have a bilangual website without flags to make switch the language.
I means , if we are in English and want to switch to French, you have just to click on "french" and when you are in French
just click on "English" but not have the both option in the same time.
I'm not a php developper but just a integrator. I would really appreciate if someone can help me to solve this issue.
Thanks
I would like to have a bilangual website without flags to make switch the language.
I means , if we are in English and want to switch to French, you have just to click on "french" and when you are in French
just click on "English" but not have the both option in the same time.
I'm not a php developper but just a integrator. I would really appreciate if someone can help me to solve this issue.
Thanks
Re: switching language
You must go to MLE version or wait for 2.0 releaselinoleum wrote: I would like to have a bilangual website without flags to make switch the language.
I means , if we are in English and want to switch to French, you have just to click on "french" and when you are in French
just click on "English" but not have the both option in the same time.
I'm not a php developper but just a integrator. I would really appreciate if someone can help me to solve this issue.
Alby
Re: switching language
By using the top menu level as languages and use two diferent templates you should acomplish this.
Just hardcode the flags for the languages as top level and set the showing menu to start at level two.
Make the english flag show in the french template and the french flag in the english template. And set all english pages to english template and french to use french template.
(But then you click the flag you will always end on same landing page.)
Just hardcode the flags for the languages as top level and set the showing menu to start at level two.
Make the english flag show in the french template and the french flag in the english template. And set all english pages to english template and french to use french template.
(But then you click the flag you will always end on same landing page.)
ReneH
A search will save you hours waiting for an answer!
A search will save you hours waiting for an answer!
Re: switching language
I use the top-level for the languages as well.....
I also use a UDT to show the browser-language as the first page to be shown, but that is optional....
http://forum.cmsmadesimple.org/index.ph ... 805.0.html
You dont need the UDT, and can set any page as the default landing-page, but with the UDT on the landingpage, you push the viewer to the page with their language if available, else it goes to the default-page......
Ronny
I also use a UDT to show the browser-language as the first page to be shown, but that is optional....
http://forum.cmsmadesimple.org/index.ph ... 805.0.html
You dont need the UDT, and can set any page as the default landing-page, but with the UDT on the landingpage, you push the viewer to the page with their language if available, else it goes to the default-page......
Ronny
Re: switching language
Simple insert in the header of your website (or where you want users to toggle)linoleum wrote: Hi,
I would like to have a bilangual website without flags to make switch the language.
I means , if we are in English and want to switch to French, you have just to click on "french" and when you are in French
just click on "English" but not have the both option in the same time.
I'm not a php developper but just a integrator. I would really appreciate if someone can help me to solve this issue.
Thanks
===================================================
English | French
NOTE: I changed the English and French acronym to "en" and "fr" (the defaults were "usa" and "fra" (sorry but Canadians are English and some French so I preferred to use a 2-letter acronym for the language instead of the originating Country))
I just installed this module moments ago - thank goodness for it and thanks to the developers!! Here's what I did to quickly toggle between languages....
NOTE: I am using CMSMS Version 1.4.1
Good luck and enjoy this great addon!!
Re: switching language
This is MLE sintax, for language trees depend from method usedinyerface wrote: Simple insert in the header of your website (or where you want users to toggle)
===================================================
English | French
Alby
Re: switching language
I used to use the above code as well, just problem is that you will always be redirected again to the homepage. So what you basically want is to use the current URL with the language parameter added to it, so you will return to your current page, just within the language of your choice.
As I am fairly new to cmsms, I could not find an existing TAG to retrieve the current URL, so I wrote a small UDT named: get_url. It pretty much does what it says it does: returning your current URL. It comes with the options to remove and add certain variables.
How to use it? I created a global content block for the language options (so it changes with the language in MLE version or v2.x)
Note: You could unlink the language you are showing at the moment.
Code to insert into your UDT (User defined tag):
I am pretty sure the CMSMS Team will include something like this in the new version, but for now, it works for me.
Good luck!
As I am fairly new to cmsms, I could not find an existing TAG to retrieve the current URL, so I wrote a small UDT named: get_url. It pretty much does what it says it does: returning your current URL. It comes with the options to remove and add certain variables.
How to use it? I created a global content block for the language options (so it changes with the language in MLE version or v2.x)
Code: Select all
<a title="English" href="{get_url add='hl=en_US'}"><img src="images/lang/gb.png" alt="English" /></a>
<a title="Nederlands" href="{get_url add='hl=nl_NL'}"><img src="images/lang/nl.png" alt="Nederlands" /></a>
<a title="Francais" href="{get_url add='hl=fr_FR'}"><img src="images/lang/fr.png" alt="Francais" /></a>
Code to insert into your UDT (User defined tag):
Code: Select all
/*
* Get the current URL
* Parameters:
* - remove (array of vars to remove from URL)
* - add (array of vars to add to URL)
*
* Examples:
* {get_url remove="hl" add="hl=us_US:returnid=15"
*
* NOTE: Variables are seperated by a ":"
*/
$pageURL = 'http';
$REQUEST_URI = $_SERVER["REQUEST_URI"];
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
if( isset($params['add']) || isset($params['remove']) ) {
list($file_name, $file_params_string) = explode("?", $REQUEST_URI);
if( stripos($file_params_string, "&") ) {
$file_params_array = explode("&", $file_params_string);
} else {
$file_params_array = array();
}
foreach($file_params_array as $value) {
if( stripos($value, "=") ) {
list($k,$v) = explode("=", $value);
} else {
$k = $value;
$value = "$k=";
}
$file_params[$k] = $value;
}
if( isset($params['remove']) ) {
$params['remove'] = explode(":", $params['remove']);
foreach($params['remove'] as $k) {
unset($file_params[$k]);
}
}
if( isset($params['add']) ) {
$params['add'] = explode(",", $params['add']);
foreach($params['add'] as $key) {
if( stripos($key, "=") ) {
list($k,$v) = explode("=", $key);
} else {
list($k,$v) = array($key, "");
}
$file_params[$k] = "$k=$v";
}
}
$REQUEST_URI = $file_name;
if( count($file_params) ) {
$REQUEST_URI .= "?" . implode("&", $file_params);
}
}
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$REQUEST_URI;
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$REQUEST_URI;
}
return $pageURL;
Good luck!
Last edited by joeri on Tue Sep 22, 2009 5:00 am, edited 1 time in total.
Re: switching language
Have you look to lang plugin?joeri wrote: I used to use the above code as well, just problem is that you will always be redirected again to the homepage. So what you basically want is to use the current URL with the language parameter added to it, so you will return to your current page, just within the language of your choice.
As I am fairly new to cmsms, I could not find an existing TAG to retrieve the current URL, so I wrote a small UDT named: get_url. It pretty much does what it says it does: returning your current URL. It comes with the options to remove and add certain variables.
Alby
Re: switching language
Found it yesterday... ahuh!
Thanks anyway.
PS. Too bad documentation is not up to date. I understand its done by fanatics in their spare time, just if they would list the functions/modules they write, ppl would at least know something exists like this.
Thanks anyway.
PS. Too bad documentation is not up to date. I understand its done by fanatics in their spare time, just if they would list the functions/modules they write, ppl would at least know something exists like this.
Re: switching language
Tips and Tricks #2joeri wrote: PS. Too bad documentation is not up to date. I understand its done by fanatics in their spare time, just if they would list the functions/modules they write, ppl would at least know something exists like this.
Alby
Re: switching language
Ok. I implemented it, but it doesnt get the correct URL for switching purposes when you are in a module. So, still need my own code to do this.
Thanks anyways.
Thanks anyways.
Re: switching language
Obviously that module does not use CMSMS APIjoeri wrote: but it doesnt get the correct URL for switching purposes when you are in a module.
It could be a problem with new versions of CMSMS
Alby