diff options
Diffstat (limited to '')
-rw-r--r-- | include/common.inc.php | 25 | ||||
-rw-r--r-- | include/constants.php | 1 | ||||
-rw-r--r-- | include/functions_user.inc.php | 34 |
3 files changed, 37 insertions, 23 deletions
diff --git a/include/common.inc.php b/include/common.inc.php index fa0a7f3db..38b0e7de0 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -166,32 +166,11 @@ while ( $row =mysql_fetch_array( $result ) ) include(PHPWG_ROOT_PATH.'include/user.inc.php'); // language files -$user_langdir = PHPWG_ROOT_PATH.'language/'.$user['language']; -$conf_langdir = PHPWG_ROOT_PATH.'language/'.$conf['default_language']; +include_once(get_language_filepath('common.lang.php')); -if (file_exists($user_langdir.'/common.lang.php')) -{ - include_once($user_langdir.'/common.lang.php'); -} -else -{ - include_once($conf_langdir.'/common.lang.php'); -} - -// The administration section requires 2 more language files if (defined('IN_ADMIN') and IN_ADMIN) { - foreach (array('admin') as $section) - { - if (file_exists($user_langdir.'/'.$section.'.lang.php')) - { - include_once($user_langdir.'/'.$section.'.lang.php'); - } - else - { - include_once($conf_langdir.'/'.$section.'.lang.php'); - } - } + include_once(get_language_filepath('admin.lang.php')); } // only now we can set the localized username of the guest user (and not in diff --git a/include/constants.php b/include/constants.php index a04020d50..a7823b230 100644 --- a/include/constants.php +++ b/include/constants.php @@ -29,6 +29,7 @@ define('PHPWG_VERSION', '%PWGVERSION%'); define('PHPWG_URL', 'http://www.phpwebgallery.net'); define('PHPWG_FORUM_URL', 'http://forum.phpwebgallery.net'); +define('PHPWG_DEFAULT_LANGUAGE', 'en_UK.iso-8859-1'); // Error codes define('GENERAL_MESSAGE', 200); diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 41321a587..25dc3efda 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -497,4 +497,38 @@ SELECT name return $groupname; } + +/** + * return the file path of the given language filename, depending on the + * availability of the file + * + * in descending order of preference: user language, default language, + * PhpWebGallery default language. + * + * @param string filename + * @return string filepath + */ +function get_language_filepath($filename) +{ + global $user, $conf; + + $directories = + array( + PHPWG_ROOT_PATH.'language/'.$user['language'], + PHPWG_ROOT_PATH.'language/'.$conf['default_language'], + PHPWG_ROOT_PATH.'language/'.PHPWG_DEFAULT_LANGUAGE + ); + + foreach ($directories as $directory) + { + $filepath = $directory.'/'.$filename; + + if (file_exists($filepath)) + { + return $filepath; + } + } + + return false; +} ?>
\ No newline at end of file |