Search code examples
codenameone

How do I change UI language more effieicntly?


I changed the UI language by code below

UIManager.getInstance().setBundle(theme.getL10N("L10N", language));

Should I recreate all components on the UI to change the language?

Are there any more efficient methodologies to change languages on all the UI components?


Solution

  • Yes. No.

    There's no way that's more efficient since the alternative is to bind all components to a listener that would track language changes. This can be expensive but also risks a memory leak. Forms are meant to be fast to create and discard in Codename One, so this should be pretty fast.