From b936d88c7344638916038d80a7a599aac61e3a53 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 26 Feb 2024 07:43:34 +0100 Subject: [PATCH] Set params when using `@text/` (#2254) Signed-off-by: Martin --- developers/utils/i18n.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/developers/utils/i18n.md b/developers/utils/i18n.md index 25ad050788..49011732b3 100644 --- a/developers/utils/i18n.md +++ b/developers/utils/i18n.md @@ -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/`. +The syntax for custom keys is `@text/ [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: @@ -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`): @@ -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