Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ _This release is scheduled to be released on 2021-01-01._
- Added SMHI as a provider to Weather module.
- Added Hindi & Gujarati translation.
- Added optional support for DEGREE position in Feels like translation
- Added support for variables in nunjucks templates for translate filter
- Chuvash translation.
- Calendar: new options "limitDays" and "coloredEvents".
- Added new option "limitDays" - limit the number of discreet days displayed.
Expand Down Expand Up @@ -63,6 +64,7 @@ _This release is scheduled to be released on 2021-01-01._
- update node-ical version again, 0.12.7, change RRULE fix (#2371, #2379), node-ical now throws error (which we catch)
- update simple-git version to 2.31 unhandled promise rejection (#2383)
- Translator variables can have falsy values (e.g. empty string)
- Fix issue with weather module with DEGREE label in FEELS like

## [2.13.0] - 2020-10-01

Expand Down
4 changes: 2 additions & 2 deletions js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ var Module = Class.extend({
lstripBlocks: true
});

this._nunjucksEnvironment.addFilter("translate", function (str) {
return self.translate(str);
this._nunjucksEnvironment.addFilter("translate", function (str, variables) {
return self.translate(str, variables);
});

return this._nunjucksEnvironment;
Expand Down
5 changes: 4 additions & 1 deletion modules/default/weather/current.njk
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@
<div class="normal medium">
{% if config.showFeelsLike %}
<span class="dimmed">
{{ "FEELS" | translate }} {{ current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }}
{{ "FEELS" | translate({DEGREE: current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }) }}
{% if not config.feelsLikeWithDegree %}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather add the DEGREE placeholder in all other translations too, so we can get rid of these if clauses.

{{ current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }}
{% endif %}
</span>
{% endif %}
{% if config.showPrecipitationAmount %}
Expand Down
5 changes: 4 additions & 1 deletion modules/default/weather/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ Module.register("weather", {
onlyTemp: false,
showPrecipitationAmount: false,
colored: false,
showFeelsLike: true
showFeelsLike: true,
feelsLikeWithDegree: false
},

// Module properties.
Expand Down Expand Up @@ -88,6 +89,8 @@ Module.register("weather", {
// Let the weather provider know we are starting.
this.weatherProvider.start();

this.config.feelsLikeWithDegree = this.translate("FEELS").indexOf("{DEGREE}") > -1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with DEGREE in all translations this would not be necessary either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to keep it as it is. As it is optional and very few languages will need DEGREE placeholder. If we add DEGREE placeholder it might break other modules who are using FEELS like resource string in their modules. New languages (Hindi and Gujarati) only have it now and if any third party is using it they need to correct it for this lang. only.


// Add custom filters
this.addFilters();

Expand Down