Getting MD internationalised strings
I have an old extension that uses MDResourceProvider to create a GUI class. ie:
public class MRBGUI implements MDResourceProvider {
private Resources resources;
private UserPreferences userPref;
public MRBGUI () {
userPref = UserPreferences.getInstance();
resources = userPref.getResources();
}
@Override
public Icon getIcon(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public Image getImage(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public Resources getResources() {
return resources;
}
@Override
public String getStr(String strKey) {
return resources.getString(strKey);
}
public String getString(PeriodType type) {
return resources.getString(type);
}
@Override
public MDStrings strings() {
// TODO Auto-generated method stub
return null;
}
I use this to get strings: ie,
}
gui=new MRBGUI();
types = PeriodType.all();
String[] typeStrings = new String[types.length];
for (int i=0;i<types.length;i++) {
typeStrings[i] = gui.getString(types[i]);
}
budgetTypesCB.setSelectedItem(gui.getString(PeriodType.MONTH));
I wish to get rid of this. Is there a better way of getting Internationalized strings?Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Sean Reilly on 26 Apr, 2021 12:37 PM
I would be very wary of this... extensions should be using their own localised strings as that API isn't promised to be stable and has recently changed a bit, but probably hasn't broken any extensions yet.
If you'd still like to use it, you should be able to use .getUI().getStrings().getString("name_of_string_token"). Or maybe it's .getUI().getResources().getString("name_of_string_token")
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
System closed this discussion on 26 Jul, 2021 12:40 PM.