Skip to content

Added support for variables in nunjucks templates for translate filter#2397

Merged
MichMich merged 2 commits intoMagicMirrorOrg:developfrom
ashishtank:develop
Dec 31, 2020
Merged

Added support for variables in nunjucks templates for translate filter#2397
MichMich merged 2 commits intoMagicMirrorOrg:developfrom
ashishtank:develop

Conversation

@ashishtank
Copy link
Contributor

Added support for variables in nunjucks templates for translate filter
Fix issue with weather module with DEGREE label in FEELS like

<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
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.

// Let the weather provider know we are starting.
this.weatherProvider.start();

this.config.feelsLikeWithDegree = this.translate("FEELS").indexOf("{DEGREE}") > -1;
Copy link
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
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.

@MichMich
Copy link
Collaborator

@rejas, does this solve the issue for you? Should I merge this or revert the other?

@rejas
Copy link
Collaborator

rejas commented Dec 31, 2020

@MichMich that solves the issue. you can merge it. still the question is: do other modules rely on this translation? becuase I really think this should be solved in the translation files and not in the code. or what is your stance on this.
We can always "clean it up" in 2021 :-)

@MichMich
Copy link
Collaborator

Yeah. I agree we should clean it up. It's a bit too specific. But for now I'll merge it.

@MichMich MichMich merged commit a4ab0cb into MagicMirrorOrg:develop Dec 31, 2020
@ashishtank
Copy link
Contributor Author

@MichMich @rejas I will clean it up in 2021 ! Happy new year 🎊

@MichMich
Copy link
Collaborator

U2! 🎉

@rejas
Copy link
Collaborator

rejas commented Dec 31, 2020

Happy new year to everybody! Stay healthy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants