forum.coppermine-gallery.net

Dev Board => cpg1.4 Testing/Bugs => cpg1.4 Testing/Bugs: FIXED/CLOSED => Topic started by: Andi on December 14, 2004, 07:14:06 pm

Title: Problem with language fallback in admin.php
Post by: Andi on December 14, 2004, 07:14:06 pm
Hello Team :)

when i change to another language than english, the configuration menue is completely empty. No options are available.

I think there is a conflict between the constants ADMIN_PHP and CONFIG_PHP.
CONFIG_PHP is used for the fallback function, but only ADMIN_PHP is defined in admin.php.

I've write additionaly this line in admin.php:
define('CONFIG_PHP', true);

Not shure if it's the correct solution, but it works for me ;)


admin.php,v 1.15 2004/12/12 10:24:05 gaugau
langfallback.inc.php,v 1.12 2004/12/12 10:24:13 gaugau
Title: Re: Problem with language fallback in admin.php
Post by: Casper on December 14, 2004, 08:43:00 pm
Well spotted.  This was overlooked when I changed the names of the old admin.php (now mode.php) and config.php (now admin.php)

The correct fix is to change it in langfallback.inc.php

Find;
Code: [Select]
// ------------------------------------------------------------------------- //
// File admin.php
// ------------------------------------------------------------------------- //

if (defined('ADMIN_PHP')) {
  $lang_admin_php_en = cpg_get_default_lang_var('lang_admin_php','english');
  $lang_admin_php = array_merge($lang_admin_php_en, $lang_admin_php);
}

if (defined('CONFIG_PHP')) {
  $lang_admin_data_en = cpg_get_default_lang_var('lang_admin_data','english');
  $lang_admin_data = array_merge($lang_admin_data_en, $lang_admin_data);
}

and change it to;
Code: [Select]
// ------------------------------------------------------------------------- //
// File admin.php
// ------------------------------------------------------------------------- //

// ------------------------------------------------------------------------- //
// File admin.php
// ------------------------------------------------------------------------- //

if (defined('ADMIN_PHP')) {
  $lang_admin_php_en = cpg_get_default_lang_var('lang_admin_php','english');
  $lang_admin_php = array_merge($lang_admin_php_en, $lang_admin_php);
}

if (defined('ADMIN_PHP')) {
  $lang_admin_data_en = cpg_get_default_lang_var('lang_admin_data','english');
  $lang_admin_data = array_merge($lang_admin_data_en, $lang_admin_data);
}

Can you please test this works for you.
Title: Re: Problem with language fallback in admin.php
Post by: Andi on December 15, 2004, 12:40:02 am
Yes, it works fine  :D
Title: Re: Problem with language fallback in admin.php
Post by: Tarique Sani on December 15, 2004, 05:39:54 am
@Casper - please commit if not already done :)
Title: Re: Problem with language fallback in admin.php
Post by: Casper on December 15, 2004, 10:21:33 am
Fixed and committed.  Version 1.13  ;)
Title: Re: Problem with language fallback in admin.php
Post by: Andi on December 24, 2004, 12:47:09 am
Hello :)

Embarrassingly, but it does not work yet correctly.

here are the error-messages:
Quote
\include\langfallback.inc.php
    * Notice line 152: Undefined variable: lang_admin_data
    * Warning line 152: array_merge() [function.array-merge]: Argument #2 is not an array
    * Warning line 308: array_merge() [function.array-merge]: Argument #2 is not an array
For sample, in german language file the variable  lang_admin_data doesn't exist. This causes that the function array_merge() fails and the variable lang_admin_data is totaly empty.
Similar errors happen also at other opportunities.

I studied myself the file 'langfallback.inc.php' and converted it very extensively.
I added the result here as attachment.

Look at it, maybe it is the better solution?
Title: Re: Problem with language fallback in admin.php
Post by: Andi on December 24, 2004, 02:33:35 am
updated file...
Title: Re: Problem with language fallback in admin.php
Post by: Casper on December 24, 2004, 10:38:53 am
Andi,

