Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation of weather strings like "Partlycloudy"? #16

Open
magune opened this issue May 24, 2022 · 2 comments
Open

Translation of weather strings like "Partlycloudy"? #16

magune opened this issue May 24, 2022 · 2 comments
Labels
question Further information is requested

Comments

@magune
Copy link

magune commented May 24, 2022

With the weather data on my screensaver, next problem is it is in English and not in Swedish, that the date info is.

image

I volunteer to do the translation to Swedish of the Weather strings like "Partly cloudy", but don't know how to do it.
(I am not a developer and don't code)

/Magnus

@Shreyas-R
Copy link
Owner

Weather state strings are provided by your weather provider on Home Assistant. Check if they support changing the language or it might be coming straight from the Home Assistant configuration which might be using the English language.
This plugin uses the weather state strings as is without any translation.

However, once you are able to translate the weather state strings, you might need to change the names of the weather icons as per the language of weather state strings as they are currently hard-coded in English.

@Shreyas-R
Copy link
Owner

Shreyas-R commented May 24, 2022

Update: You can follow this old discussion to translate weather state strings within HA and use the same in wallpanel-screensaver config,
https://community.home-assistant.io/t/weather-conditions-in-local-language-in-template/243824

  1. Add the following lines in HA configuration.yaml, replace weather.home with the weather entity in your HA setup and replace Russian translation with Swedish translation,
template:
 - sensor:
   - name: "current_weather"
     state: >
       {%- set state = states('weather.home') -%}
       {% if state == 'clear-night' %} Ясно, ночь
       {% elif state == 'cloudy' %} Облачно
       {% elif state == 'exceptional' %} Предупреждение
       {% elif state == 'fog' %} Туман
       {% elif state == 'hail' %} Град
       {% elif state == 'lightning' %} Молния
       {% elif state == 'lightning-rainy' %} Молния, дождь
       {% elif state == 'partlycloudy' %} Переменная облачность
       {% elif state == 'pouring' %} Ливень
       {% elif state == 'rainy' %} Дождь
       {% elif state == 'snowy' %} Снег
       {% elif state == 'snowy-rainy' %} Снег с дождем
       {% elif state == 'sunny' %} Ясно
       {% elif state == 'windy' %} Ветрено
       {% elif state == 'windy-variant' %} Ветрено
       {% else %} Нет данных
       {% endif %}
  1. Check configuration.yaml file for any issue and restart the HA.

  2. After restart, add this to your wallpanel-screensaver config at dashboard config file,

wallpanel_screensaver:
 ...
 ...
 info_template: '
     <div id="wallpanel-screensaver-info-weather">
       <table>
       	<tr>
       		<th><img id="weather-temperature-icon" src="{{ filesParentPath }}/weather-icons/thermometer.svg"/></th>
       		<th>{{ states[config.weather_entity].attributes.temperature }}°&ensp;</th>
       		<th><img id="weather-state-icon" src="{{ filesParentPath }}/weather-icons/{{ states[config.weather_entity].state }}-sun-{{ states["sun.sun"].state.replace("_", "-"); }}.svg"/></th>
         	<th>{{ states["sensor.current_weather"].state.replace(/(^|\s)[A-Za-zÀ-ÖØ-öø-ÿ]/g, c => c.toUpperCase()) }}</th>
       	</tr>
       </table>
     </div>

image

The advantage of this is that you don't have to rename the English hard-coded names of weather icons in the process!

@Shreyas-R Shreyas-R added the question Further information is requested label May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants