title: Different facelets (for use in templates) in JSF 2 per locale
body: <p>I have a template somewhere that has <code>&lt;ui:insert name="help_contents" /&gt;</code> and a page that defines <code>&lt;ui:define name="help_contents&gt;&lt;!-- actual contents --&gt;&lt;/ui:define&gt;</code>, where the contents in the definition should be JSF-based (not just plain html/xhtml), handled by the faces servlet and differing based on locale. But I don't want to do this with resource bundles, since that would require large swathes of text per property and having to break it up for every component that's interspersed with the text. In other words, I want a facelet per locale, and then include the right one based on the active locale.</p>
  
  <p>That's basically the question. Context below for the sake of others who are searching, skip if you already understand what I mean.</p>
  
  <p>Internationalization in JSF 2 is, for the most part, very easy. You make one or more resource bundles, declare those in your faces-config.xml and you're ready to use the properties. But such properties files are to my feeling only good for short label texts, column headers, small messages with maybe a couple of parameters in  them... When it comes to large portions of text, they seem unwieldy. Especially if the text should be interspersed with XHTML tags or JSF components, in which case you'd need to break it up far too much.</p>
  
  <p>Currently I'm working on some web application that uses JSF 2, with PrimeFaces as component bundle, which uses resource bundles for i18n in the regular sense. But various views need a help page. I'd like to use JSF/PrimeFaces components in those help pages as well, so that examples of populated tables or dialogs look the same as in the view itself.</p>
  
  <p>However, including composition content based on locale appears to be less straightforward than I thought. I'd like to have XHTML pages (facelets) with locale suffixes like _en or _fr and select the right page based on the active locale. If no such page exists, it should default to the _en page (or one without a suffix that just includes the English content). Getting the locale string from the facescontext isn't a problem, but detecting whether a page exists seems harder. Is there some way to do this in JSF or via the EL, or should this be done through a managed bean? Maybe it could be useful to write a custom tag for this, but I'm not sure how much work this entails.</p>
  
  <p>I did find <a href="https://stackoverflow.com/questions/6497886/correct-way-to-do-internationalization-in-jsf-for-full-html-pages">this related question</a>, but that only seems useful if I wan't to inject pure HTML content. I'd like to include pages with JSF content so they're actually handled and rendered by the JSF servlet.</p>