the only correct language file in the 1.4 version is English, none of the others have been brought up to the changes in 1.4 yet, so it will not work, because the other language files are actually 1.3 version files.

Changes such as the move from config.php to admin.php are not in the german.php file, so it will not work.  Once the feature freeze is in place, and the correct new translations are done, it will work.

Title: Re: Problem with language fallback in admin.php
Post by: Joachim Müller on December 28, 2004, 06:53:36 am
applied the fix suggested by Andi to admin.php - won't hurt to have
Code: [Select]
define('CONFIG_PHP', true);in the code for a while...
Marking this thread as "fixed".

Joachim
Title: Re: Problem with language fallback in admin.php
Post by: Titooy on May 10, 2005, 11:27:10 pm
That problem is back :-\\
Title: Re: Problem with language fallback in admin.php
Post by: Joachim Müller on May 11, 2005, 09:46:39 am
elaborate, please.
Title: Re: Problem with language fallback in admin.php
Post by: Casper on May 11, 2005, 11:39:13 am
I suspect that Titooy has been affected by the changes made following the problem encountered on this thread;

http://forum.coppermine-gallery.net/index.php?topic=17169.0

I have copied the main post here, as that thread is devs only;

I have found the following problem in langfallback, that will affect all language files.

When the array for admin.php, '$lang_admin_data = array(' is added in the language, you end up with an admin section for each in both english and your language.

I hope the attached screenshot will make it clearer what I mean.

This is caused by this section of code in langfallback;

Code: [Select]
if (defined('ADMIN_PHP')) {
  $lang_admin_data_en = cpg_get_default_lang_var('lang_admin_data','english');
  $lang_admin_data = array_merge($lang_admin_data_en, $lang_admin_data);
}


Obviously, each language will have different array, so langfallback see these as different, and puts in both.

Removing the above code works, but it does mean that this section of code for admin.php will have to be present in every language file.


Please note that every language file must have the relevant section of code to work, as langfallback cannot be used for this without duplicating the output of the entire section.


(https://forum.coppermine-gallery.net/index.php?action=dlattach;topic=17169.0;id=1330;image)
Title: Re: Problem with language fallback in admin.php
Post by: Titooy on May 11, 2005, 11:27:07 pm
I presume this is the reason why for now the config options aren't available in any other language than english... (elaboration of the problem ;-) )
Title: Re: Problem with language fallback in admin.php
Post by: Casper on May 12, 2005, 11:46:25 am
Yes, the othe languages are still actually 1.3x versions, and are not 1.4 ready.  The change from config.php to admin.php is the one that affects this particular area, but there are many others that will not work correctly with 1.4.

If you want to use one of these files in the meantime, you can make the following changes;

Find;

Code: [Select]
// ------------------------------------------------------------------------- //
// File admin.php
// ------------------------------------------------------------------------- //

if (defined('ADMIN_PHP')) $lang_admin_php = array(

change it to;

Code: [Select]
// ------------------------------------------------------------------------- //
// File mode.php
// ------------------------------------------------------------------------- //

if (defined('MODE_PHP')) $lang_mode_php = array(


Find;

Code: [Select]
// ------------------------------------------------------------------------- //
// File config.php
// ------------------------------------------------------------------------- //

if (defined('CONFIG_PHP')) $lang_config_php = array(

change it to;

Code: [Select]
// ------------------------------------------------------------------------- //
// File admin.php
// ------------------------------------------------------------------------- //

if (defined('ADMIN_PHP')) $lang_admin_php = array(

Now find;

Code: [Select]
if (defined('CONFIG_PHP')) $lang_config_data = array(
change it to;

Code: [Select]
if (defined('ADMIN_PHP')) $lang_admin_data = array(


Note, these are not all the changes required to these areas by a long way, but will give you the same functions as available in version 1.3x.