diff options
author | Simon Rettberg | 2014-09-02 18:29:15 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-09-02 18:29:15 +0200 |
commit | 123be7629fda9733626ef41af2bdedc1215ec5ef (patch) | |
tree | 531dd4cd82cefaeb8ec0f69b6e22e94234b6a17f /inc/render.inc.php | |
parent | Fix display glitches (diff) | |
download | slx-admin-123be7629fda9733626ef41af2bdedc1215ec5ef.tar.gz slx-admin-123be7629fda9733626ef41af2bdedc1215ec5ef.tar.xz slx-admin-123be7629fda9733626ef41af2bdedc1215ec5ef.zip |
[Render] Show untranslated tags in rendered output
Diffstat (limited to 'inc/render.inc.php')
-rw-r--r-- | inc/render.inc.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/inc/render.inc.php b/inc/render.inc.php index 0b891c80..fc64203e 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -160,13 +160,29 @@ class Render /** * Parse template with given params and return; do not add to body + * @param string $template name of template, relative to templates/, without .html extension + * @return string Rendered template */ public static function parse($template, $params = false) { + // Get all translated strings for this template $dictionary = Dictionary::getArrayTemplate($template); + // Load html snippet + $html = self::getTemplate($template); + // Now find all language tags in this array + preg_match_all('/{{(lang_.+?)}}/', $html, $out); + foreach ($out[1] as $tag) { + // Add untranslated strings to the dictionary, so their tag is seen in the rendered page + if (empty($dictionary[$tag])) + $dictionary[$tag] = '{{' . $tag . '}}'; + } + // Always add token to parameter list if (is_array($params) || $params === false || is_null($params)) $params['token'] = Session::get('token'); - return self::$mustache->render(self::getTemplate($template), array_merge($dictionary,$params)); + // Likewise, add currently selected language ( its two letter code) to params + $params['current_lang'] = LANG; + // Return rendered html + return self::$mustache->render($html, array_merge($dictionary,$params)); } /** |