A quick question about language

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
daress
Posts: 23
Joined: Tue Mar 13, 2007 4:52 pm
Contact:

Re: A quick question about language

Post by daress » Fri May 25, 2018 3:44 pm

Up front, understand that when ChartPanel displays the menu, the text is pulled from a ResourceBundle. The resourse bundle in ChartPanel,localizationResource, is static and allocated when the ChartPanel object is created. If you look at the code (line 393-395), you will see that a call is made to ResourceBundleWrapper.getBundle().

Within the getBundle() method with 1 argument, the default Locale is obtained from the java runtime environment. Thus, the ChartPanel menu text is dynamic from one installation country to the next, provided the localization resource has been generated for the desired Locale.

Given your question, there are multiple ways to meet your requirements, and what follows is just one suggestion.

Begin with customizing ChartPanel to allow the localizationResource variable to be non-static and updatable by GUI selections in your parent application. Did you notice the ResourceBundleWrapper.getBundle() method that takes a Locale as an input? Next, create/add ResourceBundle property files to the JFreeChart project directory org/jfree/chart - look at one of the existing LocalizationBundles first (LocalizationBundle_de.properties is a good one) - you need Finnish (ie, LocalizationBundle_fi.properties). Rebuild JFreeChart with these changes. Add the necessary code to the parent application to select the Locales dynamically.

Post Reply