title: How to use JSF tags in resource bundles / How to rewrite URLs in a resource bundle?
body: <p>Enviornment: 
  JSF 2.1.7
  SEAM 2.3.0
  JBOSS 5.1.2</p>
  
  <p>My application has a string that needs to be localized</p>
  
  <blockquote>
    <p>"I agree to WorldSite's <em>Privacy Policy</em> and <em>Cookie Notice</em>"</p>
  </blockquote>
  
  <p>Where the italicized <em>Privacy Policy</em> and <em>Cookie Notice</em> are hyperlinks to other pages.</p>
  
  <p>Originally our facelet was set up like this:</p>
  
  <pre><code>&lt;h:outputText value="#{messages['iAgreeTo']}" /&gt;
  &lt;h:outputLink target="_blank" value="#{bean.privacyPolicy}"&gt;#{messages['privacyPolicy']}&lt;/h:outputLink&gt;
  &lt;h:outputText value="#{messages['and']}"/&gt;
  &lt;h:outputLink target="_blank" value="/jsf/Notice.xhtml"&gt;
      &lt;h:outputText value="#{messages['cookieNotice']}"/&gt;
      &lt;f:param name="content" value="Cookie-Notice"/&gt;
      &lt;f:param name="application" value="#{bean.application}"/&gt;
  &lt;/h:outputLink&gt;
  </code></pre>
  
  <p>Note: We have URL rewriting in place that takes /jsf/Notice.xhtml and rewrites to</p>
  
  <pre><code>rewrite pattern: /#{application}/Notice/#{content}
  result:http://contextRoot/contextPath/myApp/Notice/Cookie-Notice
  </code></pre>
  
  <p>This allowed for piecemeal translations of the individual keys </p>
  
  <pre><code>iAgreeTo=I agree to WorldSite's&amp;#160;
  privacyPolicy=Privacy Policy
  and=&amp;#160;and&amp;#160;
  cookieNotice=Cookie Notice
  </code></pre>
  
  <p>But this required a workaround for some languages (in "iAgreeTo" and "and" keys)</p>
  
  <pre><code>iAgreeTo=J'accepte la&amp;#160;
  privacyPolicy=Politique de la vie privée
  and=&amp;#160;de WorldSite et les&amp;#160;
  cookieNotice=Note D'information sur les Cookies
  </code></pre>
  
  <p><strong>Ideally I would like to be able to have the links be movable within the key. Something like this:</strong></p>
  
  <pre><code>iAgreePhrase=I agree to WorldSite's #{messages['privacyPolicyLink']} and the #{messages['cookieNoticeLink']}
  privacyPolicy=Privacy Policy
  cookieNotice=Cookie Notice
  
  //The following non-translatable keys held in a separate file
  privacyPolicyLink=&lt;h:outputLink target="_blank" value="#{bean.privacyPolicy}"&gt;#{messages['privacyPolicy']}&lt;/h:outputLink&gt;
  cookieNoticeLink=&lt;h:outputLink target="_blank" id="cookieNoticeLink" value="/jsf/Notice.xhtml"&gt;\
      #{messages['cookieNotice']}\
      &lt;f:param name="content" value="Cookie-Notice"/&gt;\
      &lt;f:param name="application" value="#{bean.application}"/&gt;\
  &lt;/h:outputLink&gt;
  </code></pre>
  
  <p>But the facelet returns the JSF tags (h:outputLink) as strings instead of expanding them to their HTML tags. <strong>I can use <code>&lt;a&gt;</code> tags, but then I'm putting rewrite logic in the properties file which is difficult to maintain</strong></p>
  
  <pre><code>iAgreePhrase=I agree to WorldSite's #{messages['privacyPolicyLink']} and the #{messages['cookieNoticeLink']}
  privacyPolicy=Privacy Policy
  cookieNotice=Cookie Notice
  
  //The following non-translatable keys held in a separate file
  privacyPolicyLink=&lt;a target="_blank" href="#{bean.privacyPolicy}"&gt;#{messages['privacyPolicy']}&lt;/a&gt;
  cookieNoticeLink=&lt;a target="_blank" href="#{contextPath}/#{bean.application}/Notice/Terms-and-Conditions"&gt;\
      #{messages['cookieNotice']}&lt;/a&gt;
  </code></pre>
  
  <p>Is there a way I can achieve my desired effect without having to put rewrite logic in the resource bundle? Some thoughts I have are forcing the application container to process the facelet twice/reorder it, so it inserts the resource bundles first, and then expands the JSF tags.</p>
  
  <p>Alternatively I may be able to construct the rewritten URL in a bean then call that from my resource bundle?</p>