Problem with language fallback in admin.php Problem with language fallback in admin.php
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Problem with language fallback in admin.php

Started by Andi, December 14, 2004, 07:14:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andi

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
hope, I could help you... :)

Casper

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;
// ------------------------------------------------------------------------- //
// 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;
// ------------------------------------------------------------------------- //
// 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.
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

Andi

hope, I could help you... :)

Tarique Sani

SANIsoft PHP applications for E Biz

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

Andi

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?
hope, I could help you... :)

Andi

hope, I could help you... :)

Casper

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.

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

Joachim Müller

applied the fix suggested by Andi to admin.php - won't hurt to havedefine('CONFIG_PHP', true);in the code for a while...
Marking this thread as "fixed".

Joachim

Titooy


Joachim Müller


Casper

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;

Quote from: Casper on April 21, 2005, 09:28:56 AM
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;

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://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fforum.coppermine-gallery.net%2Findex.php%3Faction%3Ddlattach%3Btopic%3D17169.0%3Bid%3D1330%3Bimage&hash=2983e7638cf1563502475523b73056c02b3b57a5)
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

Titooy

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 ;-) )

Casper

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;

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

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


change it to;

// ------------------------------------------------------------------------- //
// File mode.php
// ------------------------------------------------------------------------- //

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



Find;

// ------------------------------------------------------------------------- //
// File config.php
// ------------------------------------------------------------------------- //

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


change it to;

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

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


Now find;

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

change it to;

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.
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