Skip to content

Commit

Permalink
luci-base: handle missing translations in template engine
Browse files Browse the repository at this point in the history
Previously the template engine did not interpolate translation macros if no
translation catalogue could be loaded due to a missing i18n directory.

Change the offending code to return the original string in any error case.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
  • Loading branch information
jow- committed Jan 10, 2015
1 parent 1380c7b commit 9a81d8f
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions modules/luci-base/src/template_utils.c
Expand Up @@ -477,18 +477,8 @@ void luastr_translate(struct template_buffer *out, const char *s, unsigned int l
char *tr;
int trlen;

switch (lmo_translate(s, l, &tr, &trlen))
{
case 0:
luastr_escape(out, tr, trlen, escape_xml);
break;

case -1:
luastr_escape(out, s, l, escape_xml);
break;

default:
/* no catalog loaded */
break;
}
if (!lmo_translate(s, l, &tr, &trlen))
luastr_escape(out, tr, trlen, escape_xml);
else
luastr_escape(out, s, l, escape_xml);
}

0 comments on commit 9a81d8f

Please sign in to comment.