I’ve added support for locale-aware formatting and project localisation resources. This is coming in the next release.
There are two related parts.
First, Objo now has a built-in Locale class. A Locale represents a language/region identifier such as en-GB, fr-FR, or the invariant locale. You can use it when formatting or parsing numbers, currency values, and dates.
Existing ToString() and Parse() behaviour stays unchanged unless you explicitly pass a locale, so this should be additive for existing projects.
Var gb As Locale = Locale.FromIdentifier("en-GB")
Var fr As Locale = Locale.FromIdentifier("fr-FR")
Print(1234.5.ToString("F1", gb)) # 1234.5
Print(1234.5.ToString("F1", fr)) # 1234,5
Print(Double.Parse("1234,5", fr)) # 1234.5
There are also convenience values:
Print(Locale.Current.Identifier)
Print(Locale.CurrentUI.Identifier)
Print(Locale.Invariant.Identifier)
Print(System.LocaleCode)
Second, Studio now supports project string tables for localised app text. These are edited in Project Settings > Localisation. You add locale columns such as en-GB and fr-FR, then add stable string keys that your code can look up with Localise(...).
For example, a project might contain this table:
| Key | en-GB | fr-FR |
|---|---|---|
| button.save | Save | Enregistrer |
| welcome.message | Hello {name} | Bonjour {name} |
Then in code:
Var fr As Locale = Locale.FromIdentifier("fr-FR")
Print(Localise("button.save", fr))
# Enregistrer
Var values As Dictionary = {"name": "Ada"}
Print(Localise("welcome.message", fr, values))
# Bonjour Ada
The {name} part is a placeholder inside the localised string, not Objo code. Localise(...) replaces it with the matching dictionary value. The dictionary key is name, without the braces.
If you omit the locale, Objo uses the current UI locale:
Print(Localise("button.save"))
Missing translations fall back through the requested locale, the parent language, the project default locale, the default parent language, and finally the key itself. So if a key is missing everywhere:
Print(Localise("settings.title"))
# settings.title
Studio also bundles these string resources when running, debugging, and publishing apps. The compiled bytecode format does not need to change.
I’ve also added a bundled example project to Studio. It shows a small desktop window with a locale picker, translated labels, placeholder replacement, locale-aware number/currency/date formatting, and missing-key fallback.