I18n Support

Internationalization oder I18n is available in different places of Sapphire Javafx.

  • FXML Files
  • ViewController, WindowController
  • Expression Language

Adding Default (Application) Resource Bundle

Normally you will add resources in the ApplicationController.

sourceSFXApplicationEnvironment.loadResourceBundle("bundles/application")

The ApplicationEnvironment will hold the reference to the loaded resources.

FXML Support

If there is a loaded resource, you can use it in the fxml files with the following pattern: %

<Button mnemonicParsing="false" onAction="#actionToggleWorkspace" text="%navigation.toggle" />

If you want a special resource bundle for one or more fxml files,
you have to override resourceBundleForView in the ApplicationController.

source// only example values ...
override def resourceBundleForView(viewPath: String): ResourceBundle =
  if (viewPath.contains("mySpecialViewName")) {
    val path = "myCustomResourcePath"
    val classLoader = Thread.currentThread().getContextClassLoader
    ResourceBundle.getBundle(path, Locale.getDefault(), classLoader)
  } else
    super.resourceBundleForView(viewPath) // =  applicationEnvironment.resourceBundle