|
Re: EMF Edit localization in a stand-alone application [message #1849457 is a reply to message #1849449] |
Thu, 20 January 2022 14:39 |
Ed Merks Messages: 32985 Registered: July 2009 |
Senior Member |
|
|
No one has ever asked for that before, so mostly it's focused on finding something.
For standalone it would of course be good to have it in the "standard place" but the plugin.properties also has things used in the plugin.xml so if you need it to work in both places, that's not so helpful.
Probably it should be more like this completely untested approach: catch (MissingResourceException exception)
{
Locale locale = Locale.getDefault();
List<String> bundleLocalizations = new ArrayList<String>();
bundleLocalizations.add(bundleLocalization);
String translatedBundleLocalization = bundleLocalization.replace(".properties", "");
String language = locale.getLanguage();
if (language != "")
{
translatedBundleLocalization += '_' + language;
bundleLocalizations.add(0, translatedBundleLocalization + ".properties");
String script = locale.getScript();
if (script != "")
{
translatedBundleLocalization += '_' + script;
bundleLocalizations.add(0, translatedBundleLocalization + ".properties");
}
String country = locale.getCountry();
if (country != "")
{
translatedBundleLocalization += '_' + country;
bundleLocalizations.add(0, translatedBundleLocalization + ".properties");
String variant = locale.getVariant();
if (variant != "") {
translatedBundleLocalization += '_' + variant;
bundleLocalizations.add(0, translatedBundleLocalization + ".properties");
}
}
}
for (String localization : bundleLocalizations)
{
// If the bundle can't be found the normal way, try to find it as the base URL.
// If that also doesn't work, rethrow the original exception.
//
try
{
InputStream inputStream = new URL(baseURL.toString() + localization).openStream();
bundle = untranslatedResourceBundle = resourceBundle = new PropertyResourceBundle(inputStream);
inputStream.close();
break;
}
catch (IOException ioException)
{
// We'll rethrow the original exception, not this one.
}
}
if (bundle == null)
{
throw exception;
}
} I.e., in general it should search for the most specific thing first until finally falling back to just the plugin.properties. You could override the method in plugin subclass, copy the entire base method, paste in the above code and try it.
If that works or if you have an improvement that works, you could open a Bugzilla to put in the base implementation.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.01301 seconds