Image of i18n in JSF2

I am trying to localize images in JSF and I want the user to be able to set their locale on my site. This I do on call

FacesContext.getCurrentInstance().getViewRoot().setLocale(_locale);

which works great, with one exception:

<h:graphicImage library="images" name="pic.gif" />

uses Accept-Languagesent in a browser request to determine which language to use. I can get around this by placing a locale string in each file .propertiesand referencing the images

<h:graphicImage library="#{resource.locale}/images" name="pic.gif" />

but then there are no separate calls to individual images, so I must have a copy of each image, regardless of whether it is different or not, in each directory of locales. This is rather cumbersome given that I support 9 locales and probably more in the future. Any advice would be highly appreciated.

+5
1

. , JSF Java EE. Servlet, , , :

if (getServletContext().getResource(request.getPathInfo()) == null) {
    // Display fallback image instead.
}

JSF, .

+2

All Articles