Force language use. Force language use.
 

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

Force language use.

Started by benj_gos, November 11, 2006, 02:07:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

benj_gos

Hi,
Is there some way to force CPG to use a specific language?
Kind of having the same effect of actually deleting the languages in the lang directory, but cleaner.
(i'm guessing there's an autodetect from browser feature so deleting the files will still "waste the time" on the autodetect but then fail to assign the language and go to default, but i'm just guessing here...)

I want to make sure that the site is always in english but that other languages can be used for comments etc...

Thanks,
Benji

Nibbler

#1
You can short-circuit the language code in init.inc.php if you wish, but you will need to repeat this whenever you update your gallery.


// Process language selection if present in URI or in user profile or try
// autodetection if default charset is utf-8
if (!empty($_GET['lang']))
{
    $USER['lang'] = ereg("^[a-z0-9_-]*$", $_GET['lang']) ? $_GET['lang'] : $CONFIG['lang'];
}

if (isset($USER['lang']) && !strstr($USER['lang'], '/') && file_exists('lang/' . $USER['lang'] . '.php'))
{
    $CONFIG['default_lang'] = $CONFIG['lang'];          // Save default language
    $CONFIG['lang'] = strtr($USER['lang'], '$/\\:*?"\'<>|`', '____________');
}
elseif ($CONFIG['charset'] == 'utf-8')
{
    include('include/select_lang.inc.php');
    if (file_exists('lang/' . $USER['lang'] . '.php'))
    {
        $CONFIG['default_lang'] = $CONFIG['lang'];      // Save default language
        $CONFIG['lang'] = $USER['lang'];
    }
}
else
{
    unset($USER['lang']);
}

if (isset($CONFIG['default_lang']) && ($CONFIG['default_lang']==$CONFIG['lang']))
{
        unset($CONFIG['default_lang']);
}

if (!file_exists("lang/{$CONFIG['lang']}.php"))
  $CONFIG['lang'] = 'english';

// We load the chosen language file
require "lang/{$CONFIG['lang']}.php";

// Include and process fallback here if lang <> english
if($CONFIG['lang'] != 'english' && $CONFIG['language_fallback']==1 ){
        require "include/langfallback.inc.php";
}


Replace with


// We load the chosen language file
require "lang/{$CONFIG['lang']}.php";

benj_gos

wonderful, works! :)

too bad there's no mod for it...
hmm.. maybe that's a good way for me to learn php. ;)

Thank you anyway.  ;D

Benji


Joachim Müller

Deleting the unneeded language files actually is the cleanest method and exactly what I'd recommend in your case.

benj_gos

Stramm, you were saying something in there about a future plugin instead of the core modifications? ;)

GauGau, wouldn't deleting the files still have the autodetect run, but fail (thus causing the extra time to load)? Although i guess it is the "faster" fix, simply deleting\renaming the files.

Benji


Joachim Müller

The detection won't burn too many CPU cycles imo. Deleting the files and not fiddling with the core code will make upgrading easier, that's why we recommend it.