diff --git a/_config.php b/_config.php index c8e8e6721..fcaf95fd8 100644 --- a/_config.php +++ b/_config.php @@ -62,7 +62,7 @@ Authenticator::registerAuthenticator('OpenIDAuthenticator'); /** * Define a default language different than english */ -//LocaleAPI::set_locale('ca_AD'); +//i18n::set_locale('ca_AD'); define('MCE_ROOT', 'jsparty/tiny_mce2/'); diff --git a/core/Core.php b/core/Core.php index 32f97836a..f0092119c 100755 --- a/core/Core.php +++ b/core/Core.php @@ -83,6 +83,13 @@ function stripslashes_recursively(&$array) { } } +/** + * Priorities definition. These constants are used in calls to _t() as an optional argument + */ +define('PR_HIGH',100); +define('PR_MEDIUM',50); +define('PR_LOW',10); + /** * This is the main translator function. Returns the string defined by $class and $entity according to the currently set locale * diff --git a/core/ManifestBuilder.php b/core/ManifestBuilder.php index 5f91bdd3e..1f1e84cf4 100644 --- a/core/ManifestBuilder.php +++ b/core/ManifestBuilder.php @@ -184,6 +184,9 @@ class ManifestBuilder { // ignore certain directories if(is_dir("$folder/$item") && in_array($item, self::$ignore_folders)) continue; + + // i18n: ignore language files (loaded on demand) + if($item == 'lang' && is_dir("$folder/$item") && ereg_replace("/[^/]+/\\.\\.","",$folder.'/..') == Director::baseFolder()) continue; if(is_dir("$folder/$item")) { // recurse into directories (if not in $ignore_folders) diff --git a/core/SSViewer.php b/core/SSViewer.php index 44355236d..9f02841e3 100644 --- a/core/SSViewer.php +++ b/core/SSViewer.php @@ -154,7 +154,7 @@ class SSViewer extends Object { if(isset($_GET['debug_profile'])) Profiler::mark("SSViewer::process - compile", " for $template"); $content = file_get_contents($template); - $content = SSViewer::parseTemplateContent($content); + $content = SSViewer::parseTemplateContent($content, $template); $fh = fopen($cacheFile,'w'); fwrite($fh, $content); @@ -186,7 +186,7 @@ class SSViewer extends Object { $itemStack = array(); $val = ""; - + include($cacheFile); $output = $val; @@ -199,7 +199,7 @@ class SSViewer extends Object { return $output; } - static function parseTemplateContent($content) { + static function parseTemplateContent($content, $template="") { while(true) { $oldContent = $content; $content = preg_replace_callback('/<' . '% include +([A-Za-z0-9_]+) +%' . '>/', create_function( @@ -282,7 +282,8 @@ class SSViewer extends Object { $content = ereg_replace('<' . '% +end_if +%' . '>', '', $content); // i18n - $content = ereg_replace('<' . '% +_t\((([^)]|\)[^;])*)\); +%' . '>', '', $content); + ereg('.*[\/](.*)',$template,$path); + $content = ereg_replace('<' . '% +_t\((\'([^\']*)\'|"([^"]*)")(([^)]|\)[^;])*)\); +%' . '>', '', $content); // isnt valid html? !? $content = ereg_replace('<' . '% +base_tag +%' . '>', '', $content); diff --git a/core/i18n.php b/core/i18n.php index b3e1aa74f..329a48298 100755 --- a/core/i18n.php +++ b/core/i18n.php @@ -6,13 +6,6 @@ * @author Bernat Foj Capell */ -/** - * Priorities definition. These constants are used in calls to _() as an optional argument - */ -define('PR_HIGH',100); -define('PR_MEDIUM',50); -define('PR_LOW',10); - class i18n extends Controller { /** @@ -118,6 +111,7 @@ class i18n extends Controller { if (isset($callMap[$class.'--'.$entity])) echo "Warning! Redeclaring entity $entity in file $file
"; + if (substr($regs[2],0,1) == '"') $regs[2] = addcslashes($regs[2],'\''); $mst .= '$lang[\'en_US\'][\'' . $class . '\'][\'' . $entity . '\'] = '; if ($regs[5]) { $mst .= "array(\n\t'" . substr($regs[2],1,-1) . "',\n\t" . substr($regs[5],1); @@ -148,11 +142,11 @@ class i18n extends Controller { static $callMap; $content = file_get_contents($file); $mst = ''; - while (ereg('_t[[:space:]]*\([[:space:]]*("[^,]*"|\\\'[^,]*\\\')[[:space:]]*,[[:space:]]*("([^"]|\\\")*"|\'([^\']|\\\\\')*\')([[:space:]]*,[[:space:]]*[^,)]*)?([[:space:]]*,[[:space:]]*("([^"]|\\\")*"|\'([^\']|\\\\\')*\'))?[[:space:]]*\)',$content,$regs)) { + while (ereg('_t[[:space:]]*\([[:space:]]*("[^"]*"|\\\'[^\']*\\\')[[:space:]]*,[[:space:]]*("([^"]|\\\")*"|\'([^\']|\\\\\')*\')([[:space:]]*,[[:space:]]*[^,)]*)?([[:space:]]*,[[:space:]]*("([^"]|\\\")*"|\'([^\']|\\\\\')*\'))?[[:space:]]*\)',$content,$regs)) { $entityParts = explode('.',substr($regs[1],1,-1)); $entity = array_pop($entityParts); - + // Entity redeclaration check if (isset($callMap[$index.'--'.$entity])) echo "Warning! Redeclaring entity $entity in file $file
"; @@ -165,7 +159,7 @@ class i18n extends Controller { $mst .= ",\n\t'" . substr($regs[6],2,-1) . '\''; } $mst .= "\n);"; - } else $mst .= '\'' . substr($regs[2],2,-1) . '\';'; + } else $mst .= '\'' . substr($regs[2],1,-1) . '\';'; $mst .= "\n"; $content = str_replace($regs[0],"",$content);