JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

Utility class for localizing strings using JavaFX properties files. An object of this class is used to find the appropriate localized strings for the given attributes. For example,

 // Object creation
 var localizer = StringLocalizer{ key: "Hello, World!" };

 // This prints localized text for "Hello, World!" for the default locale
 System.out.println(localizer.localizedString()); 

 // This prints localized text for "Duke" for the default locale
 localizer.key = "Duke";
 System.out.println(localizer.localizedString()); 

 // This prints localized text for "Duke" for the French locale
 localizer.locale = Locale.FRENCH;
 System.out.println(localizer.localizedString()); 

 // This prints localized text for "Duke", from 
 // the FX properties file "foo/bar/MyResources_fr.fxproperties
 localizer.propertiesName = "foo.bar.MyResources";
 System.out.println(localizer.localizedString()); 
 

Attribute Summary

nametypedescription
Public
defaultStringString

The default string returned from localizedString() method.

More: [+]

The default string returned from localizedString() method.

keyString

The string that represents the 'key' in the JavaFX properties file

More: [+]

The string that represents the 'key' in the JavaFX properties file

localeLocale

The locale used for determining the JavaFX properties resource bundle.

More: [+]

The locale used for determining the JavaFX properties resource bundle. If it is not explicitly specified, Locale.getDefault() is used.

propertiesNameString

The canonical base name of the JavaFX properties file.

More: [+]

The canonical base name of the JavaFX properties file. It consists of the package name and the base bundle name of the JavaFX properties file. For example, the canonical base name of 'MyResources_xx.fxproperties', where 'xx' denotes the target locale, in 'foo.bar' package is 'foo.bar.MyResources'. If this attribute is not explicitly specified, it is synthesized from the caller's package and script file name, e.g., a JavaFX Script 'Example.fx' is in 'foo.bar' package, the synthesized canonical base name will be 'foo.bar.Example'.

Protected

Inherited Attributes

Function Summary

public static associate(properties: java.lang.String, packageName: java.lang.String) : Void

A static function to associate a JavaFX package with a JavaFX properties file.

More: [+]

A static function to associate a JavaFX package with a JavaFX properties file. If an association is made, further localizations in the source files in the specified package will be searched within the specified JavaFX properties file. 'properties' denotes the canonical base name of the JavaFX properties file, e.g., 'packageName' denotes the JavaFX package, e.g., 'foo.bar', 'foo.bar.MyResources'.

Parameters
properties
packageName
public static associate(properties: java.lang.String, packageName: java.lang.String, scriptFileName: java.lang.String) : Void

A static function to associate a JavaFX Script source file with a JavaFX properties file.

More: [+]

A static function to associate a JavaFX Script source file with a JavaFX properties file. If an association is made, further localizations in the specified source file will be searched within the specified JavaFX properties file. 'properties' denotes the canonical base name of the JavaFX properties file, e.g., 'foo.bar.MyResources'. 'packageName' denotes the JavaFX package, e.g., 'foo.bar'. 'scriptFileName' is the file name source script file, e.g., 'Example.fx'.

Parameters
properties
packageName
scriptFileName
public static dissociate(packageName: java.lang.String) : Void

A static function to dissociate a JavaFX package from any JavaFX properties file.

More: [+]

A static function to dissociate a JavaFX package from any JavaFX properties file. 'packageName' denotes the JavaFX package, e.g., 'foo.bar',

Parameters
packageName
public static dissociate(packageName: java.lang.String, scriptFileName: java.lang.String) : Void

A static function to dissociate a JavaFX Script source file from any JavaFX properties file.

More: [+]

A static function to dissociate a JavaFX Script source file from any JavaFX properties file. 'packageName' denotes the JavaFX package, e.g., 'foo.bar'. 'scriptFileName' is the file name source script file, e.g., 'Example.fx'.

Parameters
packageName
scriptFileName
public bound localizedString() : java.lang.String

This function returns the localized string for the given attributes.

More: [+]

This function returns the localized string for the given attributes. The return value is bound to each of the attributes. If there is no appropriate localized string found in JavaFX properties files, this function returns 'defaultString' if it is specified, otherwise 'key' is returned.

Returns
String

Inherited Functions