Skip to content

Commit

Permalink
Update example for I18N custom keys (#2117)
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
  • Loading branch information
jlaur authored Aug 21, 2023
1 parent 0d67c5c commit bdb3707
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions developers/utils/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,29 +408,40 @@ The keys are unique across the whole bundle, so a constant can reference any key
The following snippet shows a binding XML that uses custom keys:
XML file (`binding.xml`):
XML file (`addon.xml`):
```xml
<binding:binding id="acmeweather">
<name>@text/bindingName</name>
<description>@text/bindingName</description>
</binding:binding>
<addon:addon id="acmeweather">
<type>binding</type>
<name>@text/addon.acmeweather.name</name>
<description>@text/addon.acmeweather.description</description>
</addon:addon>
```
Language file (`acmeweather_en.properties`):
```ini
bindingName = ACME Weather Binding
# add-on
addon.acmeweather.name = ACME Weather Binding
addon.acmeweather.description = Binding for ACME Weather
offline.communication-error=The ACME Weather API is currently not available.
# thing status descriptions
offline.communication-error = The ACME Weather API is currently not available.
```
Language file (`acmeweather_de.properties`):
```ini
bindingName = ACME Wetter Binding
# add-on
addon.acmeweather.name = ACME Wetter Binding
addon.acmeweather.description = Binding für ACME Wetter
# thing status descriptions
offline.communication-error=Die ACME Wetter API ist zur Zeit nicht verfügbar.
offline.communication-error = Die ACME Wetter API ist zur Zeit nicht verfügbar.
```
The custom keys are a very good practice to translate bundle dependent error messages.
Expand Down

0 comments on commit bdb3707

Please sign in to comment.