WAS v8.5 > Develop applications > Develop Internationalization service > Tasks: Internationalizing interface strings (localizable-text API) > Compose language-specific stringsGenerate localized text
Perform this task to specify the runtime formatting of localized text in an application component.
Create a formatter instance and set the localization values as needed.
- If needed, customize the formatting behavior.
- In application code, call the appropriate format method.
Example
We can provide fallback behavior for use if the appropriate message catalog is not available at formatting time.
The following code generates a localized string. If the formatting fails, the application retrieves and uses a fallback string instead of the localized string:
import com.ibm.websphere.i18n.localizabletext.LocalizableException; import com.ibm.websphere.i18n.localizabletext.LocalizableTextFormatter; import java.util.Locale; public void drawAccountNumberGUI(String accountType){ ... LocalizableTextFormatter ltf = new LocalizableTextFormatter(); ... ltf.setFallBackString("Enter account number: "); try { msg = new Label(ltf.format(this.applicationLocale), Label.CENTER); } catch (LocalizableException le) { msg = new Label(ltf.getFallBackString(), Label.CENTER); } ...}
When the application is finished, deploy the application. For more information, see Prepare the localizable-text package for deployment.
Subtopics
- Customize the behavior of a formatting method
Perform this task to change the runtime formatting of localized strings in an application component.- Customize the behavior of a formatting method
Perform this task to change the runtime formatting of localized strings in an application component.
Related
Compose language-specific strings
Reference:
LocalizableTextFormatter class