generated from custom-cards/boilerplate-card
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
63 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
"3": "Ср", | ||
"4": "Чт", | ||
"5": "Пт", | ||
"6": "Сб", | ||
"today": "Днес" | ||
"6": "Сб" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
"3": "Ons", | ||
"4": "Tor", | ||
"5": "Fre", | ||
"6": "Lør", | ||
"today": "I dag" | ||
"6": "Lør" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
"3": "Mit", | ||
"4": "Don", | ||
"5": "Fre", | ||
"6": "Sam", | ||
"today": "Heute" | ||
"6": "Sam" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
"3": "Wed", | ||
"4": "Thu", | ||
"5": "Fri", | ||
"6": "Sat", | ||
"today": "Today" | ||
"6": "Sat" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
"3": "Mer", | ||
"4": "Jeu", | ||
"5": "Ven", | ||
"6": "Sam", | ||
"today": "Aujourd'hui" | ||
"6": "Sam" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
{ | ||
"common": { | ||
"version": "Versie", | ||
"invalid_configuration": "Ongeldige configuratie.", | ||
"entity_missing": "Vereiste weerentiteit ontbreekt.", | ||
"invalid_forecast_days": "De waarde van forecast_days moet groter zijn dan 0." | ||
}, | ||
"weather": { | ||
"clear-night": "Helder", | ||
"cloudy": "Bewolkt", | ||
"fog": "Mist", | ||
"hail": "Hagel", | ||
"lightning": "Onweersbuien", | ||
"lightning-rainy": "Onweersbuien met regen", | ||
"partlycloudy": "Half bewolkt", | ||
"pouring": "Regen", | ||
"rainy": "Regenachtig", | ||
"snowy": "Sneeuw", | ||
"snowy-rainy": "Natte sneeuw", | ||
"sunny": "Zonnig", | ||
"windy": "Winderig", | ||
"windy-variant": "Storm", | ||
"exceptional": "Chaos" | ||
}, | ||
"day": { | ||
"0": "Zo", | ||
"1": "Ma", | ||
"2": "Di", | ||
"3": "Wo", | ||
"4": "Do", | ||
"5": "Vr", | ||
"6": "Za", | ||
"today": "Vandaag" | ||
} | ||
"common": { | ||
"version": "Versie", | ||
"invalid_configuration": "Ongeldige configuratie.", | ||
"entity_missing": "Vereiste weerentiteit ontbreekt.", | ||
"invalid_forecast_days": "De waarde van forecast_days moet groter zijn dan 0." | ||
}, | ||
"weather": { | ||
"clear-night": "Helder", | ||
"cloudy": "Bewolkt", | ||
"fog": "Mist", | ||
"hail": "Hagel", | ||
"lightning": "Onweersbuien", | ||
"lightning-rainy": "Onweersbuien met regen", | ||
"partlycloudy": "Half bewolkt", | ||
"pouring": "Regen", | ||
"rainy": "Regenachtig", | ||
"snowy": "Sneeuw", | ||
"snowy-rainy": "Natte sneeuw", | ||
"sunny": "Zonnig", | ||
"windy": "Winderig", | ||
"windy-variant": "Storm", | ||
"exceptional": "Chaos" | ||
}, | ||
"day": { | ||
"0": "Zo", | ||
"1": "Ma", | ||
"2": "Di", | ||
"3": "Wo", | ||
"4": "Do", | ||
"5": "Vr", | ||
"6": "Za" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
"3": "śr.", | ||
"4": "czw.", | ||
"5": "pt.", | ||
"6": "sob.", | ||
"today": "dzisiaj" | ||
"6": "sob." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
"3": "Quarta", | ||
"4": "Quinta", | ||
"5": "Sexta", | ||
"6": "Sábado", | ||
"today": "Hoje" | ||
"6": "Sábado" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
import * as bg from './languages/bg.json'; | ||
import * as da from './languages/da.json'; | ||
import * as de from './languages/de.json'; | ||
import * as en from './languages/en.json'; | ||
import * as fr from './languages/fr.json'; | ||
import * as nl from './languages/nl.json'; | ||
import * as pl from './languages/pl.json'; | ||
import * as ptBR from './languages/da.json'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const languages: any = { | ||
en | ||
bg, | ||
da, | ||
de, | ||
en, | ||
fr, | ||
nl, | ||
pl, | ||
ptBR | ||
}; | ||
|
||
export function localize(string: string, search = '', replace = ''): string { | ||
const lang = (localStorage.getItem('selectedLanguage') || 'en').replace(/['"]+/g, '').replace('-', '_'); | ||
|
||
export function localize(key: string): string { | ||
let translated: string; | ||
const lang = (localStorage.getItem('selectedLanguage') || 'en') | ||
.replace(/['"]+/g, '') | ||
.replace('-', '_') | ||
.replace('_', ''); | ||
|
||
try { | ||
translated = string.split('.').reduce((o, i) => o[i], languages[lang]); | ||
translated = key.split('.').reduce((o, i) => o[i], languages[lang]); | ||
} catch (e) { | ||
translated = string.split('.').reduce((o, i) => o[i], languages['en']); | ||
translated = key.split('.').reduce((o, i) => o[i], languages['en']); | ||
} | ||
|
||
if (translated === undefined) translated = string.split('.').reduce((o, i) => o[i], languages['en']); | ||
if (translated === undefined) translated = key.split('.').reduce((o, i) => o[i], languages['en']); | ||
|
||
if (search !== '' && replace !== '') { | ||
translated = translated.replace(search, replace); | ||
} | ||
return translated; | ||
} |