Move rendering into private templates
Add an explicit template renderer with HTML views and partials for the app, bootstrap, package, and catalog pages. Move shared reporting setup into config/reporting.php and relocate stylesheet assets under css/.
This commit is contained in:
@@ -79,6 +79,43 @@ class LanguageStore
|
||||
return $fallback !== null ? (string)$fallback : $key;
|
||||
}
|
||||
|
||||
public function translateFormat($key, $language, $values = array(), $fallback = null)
|
||||
{
|
||||
return self::formatText($this->translate($key, $language, $fallback), $values);
|
||||
}
|
||||
|
||||
public static function formatText($text, $values, $maxDepth = 8)
|
||||
{
|
||||
if (!is_array($values) || count($values) === 0) {
|
||||
return (string)$text;
|
||||
}
|
||||
|
||||
$text = (string)$text;
|
||||
|
||||
for ($depth = 0; $depth < $maxDepth; $depth++) {
|
||||
$changed = false;
|
||||
|
||||
$next = preg_replace_callback('/\{\{\s*([A-Za-z0-9_.-]+)\s*\}\}/', function ($match) use ($values, &$changed) {
|
||||
$name = $match[1];
|
||||
|
||||
if (!array_key_exists($name, $values)) {
|
||||
return $match[0];
|
||||
}
|
||||
|
||||
$changed = true;
|
||||
return (string)$values[$name];
|
||||
}, $text);
|
||||
|
||||
$text = $next;
|
||||
|
||||
if (!$changed) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function setTranslation($key, $language, $text)
|
||||
{
|
||||
$key = $this->safeKey($key);
|
||||
|
||||
Reference in New Issue
Block a user