forum.coppermine-gallery.net

Dev Board => cpg1.4 Testing/Bugs => cpg1.4 Testing/Bugs: FIXED/CLOSED => Topic started by: Casper on January 08, 2005, 05:47:47 pm

Title: Language selection and flags not working.
Post by: Casper on January 08, 2005, 05:47:47 pm
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.
Title: Re: Language selection and flags not working.
Post by: Nibbler on January 09, 2005, 05:21:04 pm
Working fine for me.
Title: Re: Language selection and flags not working.
Post by: Casper on January 09, 2005, 07:11:45 pm
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.
Title: Re: Language selection and flags not working.
Post by: donnoman on January 09, 2005, 08:59:07 pm
I see basically the same thing on my normal devel install

Title: Re: Language selection and flags not working.
Post by: Tranz on January 09, 2005, 09:12:23 pm
me too
Title: Re: Language selection and flags not working.
Post by: Casper on January 09, 2005, 09:28:00 pm
OK, I got it.  It's the code in functions.inc.php to check for charset when doing the select box.

Find this;

Code: [Select]
// 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;

Code: [Select]
// 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
Title: Re: Language selection and flags not working.
Post by: Nibbler on January 10, 2005, 02:03:35 pm
Your fix gives me 3 blank entries in the language dropdown box.
Title: Re: Language selection and flags not working.
Post by: Titooy on January 10, 2005, 03:51:41 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.
Title: Re: Language selection and flags not working.
Post by: Nibbler on January 10, 2005, 04:24:50 pm
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.
Title: Re: Language selection and flags not working.
Post by: Joachim Müller on January 10, 2005, 08:33:15 pm
so
Code: [Select]
// 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
Code: [Select]
// 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
Code: [Select]
// 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
Title: Re: Language selection and flags not working.
Post by: Joachim Müller on January 13, 2005, 08:37:46 am
works as expected for me. Can this be marked as "fixed"?

Joachim
Title: Re: Language selection and flags not working.
Post by: Casper on January 13, 2005, 10:48:55 am
And me, marking as fixed.
Title: Re: Language selection and flags not working.
Post by: Nibbler on January 17, 2005, 03:04:32 pm
Anyone actually commited this ?
Title: Re: Language selection and flags not working.
Post by: Casper on January 17, 2005, 10:46:47 pm
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
Title: Re: Language selection and flags not working.
Post by: Nibbler on January 19, 2005, 03:03:38 pm
Thanks Casper, it's now working properly.