Universal Robots Forum

getTranslatedText example

I can’t find any examples on how to properly provides urcap text translations.
I found the “Translatable” method String getTranslatedText(Locale locale) in the sdk api, but I wonder how to use it.
Do I have to create a class that extend Translatable and choose in a huge switch statement which string to return for each string that is displayed on screen ?

Thanks :slight_smile:

1 Like

So I tried this, seem ok for the build, except the fact that it have to be a public class, to avoid the “Attempt to assign weaker privilege; was public” error, so I have to do 1 file for each text in the urcap. Do anyone know how to avoid this ?

Also, I can’t figure how to integrate this in a field. I tried (my example class is named Add_text):

  • button_add.setText(Add_text); -> unknown variable
  • button_add.setText(new Add_text()); -> can’t convert Addtext to String
  • button_add.setText(new Add_text().getTranslatedText()); -> no arguments, required Locale

Maybe I have to get from somewhere the active Locale to provides as argument ?

1 Like