Multilanguage CMSMS MLE version 1.1.1

This is a FORK of the CMS Made Simple project and is not oficially supported in any way by the CMS Made Simple development team.
alby

Re: Multilanguage CMSMS MLE versione 1.1.2

Post by alby »

andreTTi wrote: Hi alby and thank you for your great work!
Thank you  ;D

andreTTi wrote: I have installed cmsms mle 1.1.2 and so far it works great except for one small thing. For some reason firefox chooses english as default language although I have configured swedish as default. (With Opera and IE6 it's working and swedish is default)
I tried to follow your instructions as closely as possible but maybe I got somehing wrong..

This is my config_lang.php:
define('DEFAULT_LANG', 'sv_SE');

$hls = array(

'en_US' => array(
'block'=>'en',
'flag'=>'',
),
'sv_SE' => array(
'block'=>'sv',
'flag'=>'',
'locale'=>'sv_SE',
),


Actually i'm not sure about 'locale'=>'sv_SE' ? Is this correct? If not, where can I find the correct locale?
In Unix and shell account or create a php file with this command: locale -a

Code: Select all

<?php
$output = shell_exec('locale -a');
echo $output;
?>
and check your locale strings, for Windows check in above Replies
I add this option for avoid locale problem on servers.
I think, for next release, the possibility of force DEFAULT_LANG in config_lang.php:
$force_default_lang = true/false; // Default: false

andreTTi wrote: In config.php locale is left empty. ($config['locale'] = '';)

In Site Admin->Global Settings, "Default language for the frontend:" = "No default selected"
Ok  ;)

andreTTi wrote: What do you mean by "current language (in this way CMSMS load current locale language for ALL modules)"?
In normal mode CMSMS modules load en_US languages (load other language with lang params only)

andreTTi wrote: In firefox a cookie named "mle" is set to "en_US" when I go to my frontpage. In Opera it is set to "sv_SE" as it should. Default language is set to Swedish in both firefox and opera.
What are your languages in Firefox (Tools > Options > Advanced > General > Languages)?

Alby
andreTTi

Re: Multilanguage CMSMS MLE versione 1.1.2

Post by andreTTi »

Thank you for the quick reply!
alby wrote: In Unix and shell account or create a php file with this command: locale -a
I got the following replies:

Code: Select all

sv_SE
sv_SE.iso88591
sv_SE.iso885915
sv_SE.utf8
swedish
So I guess 'locale'=>'sv_SE' should be ok then?
alby wrote: I think, for next release, the possibility of force DEFAULT_LANG in config_lang.php:
$force_default_lang = true/false; // Default: false
That would be great!  :)
alby wrote:
andreTTi wrote: In config.php locale is left empty. ($config['locale'] = '';)
Ok  ;)
That was supposed to be:

Code: Select all

($config['locale'] = '';)
Don't worry, I'm not flirting with you! ;)
alby wrote: What are your languages in Firefox (Tools > Options > Advanced > General > Languages)?
My languages in firefox is in the following order:
- Svenska [sv]                                       (swedish)
- Engelska/Förenta staterna [en-us]     (US english)
- Engelska [en]                                      (english)

I guess this is a bug in firefox since it working with opera and IE6..

Andreas
alby

Re: Multilanguage CMSMS MLE versione 1.1.2

Post by alby »

andreTTi wrote: I got the following replies:

Code: Select all

sv_SE
sv_SE.iso88591
sv_SE.iso885915
sv_SE.utf8
swedish
So I guess 'locale'=>'sv_SE' should be ok then?
Yes, but (maybe  ???) sv_SE.utf8 is better (if you use all  utf8)

andreTTi wrote: My languages in firefox is in the following order:
- Svenska [sv]                                      (swedish)
- Engelska/Förenta staterna [en-us]    (US english)
- Engelska [en]                                      (english)
Ok, browser script check match in your language order with locale: sv_SE, en_US
sv not match with sv_SE or en_US
en-us (same to en_US) match with en_US

IF YOU DELETE [en-us] languages, script continue with:
en not match with sv_SE or en_US

after browser script re-check match in your language order with parent-locale: sv, en
sv match with sv

