Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:12:58+00:00 2026-06-10T02:12:58+00:00

I have some resource bundles packaged in my main jar widget_en.properties widget_de.properties I retrieve

  • 0

I have some resource bundles packaged in my main jar

widget_en.properties
widget_de.properties

I retrieve a resource bundle based on my default locale as folows

ResourceBundle.getBundle("widget", Locale.getDefault());

But I want to present the user with a list of available languages supported so that can select a language that may be different to their computers default

But I can’t find a method in ResourceBundle that would list available locales, I don’t want to hardcode a list as I may forget to update it when another resource bundle is added.

EDIT

As I only resource bundles for different language (I dont have country refinements) so I have got generated a list by iterating through all the known language codes and check for each one as a resource.

String[]langs = Locale.getISOLanguages();
for(String lang:langs)
{
      URL rb = ClassLoader.getSystemResource("widget_"+lang+".properties");
      if(rb!=null)
      {
            System.out.println("Found:"+rb.toString());
      }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:12:59+00:00Added an answer on June 10, 2026 at 2:12 am

    I don’t think there is an API for this because new valid locale objects can be created on the fly:

    Locale locale = new Locale("abcd");
    

    without the need to register it somewhere. And then you can use a resource bundle
    widget_abcd.properties without restrictions:

    ResourceBundle resource= ResourceBundle.getBundle("widget", new Locale("abcd"));
    

    From the java.util.Locale API docs:

    Because a Locale object is just an identifier for a region, no
    validity check is performed when you construct a Locale. If you want
    to see whether particular resources are available for the Locale you
    construct, you must query those resources.

    To solve the problem you can still iterate over all files called “widget_” in the resource directory and discover the new added resource bundles.

    Note that Locale.getAvailableLocales() is not 100% sure for the above reason: you might some day define a non standard locale. But if you’ll add only a few standard locales you can use this static method to iterate over the system locales and get the corresponding bundles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some internal application bundles inside my main application bundle (in Resources). After
I have a jar embedded in a bundle that needs to fetch a resource
If I have a Resource bundle property file: A.properties: thekey={0} This is a test
Question in title pretty much sums it up. I have some resource object defined
I have some dirty resource usage records in t_resourcetable which looks like this resNo
I have some thread to write resource and some to read it.But pthread_rwlock cause
I have been trying to find some resource on this topic for a while
I have some xml similar to this: <?xml version=1.0 encoding=utf-8 ?> <data> <resources> <resource
I have a resource file named filetypes.resx. Some how I figured out to bind
I have some webserver resources protected with Form based Authentication. The requirement is to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.