Set params when using `@text/` (#2254)
Signed-off-by: Martin <martin.grzeslowski@gmail.com>pull/2222/head^2
parent
6774910167
commit
b936d88c73
|
@ -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.
|
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.
|
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.
|
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 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:
|
The following snippet shows a binding XML that uses custom keys:
|
||||||
|
@ -428,7 +428,7 @@ addon.acmeweather.description = Binding for ACME Weather
|
||||||
|
|
||||||
# thing status descriptions
|
# 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`):
|
Language file (`acmeweather_de.properties`):
|
||||||
|
@ -441,13 +441,13 @@ addon.acmeweather.description = Binding für ACME Wetter
|
||||||
|
|
||||||
# thing status descriptions
|
# 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.
|
The custom keys are a very good practice to translate bundle dependent error messages.
|
||||||
|
|
||||||
```java
|
```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
|
## Generating I18N properties file
|
||||||
|
|
Loading…
Reference in New Issue