<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi all,<div><br></div><div>Eric Wittmann has volunteered to implement proof-of-concept internationalization features in ErraiUI. To get things going, he asked me to sum up the conversation we had on a GitHub pull request[1]. Here's my summary, as I understand it.</div><div><br></div><div>Goals:</div><div>&nbsp;* Must not compromise on 'designer templates:' the template must be 100% valid HTML5 and render properly in a browser as-is.</div><div>&nbsp;* Aim for least possible amount of boilerplate in the common case: if I18N is invisible on 80% of the fields it affects (both Java side and HTML side) then we're winning.</div><div>&nbsp;* At compile time, we'll generate reports on the state of each translation: for each language, which translations are missing and which are orphaned? If this is summarized numerically in a .properties file, it's trivially easy to track in Jenkins with the Plot plugin[2].</div><div>&nbsp;* Must be able to substitute different images based on user's language</div><div>&nbsp;* Ability to translate both text within an element as well as attribute values in tags</div><div>&nbsp;* Should accommodate simple HTML markup within messages (eg. anything SafeHtml would allow)</div><div>&nbsp;* Support user selection of language independent of what the accept-language header says</div><div><br></div><div>Non-Goals:</div><div>&nbsp;* We're not attempting to define something that works outside of Errai UI templates and @Templated classes</div><div>&nbsp;* We're not considering the ability to define structurally different page layouts based on locale (Android can do this with its resources system)</div><div>&nbsp;* We're not talking about reacting to anything except the user's language preference (again, Android's resource system supports varying resources based on screen size, resolution, language, country, and lots more besides)</div><div><br></div><div>Open Questions:</div><div>&nbsp;* Should we use GWT's message resource file format?</div><div>&nbsp;* When/if we specify a key, should it be in the template file (eg, as a data-i18n="message.key" attrbute) or in the Java class (as an @I18n("message.key") annotation on the @DataField)? ewittmann originally proposed the attribute-in-template approach, and okrasz and w0mbat expressed a preference for that too.</div><div>&nbsp;* How will we handle interpolation into messages (for example&nbsp;<span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 11.818181991577148px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; text-align: left; text-indent: 0px; text-transform: none; white-space: nowrap; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(248, 248, 248); display: inline !important; float: none; ">Hello {name}. Pleased to meet you!)</span>? Most importantly, where do the values come from?</div><div>&nbsp;* (How) do we handle special numeric formatting like&nbsp;$0.00 in the USA vs. 0,00€ in Europe? It seems we may need a mechanism to call out to GWT's number formatting classes</div><div><br></div><div><br></div><div>Based on all that, here's a strawman proposal to get us started (lifted from Eric's comment):</div><div><br></div><div>Java:</div><div><br>@Templated<br>public&nbsp;class&nbsp;MyPage&nbsp;extends&nbsp;Composite&nbsp;{<div>&nbsp;&nbsp;</div>&nbsp; @Inject&nbsp;@DataField("field1")<div>&nbsp; private&nbsp;Label&nbsp;contentBecomesKey;</div><div>&nbsp; &nbsp;</div>&nbsp; @Inject&nbsp;@DataField("field2")&nbsp;@I18n("mypage.description")<div>&nbsp; private&nbsp;Label&nbsp;keySpecifiedInAnnotation;</div><div>&nbsp; &nbsp;</div>&nbsp; @Inject&nbsp;@DataField("field3")&nbsp;@I18n(value="mypage.input",&nbsp;attributes={"placeholder",&nbsp;"title"})<div>&nbsp; private&nbsp;Text&nbsp;inputBoxWithTranslatedTooltipAndPlaceholder;</div><div><br></div><div>&nbsp; // I don't think this will actually work well. It's just here for the sake of argument.</div><div>&nbsp; @I18nParams</div><div>&nbsp; private Map&lt;String, SafeHtml&gt; messageKeys;</div><div>}</div><div><br></div>Template:<br><br>&lt;div&nbsp;data-field="templateId"&gt;<div>&nbsp; &lt;div&nbsp;data-field="field1"&gt;MyHeader&lt;/div&gt;</div><div>&nbsp; &lt;div&nbsp;data-field="field2"&gt;This is a lengthy description that I don't want becoming an i18n key.&lt;/div&gt;</div><div>&nbsp; &lt;input&nbsp;data-field="field3"&nbsp;type="text"&nbsp;name="field3"&nbsp;placeholder="Enter a value here"&nbsp;title="Use this data entry field to enter a valid value..."&nbsp;/&gt;</div></div><div>&nbsp; &lt;div&gt;Innocent Bystander&lt;/div&gt;</div><div>&nbsp; &lt;div data-field="field3"&gt;{name}, you owe {amountOwing}.&lt;/div&gt;<br>&lt;/div&gt;<br><br></div><div>Bundle for Piglatin translation:<br><br>MyHeader=yHeaderMay<br>mypage.description=Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br>mypage.input.placeholder=Value here, you must enter<br>mypage.input.title=This data entry field, use you must...<br>Innocent\ Bystander=Innocentay Ystanderbay<br><br></div><div>So, thoughts?</div><div><br></div><div>-Jonathan</div><div><br></div><div>[1]:&nbsp;<a href="https://github.com/errai/errai/pull/24">https://github.com/errai/errai/pull/24</a></div><div>[2]:&nbsp;<a href="https://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin">https://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin</a></div></body></html>