From 15e31f67103ee7389fa8ab295875a1064a12a028 Mon Sep 17 00:00:00 2001 From: Yaco Date: Mon, 27 Jan 2020 21:37:41 -0300 Subject: hace que cuando se selecciona un idioma no soportado, se muestra el idioma por defecto de la wiki --- .../extensions/LanguageTag/LanguageTag.body.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/www/wiki/extensions/LanguageTag/LanguageTag.body.php b/www/wiki/extensions/LanguageTag/LanguageTag.body.php index 38023174..188f0b61 100644 --- a/www/wiki/extensions/LanguageTag/LanguageTag.body.php +++ b/www/wiki/extensions/LanguageTag/LanguageTag.body.php @@ -20,9 +20,24 @@ class LanguageTag public static function LanguageTagParserInit( Parser $parser ) { // at runtime TagLanguages is in the global scope global $wgLanguageTagLanguages; + global $wgLang; + global $DefaultLang; + global $wgLanguageCode; + + if ( $wgLanguageTagLanguages === null ) return true; // Nothing to do + + if (!in_array($wgLang->getCode(), $wgLanguageTagLanguages)) { + error_log('Idioma actual es: ' . $wgLang->getCode() . ' y NO esta soportado'); + $DefaultLang = $wgLanguageCode; + // $parser->setHook( 'es', 'LanguageTag::LanguageTagRender_es' ); + // return true; + } + foreach ($wgLanguageTagLanguages as $Tag) $parser->setHook( $Tag, 'LanguageTag::LanguageTagRender_'.$Tag ); + + unset($Tag); // theoretically nothing to return or fail. return true; @@ -31,12 +46,22 @@ class LanguageTag // This function is helpful in checking against the passed Language public static function LanguageTagCheck($input, $lang) { + global $DefaultLang; + // $output= htmlspecialchars($input); // Hacemos este cambio para poder meter código HTML en las paginas traducidas $output = $input; global $wgLang; + // error_log("Voy a preocesar: $lang"); + // error_log('Idioma seleccionado es: ' . $wgLang->getCode() . ' y el idioma procesado es ' . $lang); + error_log("El valor de DefaultLang es: $DefaultLang"); + + if ($DefaultLang===$lang) { + error_log('Idioma actual es: ' . $wgLang->getCode() . ' y NO esta soportado y entonces deberia hacer algo'); + return $output; + } if ( $wgLang->getCode()===$lang ) { // Match. The Language (set by LanguageSelector) is equal to the language tag. return $output; @@ -50,6 +75,7 @@ class LanguageTag // LanguageTagRender_ this is 18 characters, we get the language code from the function's name, and access everything else passed in via $arguments public static function __callStatic($name, $arguments) { + error_log("Voy a preocesar: $name"); return $arguments[2]->recursiveTagParse( LanguageTag::LanguageTagCheck($arguments[0], substr($name,18)), $arguments[3] ); } -- cgit v1.2.1