This script is a modify version of www.php.net script
I don't know if modify

I see for locale:
fi            Finnish
fi_FI        Finnish Finland
sv          Swedish
sv_FI      Swedish Finland
sv_SE      Swedish Sweden

What are languages in Swedish Finland (if exist) Firefox?

Alby
Last edited by alby on Fri Sep 21, 2007 9:30 am, edited 1 time in total.
andreTTi

Re: Multilanguage CMSMS MLE versione 1.1.2

Post by andreTTi »

alby wrote: Ok, browser script check match in your language order with locale: sv_SE, en_US
sv not match with sv_SE or en_US
en-us (same to en_US) match with en_US

IF YOU DELETE [en-us] languages, script continue with:
en not match with sv_SE or en_US

after browser script re-check match in your language order with parent-locale: sv, en
sv match with sv
I'm not sure if I understand this correctly but should'nt sv take precedence over en_US  ??? I'm mean since it's the "parentlocale" of sv_SE. Anyway, I have modified the function "language_user_setting" in function.mle.php to do so.

Here is the modified version:

Code: Select all

function language_user_setting( $hls )
{
	$browser_langs = array();

	// Check if we have $_SERVER['HTTP_ACCEPT_LANGUAGE'] set and
	// it no longer breaks if you only have one language set :)
	if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
		$browser_accept = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']);

		// Go through all language preference specs
		for ($i = 0; $i < count($browser_accept); $i++) {
			// The language part is either a code or a code with a quality
			// We cannot do anything with a * code, so it is skipped
			// If the quality is missing, it is assumed to be 1 according to the RFC
			if (preg_match("!([a-z-]+)(;q=([0-9\\.]+))?!", trim($browser_accept[$i]), $found)) {
				$quality = (isset($found[3]) ? (float) $found[3] : 1.0);
				$browser_langs[] = array($found[1], $quality);
			}
			unset($found);
		}
	}

	// Order the codes by quality
	usort($browser_langs, "language_accept_order");

	$t_hls = transform_language_arr($hls);

	foreach($browser_langs as $browser_lang)
	{
		$language = trim($browser_lang[0]);
		if (strlen($language) == 2)
		{
			$language = strtolower($language);
			if (in_array($language, array_keys($t_hls))) return $t_hls["$language"];
		}
		else
		{
			// Check if $language in config
			$language = strtolower(substr($language, 0, 2)) .'_'. strtoupper(substr($language, 3, 2));
			if (in_array($language, array_keys($hls))) return $language;
		}
	}

	return DEFAULT_LANG;
}
This seems to work for me anyway. I don't know if this breaks something else, so use at own risk!  :)

Thanks again for your help Alby!

Andreas
alby

Re: Multilanguage CMSMS MLE versione 1.1.2

Post by alby »

andreTTi wrote: I'm not sure if I understand this correctly but should'nt sv take precedence over en_US  ??? I'm mean since it's the "parentlocale" of sv_SE. Anyway, I have modified the function "language_user_setting" in function.mle.php to do so.
The problem is:
If you have a site with: en_GB, en_AU, en_US what languages if first?

TODO: I would want is to connect the plugin geolocate

Alby
andreTTi

Re: Multilanguage CMSMS MLE versione 1.1.2

Post by andreTTi »

alby wrote: The problem is:
If you have a site with: en_GB, en_AU, en_US what languages if first?
No problem, for example if the browser is configured with en_AU, that language will be choosen. If the browser is configured with only the generic en, I guess the result would be a bit random (the first one in the list will probably be choosen). But in this case, is'nt it up to the browser to report correct locale in the first place?
I think this behavior is more correct than the original solution which selected an entire different language. (but of course I could be wrong. Maybe I don't have enough insight in how this is supposed to work?)  :)


On a sidenote, how hard would it be to adapt news module and album module to be multilingual?


Andreas
alby

Re: Multilanguage CMSMS MLE versione 1.1.2

Post by alby »

andreTTi wrote:
On a sidenote, how hard would it be to adapt news module and album module to be multilingual?
For News module I use this method:

Create plus category:
Home-en_US, Home-it_IT, Home-fr_FR

In template call module:
{news category="Home-$lang"}


For Album I must still try  ;)

Alby
alby

Re: Multilanguage CMSMS MLE version 1.1.2

Post by alby »

I have upgrade to CMSMS 1.1.3.1  ;D
I started a new topic for this version ONLY

Alby
Last edited by alby on Sat Sep 22, 2007 8:46 pm, edited 1 time in total.
lapinkulta
New Member
New Member
Posts: 3
Joined: Sat Sep 22, 2007 6:54 pm

Re: Multilanguage CMSMS MLE version 1.1.2

Post by lapinkulta »

I'm trying to set up a site in german and hungarian and got mod_rewrite working thanks to the tips here. However, I would prefer to have the URLs like www.domain.com/hu/... and www.domain.com/de/.... instead of www.domain.com/hu_HU/... and www.domain.com/de_DE/...

I know I can change in config_lang.php from hu_HU to hu, but I feel I'm not using the correct language selection than anymore. Hope you understand what I mean.

Thank you.
lapinkulta
alby

Re: Multilanguage CMSMS MLE version 1.1.2

Post by alby »

lapinkulta wrote: I'm trying to set up a site in german and hungarian and got mod_rewrite working thanks to the tips here. However, I would prefer to have the URLs like www.domain.com/hu/... and www.domain.com/de/.... instead of www.domain.com/hu_HU/... and www.domain.com/de_DE/...

I know I can change in config_lang.php from hu_HU to hu, but I feel I'm not using the correct language selection than anymore. Hope you understand what I mean.
Try to use locale in config_lang.php  ;)

'hu' => array (
  'block'=>'hu',
  'flag'=>'',
  'locale'=>'hu_HU',
),

Alby
lapinkulta
New Member
New Member
Posts: 3
Joined: Sat Sep 22, 2007 6:54 pm

Re: Multilanguage CMSMS MLE version 1.1.2

Post by lapinkulta »

now that has also a meaning to me  :D grazie alby
alby

Re: Multilanguage CMSMS MLE version 1.1.2

Post by alby »

lapinkulta wrote: now that has also a meaning to me  :D grazie alby
I have tried to have the maximum flexibility  ;)

Alby
ottyscom
Forum Members
Forum Members
Posts: 154
Joined: Tue Nov 13, 2007 12:01 am

Re: Multilanguage CMSMS MLE version 1.1.2

Post by ottyscom »

Hello

At the moment all the Lings will show follwing: http://www.otschuster.com/index.php?page=home&hl=es_ES

I would like tho show withe only es (not es_ES) ist that posible? How can i make it?

Another Problem. The Module Album for Photogallery will not show in multilanguage. How can i make it multilanguage for your MLE Edition?

Thank you for your help

Otty
alby

Re: Multilanguage CMSMS MLE version 1.1.2

Post by alby »

ottyscom wrote: At the moment all the Lings will show follwing: http://www.otschuster.com/index.php?page=home&hl=es_ES

I would like tho show withe only es (not es_ES) ist that posible? How can i make it?
Try in config_lang.php with:
'es_ES' = array(
        ......
      'locale' => 'es_ES',
);

ottyscom wrote: Another Problem. The Module Album for Photogallery will not show in multilanguage. How can i make it multilanguage for your MLE Edition?
Album (comments) and many other modules are monolingual only.
Workaround (if there is that option) is set param lang="$lang" in calling module.

Alby
Last edited by alby on Thu Nov 15, 2007 1:05 pm, edited 1 time in total.
ottyscom
Forum Members
Forum Members
Posts: 154
Joined: Tue Nov 13, 2007 12:01 am

Re: Multilanguage CMSMS MLE version 1.1.2

Post by ottyscom »

Ok Thank You,

But i have a big Problem about this.

When my website is visited from a browser or computer at the first the server will show an error:

NOT FOUND

The Server encountered an internal error or missconfiguration and was unable to complete your request


Corioosly when i visit the webpage for my browsers on my computer the website will shoen corectly without erro messages.

Who is the Problem? How can i solvent it?

Thank You
Locked

Return to “[locked] CMSMS MLE fork”