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

Improved translation #22

Merged
merged 4 commits into from
Jun 25, 2022
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
9 changes: 5 additions & 4 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { formfieldDefinition } from '../elements/formfield';
import { selectDefinition } from '../elements/select';
import { switchDefinition } from '../elements/switch';
import { textfieldDefinition } from '../elements/textfield';
import { localize } from './localize/localize';

@customElement('hourly-weather-editor')
export class HourlyWeatherCardEditor extends ScopedRegistryHost(LitElement) implements LovelaceCardEditor {
Expand Down Expand Up @@ -64,7 +65,7 @@ export class HourlyWeatherCardEditor extends ScopedRegistryHost(LitElement) impl
<mwc-select
naturalMenuWidth
fixedMenuPosition
label="Entity (Required)"
label=${localize('editor.entity')}
.configValue=${'entity'}
.value=${this._entity}
@selected=${this._valueChanged}
Expand All @@ -75,19 +76,19 @@ export class HourlyWeatherCardEditor extends ScopedRegistryHost(LitElement) impl
})}
</mwc-select>
<mwc-textfield
label="Name (Optional)"
label=${localize('editor.name')}
.value=${this._name}
.configValue=${'name'}
@input=${this._valueChanged}
></mwc-textfield>
<mwc-textfield
label="Number of hours to show (Optional)"
label=${localize('editor.hours_to_show')}
.value=${this._numHours}
.configValue=${'num_hours'}
@input=${this._valueChanged}
.pattern=${"([1-9][0-9]*[02468])|([2468])"}
.autoValidate=${true}
validationMessage="Must be an even integer greater than or equal to 2"
validationMessage=${localize('errors.must_be_int')}
></mwc-textfield>
`;
}
Expand Down
8 changes: 4 additions & 4 deletions src/hourly-weather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ console.info(
(window as any).customCards = (window as any).customCards || [];
(window as any).customCards.push({
type: 'hourly-weather',
name: 'Hourly Weather Card',
description: 'A card to render hourly weather conditions as a bar.',
name: localize('common.title_card'),
description: localize('common.description'),
});

@customElement('hourly-weather')
Expand Down Expand Up @@ -67,7 +67,7 @@ export class HourlyWeatherCard extends LitElement {
}

this.config = {
name: 'Hourly Weather',
name: localize('common.title'),
...config,
};
}
Expand Down Expand Up @@ -113,7 +113,7 @@ export class HourlyWeatherCard extends LitElement {
>
<div class="card-content">
${isForecastDaily ?
this._showWarning('The selected weather entity seems to provide daily forecasts. Consider switching to an hourly entity.') : ''}
this._showWarning(localize('errors.daily_forecasts')) : ''}
<weather-bar .conditions=${conditionList} .temperatures=${temperatures}></weather-bar>
</div>
</ha-card>
Expand Down
14 changes: 12 additions & 2 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"common": {
"version": "Version",
"title": "Hourly Weather",
"title_card": "Hourly Weather Card",
"description": "A card to render hourly weather conditions as a bar.",
"invalid_configuration": "Invalid configuration"
},
"editor": {
"entity": "Entity (Required)",
"name": "Name (Optional)",
"hours_to_show": "Number of hours to show (Optional)"
},
"errors": {
"missing_entity": "entity is missing in configuration",
"too_many_hours_requested": "Too many hours requested in num_hours. Must be <= number of hours in forecast entity."
"too_many_hours_requested": "Too many hours requested in num_hours. Must be <= number of hours in forecast entity.",
"daily_forecasts": "The selected weather entity seems to provide daily forecasts. Consider switching to an hourly entity.",
"must_be_int": "Must be an even integer greater than or equal to 2"
},
"conditions": {
"clear": "Clear",
Expand All @@ -21,4 +31,4 @@
"sunny": "Sunny",
"windy": "Windy"
}
}
}
16 changes: 13 additions & 3 deletions src/localize/languages/pt.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
{
"common": {
"version": "Versão",
"title": "Tempo de hora em hora",
"title_card": "Tempo de hora em hora",
"description": "Um cartão para mostrar as condições meteorológicas de hora em hora como uma barra.",
"invalid_configuration": "Configuração Inválida"
},
"editor": {
"entity": "Entidade",
"name": "Nome (opcional)",
"hours_to_show": "Número de horas para mostrar"
},
"errors": {
"missing_entity": "A entidade não existe na configuração",
"too_many_hours_requested": "Demasiadas horas solicitadas em num_hours. Deve ser menor que o número de horas disponíveis na entidade de meteo."
"too_many_hours_requested": "Demasiadas horas solicitadas em num_hours. Deve ser menor que o número de horas disponíveis na entidade de meteo.",
"daily_forecasts": "A entidade meteorológica selecionada parece fornecer previsões diárias. Considere mudar para uma entidade horária.",
"must_be_int": "Deve ser um número inteiro par maior ou igual a 2"
},
"conditions": {
"clear": "Limpo",
"cloudy": "Nublado",
"fog": "Nevoeiro",
"hail": "Granizo",
"thunderstorm": "Trovoada",
"partlyCloudy": "Parcialmente nublado",
"partlyCloudy": "Pouco nublado",
"heavyRain": "Chuva forte",
"rain": "Chuva",
"snow": "Neve",
"mixedPrecip": "Precipitação mista",
"sunny": "Sol",
"windy": "Vento"
}
}
}