From e8ec13b9a448dc4c0be4aa459d1586165aed6044 Mon Sep 17 00:00:00 2001 From: Klap-in Date: Fri, 2 Aug 2013 13:38:31 +0200 Subject: localized texts for templates --- inc/template.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'inc') diff --git a/inc/template.php b/inc/template.php index bb5f2cd53..33b886927 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1192,6 +1192,39 @@ function tpl_getLang($id) { return $lang[$id]; } +/** + * locale_xhtml($id) + * + * retrieve a language dependent file and pass to xhtml renderer for display + * template equivalent of p_locale_xhtml() + * + * @param string $id id of language dependent wiki page + * @return string parsed contents of the wiki page in xhtml format + */ +function tpl_locale_xhtml($id) { + return p_cached_output(tpl_localFN($id)); +} + +/** + * localFN($id) + * + * prepends appropriate path for a language dependent filename + * template equivalent of localFN() + */ +function tpl_localFN($id) { + $path = tpl_incdir().'lang/'; + global $conf; + $file = DOKU_CONF.'/template_lang/'.$conf['template'].'/'.$conf['lang'].'/'.$id.'.txt'; + if (!@file_exists($file)){ + $file = $path.$conf['lang'].'/'.$id.'.txt'; + if(!@file_exists($file)){ + //fall back to english + $file = $path.'en/'.$id.'.txt'; + } + } + return $file; +} + /** * prints the "main content" in the mediamanger popup * -- cgit v1.2.3 From c5c17fdaa1af326a3f0c68695cb93575a3af2e5e Mon Sep 17 00:00:00 2001 From: Klap-in Date: Fri, 2 Aug 2013 19:06:29 +0200 Subject: improve method name and phpdocs --- inc/template.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'inc') diff --git a/inc/template.php b/inc/template.php index 33b886927..6af0535c9 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1193,25 +1193,20 @@ function tpl_getLang($id) { } /** - * locale_xhtml($id) - * - * retrieve a language dependent file and pass to xhtml renderer for display + * Retrieve a language dependent file and pass to xhtml renderer for display * template equivalent of p_locale_xhtml() * * @param string $id id of language dependent wiki page * @return string parsed contents of the wiki page in xhtml format */ function tpl_locale_xhtml($id) { - return p_cached_output(tpl_localFN($id)); + return p_cached_output(tpl_localeFN($id)); } /** - * localFN($id) - * - * prepends appropriate path for a language dependent filename - * template equivalent of localFN() + * Prepends appropriate path for a language dependent filename */ -function tpl_localFN($id) { +function tpl_localeFN($id) { $path = tpl_incdir().'lang/'; global $conf; $file = DOKU_CONF.'/template_lang/'.$conf['template'].'/'.$conf['lang'].'/'.$id.'.txt'; -- cgit v1.2.3