You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to port the i18n engine I wrote for tomcat/JSP (15 years ago) to EJS.
The implementation is pretty simple.
Right now a common way to add translation is to use code like that:
<%=__('TRANSLATION_KEY {1} AND {2}', variable1, variable2)%>
// or
<%-__('TRANSLATION_KEY {1} AND {2}', variable1, variable2)%>
the start tag is 7 char long (can be reduced to 6 with a single-letter translate function)
the ending tag is 3 char long
With my i18n style the same code will be converted to:
<%=`TRANSLATION_KEY ${variable1} AND ${variable2}`%>
// or
<%-`TRANSLATION_KEY ${variable1} AND ${variable2}`%>
the start tag is 4 char long
the ending tag is 3 char long
This version is much shorter and uses Template literals.
under the hood, a context variable should contain:
the lang.
the translate function.
A default empty translation function can be added by default, so all previous code will still be compatible.
In the first place, I was thinking about supporting a new tag <%`TEXT ${var}`%> but I do not know if the content should be protected or not by default.
Please give me some feedback.
The text was updated successfully, but these errors were encountered:
Hi,
I would like to port the i18n engine I wrote for tomcat/JSP (15 years ago) to EJS.
The implementation is pretty simple.
Right now a common way to add translation is to use code like that:
the start tag is 7 char long (can be reduced to 6 with a single-letter translate function)
the ending tag is 3 char long
With my i18n style the same code will be converted to:
the start tag is 4 char long
the ending tag is 3 char long
This version is much shorter and uses Template literals.
under the hood, a context variable should contain:
A default empty translation function can be added by default, so all previous code will still be compatible.
In the first place, I was thinking about supporting a new tag
<%`TEXT ${var}`%>
but I do not know if the content should be protected or not by default.Please give me some feedback.
The text was updated successfully, but these errors were encountered: