vendredi 13 février 2015

Pattern to internationalize links in JSF

I want to internationalize the following content:



Click here to view our privacy policy.



here is a hyperlink. Here is how I currently go about it:



#{msg.footer_privacyPolicy1}
<h:outputLink>
#{msg.footer_privacyPolicy2}
</h:outputLink>
#{msg.footer_privacyPolicy3}


msg is a ResourceBundle registered in faces-config.xml, with the following contents:



footer_privacyPolicy1 = Click
footer_privacyPolicy2 = here
footer_privacyPolicy3 = to view our privacy policy.




I think there must be a better pattern to achieving this. Here is what I don't like about my approach:



  • Flexibility in actual internationalization is lost, because I am constraining the semantic order of the sentence. For example, maybe in certain languages, the imperative to "click" should go at the end of the sentence - but this would not be possible in my approach.

  • The mechanics of the presentation (i.e. the hyperlink) are getting mixed into the content. If I later remove the hyperlink, or use a somehow different hyperlink control, the property files would need to change as well.


Is there a better approach to internationalizing content that is necessarily partitioned by the mechanics of presentation markup?


Aucun commentaire:

Enregistrer un commentaire