Language selection and flags not working. Language selection and flags not working.
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Language selection and flags not working.

Started by Casper, January 08, 2005, 05:47:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Casper

I have just realised the language selection from the select box or flags is not working, with none of the languages being shown.
So selection can only be done from config, or using the '?lang= ' method.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here


Casper

Well I have just re-checked, ran a cvs update, and although the only file updated was in the docs folder, I deleted then re-uploaded every file, so the only modified file in this install is the english_uk.php.  I only uploaded a few of the language files, but it illustrates the problem.

See the screenshots below, the one taken in config shows the languages are available, and changing them here works, but the one taken in index.php shows that the only choice given is the reset to default.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

donnoman

I see basically the same thing on my normal devel install


Tranz


Casper

#5
OK, I got it.  It's the code in functions.inc.php to check for charset when doing the select box.

Find this;

// get list of available languages
  $value = strtolower($CONFIG['lang']);
/*
  // is utf-8 selected?
if ($CONFIG['charset'] == 'utf-8') {
     $cpg_charset = 'utf-8';
} else {
     $cpg_charset = '';
}
*/
$cpg_charset = $CONFIG['charset'];

// extension for the custom encoding files: language-charset.php
$charset_extension = '-'.$cpg_charset;

  $lang_dir = 'lang/';
  $dir = opendir($lang_dir);
  while ($file = readdir($dir)) {
      if (is_file($lang_dir . $file) && strtolower(substr($file, -4)) == '.php') {
          if (($cpg_charset != 'utf-8' && strstr($file,$charset_extension) == true) || ($cpg_charset == 'utf-8' && strstr($file,$charset_extension) == false))
          {
              $lang_array[] = strtolower(substr($file, 0 , -4));
          }
      }
  }
  closedir($dir);
  natcasesort($lang_array);



And cahnge to this;

// get list of available languages
  $value = strtolower($CONFIG['lang']);

  $lang_dir = 'lang/';
  $dir = opendir($lang_dir);
  while ($file = readdir($dir)) {   
     $lang_array[] = strtolower(substr($file, 0 , -4));
  }
  closedir($dir);
  natcasesort($lang_array);



Will commit shortly.

Committed to cvs
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

Nibbler

Your fix gives me 3 blank entries in the language dropdown box.

Titooy

Quote from: Nibbler on January 10, 2005, 02:03:35 PM
Your fix gives me 3 blank entries in the language dropdown box.

I presume it's caused by the CVS directory. Since there are 3 files in there, it makes sense... But that files won't there in the final release so I think it's not a problem.

There's also a CVS line in the Theme dropdown box for the same reason.

Nibbler

That accounts for one of the blank entries, the other 2 are caused by '.' and '..' which are not taken care of in the new version.

Joachim Müller

so// get list of available languages
  $value = strtolower($CONFIG['lang']);

  $lang_dir = 'lang/';
  $dir = opendir($lang_dir);
  while ($file = readdir($dir)) {   
     $lang_array[] = strtolower(substr($file, 0 , -4));
  }
  closedir($dir);
  natcasesort($lang_array);
should be changed to// get list of available languages
  $value = strtolower($CONFIG['lang']);

  $lang_dir = 'lang/';
  $dir = opendir($lang_dir);
  while ($file = readdir($dir)) {
     if ($file != '.' && $file != '..') {
         $lang_array[] = strtolower(substr($file, 0 , -4));
     }
  }
  closedir($dir);
  natcasesort($lang_array);
. As there probably won't be a language file named "cvs", we could as well change it to // get list of available languages
  $value = strtolower($CONFIG['lang']);

  $lang_dir = 'lang/';
  $dir = opendir($lang_dir);
  while ($file = readdir($dir)) {
     if ($file != '.' && $file != '..' && $file !='CVS') {
         $lang_array[] = strtolower(substr($file, 0 , -4));
     }
  }
  closedir($dir);
  natcasesort($lang_array);


Joachim

Joachim Müller

works as expected for me. Can this be marked as "fixed"?

Joachim

Casper

It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

Nibbler


Casper

Hmmm,

Well I didn't, but I thought as it was working as expected someone had. 

Have just committed the code as suggested by Joachim
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

Nibbler