Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Force language use.  (Read 9471 times)

0 Members and 1 Guest are viewing this topic.

benj_gos

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • My Myspace Page
Force language use.
« 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
Logged

Nibbler

  • Guest
Re: Force language use.
« Reply #1 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";
« Last Edit: November 11, 2006, 02:56:47 pm by Nibbler »
Logged

benj_gos

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • My Myspace Page
Re: Force language use.
« Reply #2 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
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Force language use.
« Reply #4 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.
Logged

benj_gos

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • My Myspace Page
Re: Force language use.
« Reply #5 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

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Force language use.
« Reply #6 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 19 queries.