Skip to content

Instantly share code, notes, and snippets.

@cweitkamp
Created May 2, 2021 13:48
Show Gist options
  • Save cweitkamp/09a2e5634b8cde3dbea64ee20c0d9818 to your computer and use it in GitHub Desktop.
Save cweitkamp/09a2e5634b8cde3dbea64ee20c0d9818 to your computer and use it in GitHub Desktop.
i18n
#!/bin/sh
# TODO specify your binding id (e.g. bindingId="openweathermap")
bindingId="openweathermap"
i18nPath="src/main/resources/OH-INF/i18n"
rm -f $i18nPath/tmp_$bindingId.properties
# generate translation properties
mvn xml:transform
# merge files and drop empty lines
awk '!/^$/' $i18nPath/*/*.properties >> $i18nPath/$bindingId.properties.tmp
sed -e 's/^[ \t]*//' -e '/^$/d' $i18nPath/$bindingId.properties.tmp >> $i18nPath/tmp_$bindingId.properties
# TODO fixtures to replace config description uris
sed -i "s|config.bridge-type:openweathermap:|bridge-type.config.openweathermap.|g" $i18nPath/tmp_$bindingId.properties
sed -i "s|config.thing-type:openweathermap:|thing-type.config.openweathermap.|g" $i18nPath/tmp_$bindingId.properties
# clean up
rm $i18nPath/$bindingId.properties.tmp
rm -rf $i18nPath/*/
# TODO move tmp_$bindingId.properties to $bindingId.properties and add missing translations like custom keys, discovery, or similar
# thing status (custom keys "@text/<key> = ...")
# offline.conf-error-missing-apikey = The 'apikey' parameter must be configured.
# discovery result ("discovery.<binding-id>.<thing-type-id>.<bridge-id>.<thing-id>.label = ..."; Note: <bridge-id> is optional)
# discovery.openweathermap.weather-and-forecast.api.local.label = Local Weather And Forecast
# configurable services ("service.<uri>.label = ..."; Note: ":" has to be replaced by "." in the <uri> part)
# service.system.inbox.label = Inbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment