Skip to content

Commit

Permalink
[weathercompany] Add default translations to properties file (openhab…
Browse files Browse the repository at this point in the history
…#11460)

Allows translating the binding strings with Crowdin.

Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Nick Waterton <[email protected]>
  • Loading branch information
lolodomo authored and NickWaterton committed Dec 30, 2021
1 parent b976f82 commit 35c90a4
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,13 @@ protected Unit<?> getLengthUnit() {
break;
}
} catch (TimeoutException e) {
errorMsg = "TimeoutException: Call to Weather Company API timed out";
errorMsg = "@text/offline.comm-error-timeout";
} catch (ExecutionException e) {
errorMsg = String.format("ExecutionException: %s", e.getMessage());
} catch (InterruptedException e) {
errorMsg = String.format("InterruptedException: %s", e.getMessage());
}
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, errorMsg);
logger.debug("{}", errorMsg);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public void run() {
if (rootcause instanceof HttpResponseException
&& rootcause.getMessage().contains("Authentication challenge without")) {
logger.debug("Bridge: HttpResponseException: API key is not valid");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "API key is invalid");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.config-error-invalid-api-key");
} else {
logger.debug("Bridge: IOException trying to validate Api key: {}", e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ private boolean isValidLocation() {
case CONFIG_LOCATION_TYPE_POSTAL_CODE:
String postalCode = config.postalCode;
if (postalCode == null || postalCode.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Postal code is not set");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.config-error-unset-postal-code");
} else {
locationQueryString = "&postalKey=" + postalCode.replace(" ", "");
validLocation = true;
Expand All @@ -137,7 +138,8 @@ private boolean isValidLocation() {
case CONFIG_LOCATION_TYPE_GEOCODE:
String geocode = config.geocode;
if (geocode == null || geocode.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Geocode is not set");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.config-error-unset-geocode");
} else {
locationQueryString = "&geocode=" + geocode.replace(" ", "");
validLocation = true;
Expand All @@ -146,14 +148,16 @@ private boolean isValidLocation() {
case CONFIG_LOCATION_TYPE_IATA_CODE:
String iataCode = config.iataCode;
if (iataCode == null || iataCode.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "IATA code is not set");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.config-error-unset-iata-code");
} else {
locationQueryString = "&iataCode=" + iataCode.replace(" ", "").toUpperCase();
validLocation = true;
}
break;
default:
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Location Type is not set");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.config-error-unset-location-type");
break;
}
return validLocation;
Expand Down Expand Up @@ -216,7 +220,8 @@ private synchronized void refreshForecast() {
updateDaypartForecast(forecast.daypart);
} catch (JsonSyntaxException e) {
logger.debug("Handler: Error parsing daily forecast response object", e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Error parsing daily forecast");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.comm-error-parsing-daily-forecast");
return;
}
}
Expand Down Expand Up @@ -244,7 +249,8 @@ private void updateDaypartForecast(Object daypartObject) {
logger.debug("Handler: Successfully parsed daypart forecast object");
} catch (JsonSyntaxException e) {
logger.debug("Handler: Error parsing daypart forecast object: {}", e.getMessage(), e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Error parsing daypart forecast");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.comm-error-parsing-daypart-forecast");
return;
}
logger.debug("There are {} daypart forecast entries", dayparts.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ private synchronized void refreshPwsObservations() {
updatePwsObservations(pwsObservations);
} catch (JsonSyntaxException e) {
logger.debug("Handler: Error parsing pws observations response object: {}", e.getMessage(), e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Error parsing PWS observations");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.comm-error-parsing-pws-forecast");
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">

<name>WeatherCompany Binding</name>
<description>This is the binding for the WeatherCompany weather forecast API.</description>
<name>Weather Company Binding</name>
<description>This is the binding for the Weather Company weather forecast API.</description>

</binding:binding>
Loading

0 comments on commit 35c90a4

Please sign in to comment.