views:

217

answers:

1

Hi, I'm adding Internationalization to a tapestry app.

Is there a standard tapestry-3 technique to Internationalize strings that appear as Javascript literals?

For example:

<input jwcid="submitBtn" type="submit" accesskey="U" value="Update" class="actionBtn" onclick="return confirm('Are you sure that you want to do that?');"/></td>

Can I simply replace the question with a tapestry tag in this and any other context? Say something like:

<input jwcid="submitBtn" type="submit" accesskey="U" value="Update" class="actionBtn" onclick="return confirm('<span key="AreYouSure">Are you sure that you want to do that?</span>');"/></td>

This means that the source file contains an element inside an attribute which would be fine inside a JSP. Does tapestry-3 handle this? If not, is there a way to do this in tapestry-3?

+1  A: 

This works fine in T3 as well - another option is to initialize your i18n js strings at the top of the page:

<script>
  var jsStrings = { 
    sure : '<span key="AreYouSure"/>',
    ...
  };
</script>

and then just use them:

<input jwcid="submitBtn" onclick="return confirm(jsStrings.sure);"/>
Andreas Andreou
Thanks, that looks like the best way to go.
Adrian Pronk