ui5
The preset for SAPUI5 and OpenUI5. It reads .properties bundles, {i18n>key} bindings and getResourceBundle().getText calls.
The ui5 preset supports UI5 apps, SAPUI5 and OpenUI5.
Detection
The preset applies when the project depends on @ui5/cli.
x18n.config.ts
import { ui5 } from '@x18n/cli/presets'
import { defineConfig } from '@x18n/core'
export default defineConfig({
presets: [ui5()],
})Locale files
If your config has no resources, the preset uses webapp/i18n/i18n_{locale}.properties and webapp/i18n/i18n.properties. The properties format reads and writes these files. Keys stay flat.
i18n.properties has no locale in its name, so it holds the source locale. With the default sourceLocale: 'en', these files give the locales en and de:
webapp/i18n/i18n.properties
appTitle=App
hello=Hello {0}webapp/i18n/i18n_de.properties
appTitle=AnwendungSupported syntax
In XML views, JSON files, JS and TS, the preset reads {i18n>key} bindings. In JS and TS, it also reads getResourceBundle().getText('key'):
webapp/view/Main.view.xml
<Page title="{i18n>appTitle}" />webapp/controller/Main.controller.js
this.getResourceBundle().getText('hello')Placeholders
Braces: {0}, {name}.
Extraction templates
| Kinds | Files | Template |
|---|---|---|
| any | **/*.xml | {i18n>{key}} |
js-string, js-template | any | this.getResourceBundle().getText('{key}') |