Home > database >  Spring project uploaded to AWS via elastic beanstalk doesn't read from French resource bundles
Spring project uploaded to AWS via elastic beanstalk doesn't read from French resource bundles

Time:10-03

I have a Spring framework project using Java that when I run it locally and use postman it properly uses the resource bundles I got using getBundle(String baseName, Locale locale) to translate my message. When I upload the project to AWS using Elastic Beanstalk and use postman the messages are always from my en_US bundle, even if when I get the bundle, I set the locale to my French bundle. How can I get it to read from my French bundle when uploaded to AWS?

Thanks for your help!

CodePudding user response:

When I was loading the properties bundle as follows, I was getting the same issue after deploying to Elastic Beanstalk, even though it was working fine locally:

    final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PREFIX, locale);

I changed the loading method to the following and it started working:

        InputStream stream = new ClassPathResource(filename).getInputStream();
        properties.load(stream);
        value = properties.getProperty(key);

Of course, you need to make sure that your translation files are under src/main/resources.

  • Related