Commit bbbd6211f33b41588aeb72b2cfc0ed35cfaec0b9
1 parent
30453465
Grab language to use from a cookie, and implement _kt using the internal
i18n infrastructure. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5141 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
15 additions
and
31 deletions
config/dmsDefaults.php
| @@ -120,30 +120,16 @@ class KTInit { | @@ -120,30 +120,16 @@ class KTInit { | ||
| 120 | 120 | ||
| 121 | // {{{ setupI18n() | 121 | // {{{ setupI18n() |
| 122 | /** | 122 | /** |
| 123 | - * setupI | 123 | + * setupI18n |
| 124 | * | 124 | * |
| 125 | */ | 125 | */ |
| 126 | function setupI18n () { | 126 | function setupI18n () { |
| 127 | require_once(KT_LIB_DIR . '/i18n/i18nutil.inc.php'); | 127 | require_once(KT_LIB_DIR . '/i18n/i18nutil.inc.php'); |
| 128 | require_once("HTTP.php"); | 128 | require_once("HTTP.php"); |
| 129 | global $default; | 129 | global $default; |
| 130 | - if (in_array("gettext", get_loaded_extensions()) && function_exists('gettext') && function_exists('_')) { | ||
| 131 | - if ($default->useAcceptLanguageHeader) { | ||
| 132 | - $aInstalledLocales = KTi18nUtil::getInstalledLocales(); | ||
| 133 | - $sLocale = $aInstalledLocales[HTTP::negotiateLanguage($aInstalledLocales)]; | ||
| 134 | - $default->defaultLanguage = $sLocale; | ||
| 135 | - } | ||
| 136 | - putenv('LANG=' . $default->defaultLanguage); | ||
| 137 | - putenv('LANGUAGE=' . $default->defaultLanguage); | ||
| 138 | - setlocale(LC_ALL, $default->defaultLanguage); | ||
| 139 | - // Set the text domain | ||
| 140 | - $sDomain = 'knowledgeTree'; | ||
| 141 | - bindtextdomain($sDomain, $default->fileSystemRoot . "/i18n"); | ||
| 142 | - textdomain($sDomain); | ||
| 143 | - return true; | ||
| 144 | - } else { | ||
| 145 | - return false; | ||
| 146 | - $default->log->info("Gettext not installed, i18n disabled."); | 130 | + $language = KTUtil::arrayGet($_COOKIE, 'kt_language'); |
| 131 | + if ($language) { | ||
| 132 | + $default->defaultLanguage = $language; | ||
| 147 | } | 133 | } |
| 148 | } | 134 | } |
| 149 | // }}} | 135 | // }}} |
| @@ -467,13 +453,6 @@ class KTInit { | @@ -467,13 +453,6 @@ class KTInit { | ||
| 467 | 453 | ||
| 468 | $KTInit = new KTInit(); | 454 | $KTInit = new KTInit(); |
| 469 | 455 | ||
| 470 | -// handle unexpected errors in smarty somewhat more gracefully, even if no gettext is installed. | ||
| 471 | -if (!function_exists('_')) { | ||
| 472 | - function _kt($s) { return $s; } | ||
| 473 | -} else { | ||
| 474 | - function _kt($s) { return _($s); } | ||
| 475 | -} | ||
| 476 | - | ||
| 477 | $KTInit->prependPath(KT_DIR . '/thirdparty/pear'); | 456 | $KTInit->prependPath(KT_DIR . '/thirdparty/pear'); |
| 478 | $KTInit->prependPath(KT_DIR . '/thirdparty/Smarty'); | 457 | $KTInit->prependPath(KT_DIR . '/thirdparty/Smarty'); |
| 479 | require_once('PEAR.php'); | 458 | require_once('PEAR.php'); |
| @@ -487,6 +466,9 @@ require_once(KT_LIB_DIR . '/util/ktutil.inc'); | @@ -487,6 +466,9 @@ require_once(KT_LIB_DIR . '/util/ktutil.inc'); | ||
| 487 | require_once(KT_LIB_DIR . "/config/config.inc.php"); | 466 | require_once(KT_LIB_DIR . "/config/config.inc.php"); |
| 488 | 467 | ||
| 489 | $KTInit->initConfig(); | 468 | $KTInit->initConfig(); |
| 469 | + | ||
| 470 | +$KTInit->setupI18n(); | ||
| 471 | + | ||
| 490 | $oKTConfig =& KTConfig::getSingleton(); | 472 | $oKTConfig =& KTConfig::getSingleton(); |
| 491 | $KTInit->setupServerVariables(); | 473 | $KTInit->setupServerVariables(); |
| 492 | 474 | ||
| @@ -506,13 +488,7 @@ require_once(KT_LIB_DIR . '/database/lookup.inc'); | @@ -506,13 +488,7 @@ require_once(KT_LIB_DIR . '/database/lookup.inc'); | ||
| 506 | // table mapping entries | 488 | // table mapping entries |
| 507 | include("tableMappings.inc"); | 489 | include("tableMappings.inc"); |
| 508 | 490 | ||
| 509 | -$i18nLoaded = $KTInit->setupI18n(); | ||
| 510 | -if ($i18nLoaded === false) { | ||
| 511 | - // gettext dummy already loaded. | ||
| 512 | -} | ||
| 513 | - | ||
| 514 | $default->systemVersion = trim(file_get_contents(KT_DIR . '/docs/VERSION.txt')); | 491 | $default->systemVersion = trim(file_get_contents(KT_DIR . '/docs/VERSION.txt')); |
| 515 | -$default->lastDatebaseVersion = '2.0.2'; | ||
| 516 | 492 | ||
| 517 | $KTInit->cleanGlobals(); | 493 | $KTInit->cleanGlobals(); |
| 518 | $KTInit->cleanMagicQuotes(); | 494 | $KTInit->cleanMagicQuotes(); |
| @@ -529,4 +505,6 @@ if ($checkup !== true) { | @@ -529,4 +505,6 @@ if ($checkup !== true) { | ||
| 529 | KTPluginUtil::loadPlugins(); | 505 | KTPluginUtil::loadPlugins(); |
| 530 | } | 506 | } |
| 531 | 507 | ||
| 508 | +$GLOBALS['main'] =& new KTPage(); | ||
| 509 | + | ||
| 532 | ?> | 510 | ?> |
lib/i18n/i18nutil.inc.php
| @@ -58,3 +58,9 @@ class KTi18nUtil { | @@ -58,3 +58,9 @@ class KTi18nUtil { | ||
| 58 | return $aLocales; | 58 | return $aLocales; |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| 61 | + | ||
| 62 | +function _kt($sContents) { | ||
| 63 | + $oReg =& KTi18nRegistry::getSingleton(); | ||
| 64 | + $oi18n =& $oReg->geti18n('knowledgeTree'); | ||
| 65 | + return $oi18n->gettext($sContents); | ||
| 66 | +} |