forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 language => Topic started by: benj_gos on November 11, 2006, 02:07:10 pm

Title: Force language use.
Post by: benj_gos on November 11, 2006, 02:07:10 pm
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
Title: Re: Force language use.
Post by: Nibbler on November 11, 2006, 02:43:42 pm
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.

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

Code: [Select]
// We load the chosen language file
require "lang/{$CONFIG['lang']}.php";
Title: Re: Force language use.
Post by: benj_gos on November 11, 2006, 08:38:05 pm
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
Title: Re: Force language use.
Post by: Stramm on November 11, 2006, 08:48:11 pm
http://forum.coppermine-gallery.net/index.php?topic=30686.msg142274#msg142274
Title: Re: Force language use.
Post by: Joachim Müller on November 12, 2006, 10:14:34 am
Deleting the unneeded language files actually is the cleanest method and exactly what I'd recommend in your case.
Title: Re: Force language use.
Post by: benj_gos on November 12, 2006, 12:13:55 pm
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

Title: Re: Force language use.
Post by: Joachim Müller on November 12, 2006, 02:02:34 pm
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.