Skip to content

Commit

Permalink
feat: Add Slovak language support
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocjohn committed Aug 25, 2024
1 parent 1767987 commit 3f62a8e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
| `fr.json` | Français |
| `id.json` | Bahasa Indonesia |
| `pt.json` | Português (Brasil) |
| `sk.json` | Slovak |

</details>

Expand Down
1 change: 0 additions & 1 deletion src/css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ ha-select {
}

.version {
margin-top: 2rem;
color: var(--secondary-text-color);
justify-content: space-around;
align-items: stretch;
Expand Down
29 changes: 20 additions & 9 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,30 @@ export class LunarPhaseCardEditor extends LitElement implements LovelaceCardEdit

protected firstUpdated(changedProps: PropertyValues): void {
super.firstUpdated(changedProps);

if (this._compareVersions() !== 0) {
const toast = this.shadowRoot?.getElementById('toast') as HTMLElement;
const version = this.shadowRoot?.querySelector('.version') as HTMLElement;
version.style.visibility = 'hidden';
toast.classList.add('show');
}
}

private get selectedLanguage(): string {
return this._config?.selected_language || 'en';
}

protected update(changedProperties: PropertyValues): void {
super.update(changedProperties);
if (changedProperties.has('_latestRelease') && this._latestRelease !== '') {
const compareVersionsResult = this._compareVersions();
const toast = this.shadowRoot?.getElementById('toast') as HTMLElement;
const version = this.shadowRoot?.querySelector('.version') as HTMLElement;
if (toast || version) {
if (compareVersionsResult !== 0) {
toast.classList.add('show');
version.style.display = 'none';
} else {
version.style.display = 'flex';
}
}
}

this._systemLanguage = this.hass?.language;
}
private localize = (string: string, search = '', replace = ''): string => {
return localize(string, this.selectedLanguage, search, replace);
};
Expand Down Expand Up @@ -78,7 +89,7 @@ export class LunarPhaseCardEditor extends LitElement implements LovelaceCardEdit
<span
>${
CARD_VERSION === this._latestRelease
? CARD_VERSION
? html`version: ${CARD_VERSION}`
: html`version: ${CARD_VERSION} -> <span class="update">${this._latestRelease}</span>`
}</span
>
Expand Down Expand Up @@ -521,7 +532,7 @@ export class LunarPhaseCardEditor extends LitElement implements LovelaceCardEdit
private _handleAlertDismissed(): void {
const toast = this.shadowRoot?.getElementById('toast') as HTMLElement;
const version = this.shadowRoot?.querySelector('.version') as HTMLElement;
if (toast) {
if (toast || version) {
toast.classList.remove('show');
version.style.visibility = 'visible';
}
Expand Down

0 comments on commit 3f62a8e

Please sign in to comment.