On 4/13/05, Ashish Kulkarni <[EMAIL PROTECTED]> wrote: > Hi > How to find out which language property files are > availble in a web project, for example i have > test.properties, test_fr_FR.properties, > test_ru.properties file in WEB-INF\classes folder, how > to identify on the fly what languages property files > are availble and then display it in a jsp so the user > can select the language he wants to see the web site >
I don't know of any quick-and-easy way to do this (unless you are using JSF, where you declare the supported locales explicitly in a faces-config.xml file). But here's a brute force strategy that should work, if you are on a Servlet 2.3 or later container. * Call ServletContext.getResourcePaths("/WEB-INF/classes"), which returns you a set of context relative paths to all the files under your /WEB-INF/classes subdirectory. * Scan down this list and match the ones that are related to your resource bundle (i.e. things that match "*/text*.properties") to build your list of available locales. * If you have properties files in JARs under /WEB-INF lib, you can use ServletContext.getResourcePaths() again to get paths to all the JAR files. Then, you can use the utility classes in java.util.jar to scan the table of contents of each JAR file and (again) match the names to an appropriate pattern. > Ashish Craig --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]