GWT SafeHtmlTemplate Internationalization -
i'm in process of internationalizing gwt app , have several safehtmltemplate i'm using i'm not sure how translate. there convenient way translate these while still using safehtmltemplate
approach? otherwise, pass in names of days of week template , translate them using constants
usual?
@template("<table>" + "<tr><td>sunday:</td>{6}</tr>" + "<tr><td>monday:</td>{0}</tr>" + "<tr><td>tuesday:</td>{1}</tr>" + "<tr><td>wednesday:</td>{2}</tr>" + "<tr><td>thursday:</td>{3}</tr>" + "<tr><td>friday:</td>{4}</tr>" + "<tr><td>saturday:</td>{5}</tr>" + "</table>") safehtml hourshtml(safehtml mon, safehtml tue, safehtml wed, safehtml thu, safehtml fri, safehtml sat, safehtml sun);
since there's no way use constants
object inside template uibinder
template, i'd approach of getting translated strings outside template , passing them parameters next easier option.
moreover, it's mentioned time , again through gwt's safehtml
documentation strings used build safehtml
objects must determined @ compile time:
public interface safehtmltemplates
tag interface facilitates compile-time binding of html templates generate safehtml strings.
public static safehtml fromsafeconstant(java.lang.string s)
returns safehtml constructed safe string, i.e., without escaping string.
important: method able honor safehtml contract, uses of method must satisfy following constraints:
1. argument expression must determined @ compile time.
2. value of argument must end in "inner html" context , not contain incomplete html tags.
the use of constants
inside safehtml
templates might interfere rule.
1 argue constants supposedly inlined, , internationalized permutations of code generated @ compile time already, should relatively easy overcome restrictions when using constants inside templates; again, google might have implemented in way doesn't allow safe mixing of both mechanisms, hence limitation.
so passing translated strings parameters (probably) way go.
Comments
Post a Comment