Note that there are some explanatory texts on larger screens.

plurals
  1. POFile-less resource bundle for images in Java?
    primarykey
    data
    text
    <p>I have a Java (JSF) web application that needs to be localized, including text, images and etc (numbers, dates). I'm trying to have programmers to only use </p> <pre><code>&lt;h:graphicImage value="#{images['i_print.png']}" ... /&gt; </code></pre> <p>... and have the correct localized image automatically picked in the background, according to the user's locale.</p> <p>One approach is to have resource bundles property files with different image paths for a certain image key. Is there a way this can be done without property files at all?</p> <p>I mean.. the images directory having the following structure:</p> <pre><code>-Images --en ---en_US ---en_CA --fr ---fr_FR </code></pre> <p>Is it possible to create resource bundles where the lookup would go through the most localized directory first and going up the tree until the image name is found? </p> <p>So far I have the following:</p> <p>(1) An images handler.</p> <pre><code>&lt;resource-bundle&gt; &lt;base-name&gt;com.example.ImageResourcesHandler&lt;/base-name&gt; &lt;var&gt;images&lt;/var&gt; &lt;/resource-bundle&gt; </code></pre> <p>(2) The handler implementation, which extends resource bundle and handles the call by overriding getObject</p> <pre><code>public class ImageResourcesHandler extends ResourceBundle { @Override protected Object handleGetObject(String key) {...} } </code></pre> <p>(3) An Images Control that extends ResourceBundle.Control and is supposed to the the BundleLoading and control</p> <pre><code>public class ImageControl extends ResourceBundle.Control { ... } </code></pre> <p>Right now I go through the images root directory and create a map with the names of images as the key and their path as values. </p> <p>The problem is I don't have a Bundle structure, meaning that if I have the key in two different locales, my map clearly doesn't work (two+ paths are mapped to the same key).</p> <p>Do you have any ideas on how to accomplish this? I wouldn't like to maintain properties files.</p> <p><strong>TL;DR:</strong> I would like to implement a mechanism that gets images according to the user's locale from the file system without using properties files.</p> <p>Any ideas are highly appreciated. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload