Skip to content

Commit

Permalink
Merge branch 'main' into categories_sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-hoehn authored Feb 26, 2024
2 parents 88fc2df + b936d88 commit 992368c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions developers/utils/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ discovery.darksky.weather-and-forecast.api.local.label = Lokales Wetter und Wett
In addition to the default keys the developer can also specify custom keys inside the XML file.
But with this approach the XML file cannot longer contain the English texts.
So it is mandatory to define a language file for the English language.
The syntax for custom keys is `@text/<key>`.
The syntax for custom keys is `@text/<key> [params]`.
The keys are unique across the whole bundle, so a constant can reference any key in all files inside the `OH-INF/i18n` folder.
The following snippet shows a binding XML that uses custom keys:
Expand All @@ -428,7 +428,7 @@ addon.acmeweather.description = Binding for ACME Weather
# thing status descriptions
offline.communication-error = The ACME Weather API is currently not available.
offline.communication-error = The ACME Weather API is currently not available. Error {0}
```
Language file (`acmeweather_de.properties`):
Expand All @@ -441,13 +441,13 @@ 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. Fehler {0}
```
The custom keys are a very good practice to translate bundle dependent error messages.
```java
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, "@text/offline.communication-error");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, "@text/offline.communication-error [\"EX-500\"]");
```
## Generating I18N properties file
Expand Down

0 comments on commit 992368c

Please sign in to comment.