thomasbjo
Posts: 43
|
Posted: 09/10/2008, 5:35 AM |
|
I have a PHP site with en, de and nb(Norwegian). I can pick the languages dynamically from the menu. But When the site is first visited it is in english even if i have set the default language to nb here:
Common.php has this entry.
$CCSLocales->DefaultLocale = ("$_DB_LANG");
$_DB_LANG is set to nb in my external config file:
//==================================================================== //DB CONNECTION DO - NOT EDIT THIS global $_DB_HOST, $_DB_PORT, $_DB_NAME, $_DB_USER, $_DB_PASSWORD, $_DB_STYLE, $_DB_LANG ;
$_DB_HOST = ""; $_DB_PORT = ""; $_DB_NAME = ""; $_DB_USER = ""; $_DB_PASSWORD = ""; $_DB_STYLE =""; $_DB_LANG ="";
//*********************START ENTERING YOUR DATA***********************
$_DB_HOST = "localhost"; //Usually localhost
$_DB_PORT = ""; // You can usually leave this empty
$_DB_NAME = "the_name"; // Enter the database here
$_DB_USER = "confused"; // Enter your user ID here
$_DB_PASSWORD = "secret"; // Enter your password here to finish!
//******Settings to change the "look and feel" of the system******
$_DB_STYLE ="thomas1"; // Enter the default style (can be changed by user)
$_DB_LANG ="nb"; // Set the default language of your system - en, de or nb //=======================FINISHED=====================================
The Default Style is set without a problem. Any experiece on this out there?I think it must be a bug.
_________________
"I know a 100 ways on how it does not work"
http://bjoernvold.com |
|
|
jjrjr1
Posts: 942
|
Posted: 09/10/2008, 7:06 AM |
|
Hi
Take a look in the common.php file and set this to your default value.
$CCSLocales->DefaultLocale = strtolower("en");
This might work.
However there are other ways. I have a site where the default language is set by a site value in the condifuration database for the site. In othewr words the admin of the site can set the default language thru admin panels.
Since the laguage of your site is set in session variable 'locale' you can also check that valiue on site startup and if not the language you want simply re-direct the site with the default language you want.
The value locale in the url will set the language
eg: http://yoursite.com/index.php?locale=nb
would do it.
Hope that helps.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
|
|
thomasbjo
Posts: 43
|
Posted: 09/11/2008, 5:32 AM |
|
Thanks for your reply.
Quote :$CCSLocales->DefaultLocale = strtolower("en");
Well yes been there - done that. That is infact the part that is not working - not directly and not with variables. Hence my bug theory. (It does not help if it is done in the CCS-Settings either)
Quote :Since the laguage of your site is set in session variable 'locale' you can also check that valiue on site startup and if not the language you want simply re-direct the site with the default language you want.
Yes I guess this is the surest way to achive my goal - redirecting with a javascript with a ?lang=nb# extension (as I hva done here: http://bjoernvold.com ).
It does not change the fact that the Default Locale is not working The ?locale=nb session variable also makes this hard to discover when developing (Easy to forget to empty the cash files:)
But the redirect solution is a workaround that works.
_________________
"I know a 100 ways on how it does not work"
http://bjoernvold.com |
|
|
jjrjr1
Posts: 942
|
Posted: 09/11/2008, 7:22 AM |
|
You do not have to re-direct with javascript. Do it in CCS PHP. That is the easiest way to get the session variable locale.
I had a similar problem on a multi lang web site. I could not make the ccs code work as I had expected.
So I used this re-direct method. It also let me set the sites default language at will based on settings in the sites configuration.
The code looks something like this.
$Temp = CCSGetSession("locale")
if($Temp!="nb"){
global $Redirect;
$Redirect = "index.php?locale=nb";
header("HTTP/1.1 302 Found");
header("Location: " . $Redirect);
exit;
}
Try that and see if it works ok for you.
Have Fun
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
|
|
jjrjr1
Posts: 942
|
Posted: 09/11/2008, 7:35 AM |
|
BTW. If you do it in java script the page will have to get served up then re-directed. This would make the initial loading pretty slow.
If done in the php only the corrected page will get served up to the client.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
|
|
thomasbjo
Posts: 43
|
Posted: 09/12/2008, 9:16 AM |
|
The redirect works just fine! Thanks for putting me on the right track.
Here is what I used in the before show event of my (Empty) index page:
global $Redirect;
$Redirect = "Mypage.php?lang=nb";
header("HTTP/1.1 302 Found");
header("Location: " . $Redirect);
exit;
_________________
"I know a 100 ways on how it does not work"
http://bjoernvold.com |
|
|
jjrjr1
Posts: 942
|
Posted: 09/12/2008, 11:33 AM |
|
Cool.... Glad to help
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
|
|
jjrjr1
Posts: 942
|
Posted: 09/12/2008, 11:35 AM |
|
BTW. Your index page does not need to be empty if you do the check and only re-direct to index if the language is not what you want..
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
|
|