Skip to content

Commit 7a81fc1

Browse files
authored
Document simulator auto update bundle option (#4051)
1 parent c230f0d commit 7a81fc1

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

docs/developer-guide/Miscellaneous-Features.asciidoc

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,13 @@ You can use `createContact(String firstName, String familyName, String officePho
197197
Localization (l10n) means adapting to a locale which is more than just translating to a specific language but also to a specific language within environment e.g. `en_US != en_UK`.
198198
Internationalization (i18n) is the process of creating one application that adapts to all locales and regional requirements.
199199

200-
Codename One supports automatic localization and seamless internationalization of an application using the Codename One design tool.
200+
Codename One supports automatic localization and seamless internationalization of an application using Java properties bundles.
201201

202-
IMPORTANT: Although localization is performed in the design tool most features apply to hand coded applications as well. The only exception is the tool that automatically extracts localizable strings from the GUI.
202+
Place locale-specific properties files inside an `l10n` directory directly under your module’s `main` directory (e.g. `common/src/main/l10n`).
203+
Each file inside this directory is treated as a resource bundle and will be packaged automatically with your app, allowing you to version translations alongside the rest of your source code.
203204

204-
.Localization tool in the Designer
205-
image::img/developer-guide/l10nform.png[Localization tool in the Designer,scaledwidth=50%]
206-
207-
To translate an application you need to use the localization section of the Codename One Designer. This section features a handy tool to extract localization called Sync With UI, it's a great tool to get you started assuming you used the old GUI builder.
208-
209-
Some fields on some components (e.g. `Commands`) are not added when using "Sync With UI" button. But you can add them manually on the localization bundle and they will be automatically localized. You can just use the #Property Key# used in the localization bundle in the Command name of the form.
210-
211-
You can add additional languages by pressing the #Add Locale# button.
212-
213-
This generates “bundles” in the resource file which are really just key/value pairs mapping a string in one language to another language.
205+
When you are iterating on translations you can also use the simulator to capture bundles automatically.
206+
Open the Simulator menu and enable *Auto Update Default Bundle* so that running your app in the Codename One simulator will create any missing resource bundles on the fly as you interact with the UI, which makes it simple to populate keys without manually editing files during development.
214207
You can install the bundle using code like this:
215208

216209
[source,java]
@@ -242,8 +235,6 @@ Enumeration locales = res.listL10NLocales( "l10n" );
242235

243236
An exception for localization is the `TextField`/`TextArea` components both of which contain user data, in those cases the text will not be localized to avoid accidental localization of user input.
244237

245-
You can preview localization in the theme mode within the Codename One designer by selecting #Advanced#, picking your locale then clicking the theme again.
246-
247238
TIP: You can export and import resource bundles as standard Java properties files, CSV and XML. The formats are pretty standard for most localization shops, the XML format Codename One supports is the one used by Android’s string bundles which means most localization specialists should easily localize it
248239

249240
The resource bundle is just a map between keys and values e.g. the code below displays `"This Label is localized"` on the `Label` with the hardcoded resource bundle. It would work the same with a resource bundle loaded from a resource file:

0 commit comments

Comments
 (0)