Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example for I18N custom keys #2117

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading