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

Added language setting to allow users to change locale #544

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions backend/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/tidwall/buntdb"
"github.com/vertcoin-project/one-click-miner-vnext/langs"
"github.com/vertcoin-project/one-click-miner-vnext/logging"
"github.com/vertcoin-project/one-click-miner-vnext/networks"
"github.com/vertcoin-project/one-click-miner-vnext/pools"
Expand Down Expand Up @@ -186,3 +187,31 @@ func (m *Backend) PrerequisiteProxyLoop() {
m.runtime.Events.Emit("prerequisiteInstall", send)
}
}

type LangChoice struct {
Code string `json:"code"`
Name string `json:"name"`
}

func (m *Backend) GetLangs() []LangChoice {
lc := make([]LangChoice, 0)
for _, p := range langs.Getlangs() {
lc = append(lc, LangChoice{
Code: fmt.Sprintf("%s", p.GetCode()),
Name: fmt.Sprintf("%s", p.GetName()),
})
}
return lc
}

func (m *Backend) GetLang() int {
lang := m.getIntSetting("lang")
return lang
}

func (m *Backend) SetLang(lang string) {
if m.GetLang() != lang {
m.setIntSetting("lang", lang)
logging.Infof("Done setting language!")
}
}
28 changes: 23 additions & 5 deletions frontend/src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
<br />
<span class="subtext">{{ $t("settings.auto_start_sub") }}</span>
</p>
<p style="text-align: left">
{{ $t("settings.language") }}:
<br />
<select style="width: 100%" name="language" v-model="lang">
<option v-for="lang in langs" :key="`locale-${lang}`" :value="lang.code">
{{ lang.name }}
</option>
</select>
<span class="subtext">{{ $t("settings.choose_language") }}</span>
</p>
</div>
<div class="col-settings-sub">
<p style="text-align: left">
Expand Down Expand Up @@ -67,8 +77,11 @@ export default {
testnet: false,
poolID: -1,
pools: [],
lang: '',
langs: []
};
},

created() {
var self = this;
window.backend.Backend.GetClosedSource().then(result => {
Expand All @@ -85,18 +98,21 @@ export default {
self.poolID = result;
window.backend.Backend.GetEnableIntegrated().then(result => {
self.enableIntegrated = result;
window.backend.Backend.GetLangs().then(result => {
self.langs = result;
window.backend.Backend.GetLang().then(result => {
self.lang = result;
});
});
});
});
});
});
});
});
});




},

methods: {
toggleWarning: function() {
this.showWarning = !this.showWarning;
Expand All @@ -111,7 +127,9 @@ export default {
window.backend.Backend.SetTestnet(self.testnet).then(() => {
window.backend.Backend.SetPool(self.poolID).then(() => {
window.backend.Backend.SetEnableIntegrated(self.enableIntegrated).then( () => {
self.$emit("committed");
window.backend.Backend.SetLang(self.lang).then(() => {
self.$emit("committed");
})
});
});
});
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify":"Не проверявайте Verthash при стартиране.",
"skipverthashverify_sub":"Ще пропусне проверката на целостта на Verthash файла при стартиране (не се препоръчва)",
"save_n_restart" : "Запазване и Рестартиране",
"pool": "Минен басейн"
"pool": "Минен басейн",
"language": "език",
"choose_language": "Изберете език за миньора"
},
"tabbar" : {
"wallet" : "Портфейл",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify": "Stop med at verificere Verthash data fil under opstart",
"skipverthashverify_sub": "Spring verifikationen af verthash data filen over (ikke anbefalet)",
"save_n_restart" : "Gem & Genstart",
"pool": "Mining pool"
"pool": "Mining pool",
"language": "Sprog",
"choose_language": "Vælg et sprog til minearbejderen"
},
"tabbar" : {
"wallet" : "Wallet",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify" : "Verthash-Überprüfung beim Start überspringen",
"skipverthashverify_sub" : "Die Prüfung der Datenintegrität der Verthash-Daten beim Start wird übersprungen (nicht empfohlen)",
"save_n_restart" : "Speichern & Neustarten",
"pool" : "Mining-Pool"
"pool" : "Mining-Pool",
"language": "Sprache",
"choose_language": "Wählen Sie eine Sprache für den Miner aus"
},
"tabbar" : {
"wallet" : "Wallet",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify":"Don't verify Verthash on startup",
"skipverthashverify_sub":"Will skip verifying the file integrity of Verthash data on startup (not recommended)",
"save_n_restart" : "Save & Restart",
"pool": "Mining pool"
"pool": "Mining pool",
"language": "Language",
"choose_language": "Select a language for the miner"
},
"tabbar" : {
"wallet" : "Wallet",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify":"No verificar Verthash al encender",
"skipverthashverify_sub":"Se saltará la verificación de la integridad de la información de Verthash al encender (no recomendado)",
"save_n_restart" : "Guardar y reiniciar",
"pool": "Pool de minería"
"pool": "Pool de minería",
"language": "Idioma",
"choose_language": "Selecciona un idioma para el minero"
},
"tabbar" : {
"wallet" : "billetera",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"closed_source" : "Utiliser des logiciels de minage propriétaires",
"closed_source_sub" : "Meilleur taux de hachage, mais logiciel de minage ne rétribuant pas les développeurs",
"closed_source_warning" : "Vous avez choisi d'utiliser des logiciels de minage propriétaires. Vertcoin n'en assure pas le support. Leur contenu ne peut pas être audité et pourrait comporter des fonctions qui endommagent votre ordinateur.",
"save_n_restart" : "Enregistrer & Redémarrer"
"save_n_restart" : "Enregistrer & Redémarrer",
"language": "Langue",
"choose_language": "Sélectionnez une langue pour le mineur"
},
"tabbar" : {
"wallet" : "Portefeuille",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"closed_source" : "बंद-स्रोत खनिक का उपयोग करें",
"closed_source_sub" : "बेहतर हैशेट, लेकिन अघोषित खनिक जो एक डेवलपर के शुल्क को बढ़ाते हैं",
"closed_source_warning" : "आपने बंद स्रोत खननकर्ता का उपयोग करने के लिए चुना है। Vertcoin इन खनिकों का समर्थन या समर्थन नहीं करता है। उनकी सामग्री पर उनका ऑडिट नहीं किया जा सकता है और इसमें आपके कंप्यूटर को नुकसान पहुंचाने वाले कार्य हो सकते हैं।",
"save_n_restart" : "सहेजें और पुनरारंभ करें"
"save_n_restart" : "सहेजें और पुनरारंभ करें",
"language": "भाषा",
"choose_language": "खनिक के लिए एक भाषा चुनें"
},
"tabbar" : {
"wallet" : "बटुआ",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/hr.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"closed_source" : "Koristi softver za rudarenje zatvorenog koda",
"closed_source_sub" : "Bolji hashrate, ali neocijenjeni softver za rudarenje može uključivati naknadu za razvojne inženjere",
"closed_source_warning" : "Odlučili ste koristiti softver(e) za rudarenje zatvorenog koda. Vertcoin ne odobrava i ne podržava njihovu upotrebu. Ne može se provjeriti njihov sadržaj i potencijalno mogu sadržavati funkcije koje mogu oštetiti vaše računalo.",
"save_n_restart" : "Spremi i ponovno pokreni"
"save_n_restart" : "Spremi i ponovno pokreni",
"language": "Jezik",
"choose_language": "Odaberite jezik za rudar"
},
"tabbar" : {
"wallet" : "Novčanik",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify" : "Non verificare Verthash all'avvio",
"skipverthashverify_sub" : "Salta la verifica di integrità del file dei dati di Verthash all'avvio (non raccomandato)",
"save_n_restart" : "Salva e Riavvia",
"pool" : "Pool di mining"
"pool" : "Pool di mining",
"language": "Lingua",
"choose_language": "Scegli una lingua per il minatore"
},
"tabbar" : {
"wallet" : "Portafoglio",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"closed_source" : "クローズドソースマイナーを使用する",
"closed_source_sub" : "ハッシュレートは向上していますが、開発者の費用がかかる未監査のマイナー",
"closed_source_warning" : "クローズドソースマイナーを使用することを選択しました。ヴァートコインはこれらのマイナーを支持しません。内容を監査することはできず、コンピュータに害を及ぼす機能が含まれている可能性があります。",
"save_n_restart" : "保存して再起動"
"save_n_restart" : "保存して再起動",
"language": "言語",
"choose_language": "マイナーの言語を選択してください"
},
"tabbar" : {
"wallet" : "ウォレット",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify":"Paleidžiant netikrinti Verthash",
"skipverthashverify_sub":"Praleisite Verthash duomenų failo patikrinimą paleidžiant programą (nerekomenduojama)",
"save_n_restart" : "Išsaugoti ir perkrauti",
"pool": "Kasėjų pool"
"pool": "Kasėjų pool",
"language": "Kalba",
"choose_language": "Pasirinkite kalnakasio kalbą"
},
"tabbar" : {
"wallet" : "Piniginė",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
"skipverthashverify":"Verifieer Verthash niet bij opstarten",
"skipverthashverify_sub":"Zal het verifiëren van de bestandsintegriteit van Verthash-gegevens bij het opstarten overslaan (niet aanbevolen)",
"save_n_restart" : "Opslaan & Herstarten",
"pool": "Mining pool"
"pool": "Mining pool",
"language": "Taal",
"choose_language": "Kies een taal voor de mijnwerker"
},
"tabbar" : {
"wallet" : "Portemonnee",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"closed_source": "Bruk utvinningsprogramvare med stengt kildekode",
"closed_source_sub": "Bedre hashrate, men ukjente utvinnerprogramvareutvikleren kan ha en avgift for å utvinne",
"closed_source_warning": "Du har valgt å bruke utvinningsprogramvare(r) med lukket kildekode. Vertcoin støtter eller verifiserer ikke disse utvinnerne. Deres kildekode kan ikke verifiseres eller godkjennes, og de kan inneholde funksjoner som skader din datamaskin.",
"save_n_restart": "Lagre og start på nytt"
"save_n_restart": "Lagre og start på nytt",
"language": "Språk",
"choose_language": "Velg et språk for gruvearbeideren"
},
"tabbar": {
"wallet": "Lommebok",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/pa.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify":"ਪੁਸ਼ਟੀ ਨਾ ਕਰੋ ਵਰਥਸ਼ ਸ਼ੁਰੂ 'ਤੇ",
"skipverthashverify_sub":"ਦੀ ਫਾਈਲ ਇਕਸਾਰਤਾ ਦੀ ਪੁਸ਼ਟੀ ਕਰਨਾ ਛੱਡ ਦਿੱਤਾ ਜਾਵੇਗਾ ਵਰਥਸ਼ ਸ਼ੁਰੂਆਤ 'ਤੇ ਡਾਟਾ (ਦੀ ਸਿਫਾਰਸ਼ ਨਹੀਂ ਕੀਤੀ ਜਾਂਦੀ)",
"save_n_restart" : "ਸੇਵ ਅਤੇ ਰੀਸਟਾਰਟ",
"pool": "ਮਾਈਨਿੰਗ ਪੂਲ"
"pool": "ਮਾਈਨਿੰਗ ਪੂਲ",
"language": "ਭਾਸ਼ਾ",
"choose_language": "ਮਾਈਨਰ ਲਈ ਇੱਕ ਭਾਸ਼ਾ ਚੁਣੋ"
},
"tabbar" : {
"wallet" : "ਬਟੂਆ",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
"skipverthashverify" : "Nie weryfikuj Verthash podczas uruchamiania",
"skipverthashverify_sub" : "Weryfikacja integralności pliku verthash.dat podczas uruchamiania zostanie pominięta (niezalecane)",
"save_n_restart" : "Zapisz i Wznów",
"pool" : "Kopalnia"
"pool" : "Kopalnia",
"language": "Język",
"choose_language": "Wybierz język dla górnika"
},
"tabbar" : {
"wallet" : "Portfel",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify":"Não verificar o Verthash na inicialização",
"skipverthashverify_sub":"Irá pular a verificação da integridade do arquivo dos dados do Verthash na inicialização (não recomendado)",
"save_n_restart" : "Gravar & Reiniciar",
"pool": "Pool de Mineração"
"pool": "Pool de Mineração",
"language": "Linguagem",
"choose_language": "Escolha um idioma para o minerador"
},
"tabbar" : {
"wallet" : "Carteira",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"closed_source" : "Folosește mineri closed-source",
"closed_source_sub" : "Au hashrate mai bun, dar sunt mineri neauditați care trimit o taxă către dezvoltator",
"closed_source_warning" : "Ai ales să folosești mineri closed-source. Vertcoin nu este afiliat cu acești mineri și nu oferă suport pentru ei. Conținutul lor nu poate fi auditat și ar putea include funcționalități dăunătoare pentru calculatorul tău.",
"save_n_restart" : "Salvează și repornește"
"save_n_restart" : "Salvează și repornește",
"language": "Limba",
"choose_language": "Alegeți o limbă pentru miner"
},
"tabbar" : {
"wallet" : "Portofel",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify" : "Не проверять файл данных Verthash при запуске",
"skipverthashverify_sub" : "Пропустить проверку целостности файла Verthash.dat при запуске (не рекомендуется)",
"save_n_restart" : "Сохранить и перезапустить",
"pool": "Пул для майнинга"
"pool": "Пул для майнинга",
"language": "Язык",
"choose_language": "Выберите язык для майнера"
},
"tabbar" : {
"wallet" : "Кошелёк",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"closed_source" : "Uporabi zaprto programsko opremo za rudarstvo",
"closed_source_sub" : "Boljši hashrate, vendar neocenjena programska opema, ki lahko vključuje pristojbino za razvojne inženirje",
"closed_source_warning" : "Izbrali ste zaprto programsko opremo za rudarstvo. Vertcoin ne odobrava ali podpira njihovo uporabo. Ne more se preveriti njihovo vsebino tako, da lahko potencijalno vsebuje funkcije, ki lahko poškoduje vaš računalnik.",
"save_n_restart" : "Shrani & Znova zaženi"
"save_n_restart" : "Shrani & Znova zaženi",
"language": "Jezik",
"choose_language": "Izberite jezik za rudar"
},
"tabbar" : {
"wallet" : "Denarnica",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"skipverthashverify": "Verifiera inte verthash under start",
"skipverthashverify_sub": "Kommer inte att verifiera verthash data file under uppstart (rekomenderas inte)",
"save_n_restart": "Spara & starta om",
"pool": "Mining pool"
"pool": "Mining pool",
"language": "Språk",
"choose_language": "Välj ett språk för gruvarbetaren"
},
"tabbar": {
"wallet": "Plånbok",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@
"skipverthashverify":"Başlangıçta Verthash'i doğrulama",
"skipverthashverify_sub":"Başlangıçta Verthash dosyasının bütünlüğünü doğrulamayı atlayacak (önerilmez)",
"save_n_restart" : "Kaydet ve Yeniden Başlat",
"pool": "Madenci havuzu"
"pool": "Madenci havuzu",
"language": "Dil",
"choose_language": "Madenci için bir dil seçin"
},
"tabbar" : {
"wallet" : "Cüzdan",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"closed_source" : "使用闭源的矿工",
"closed_source_sub" : "更好的哈希率,但是未经审核的矿工会产生开发人员的费用",
"closed_source_warning" : "你选择使用闭源的矿工。绿币(VTC)不支持这些矿工。他们无法对其内容进行审核并且可能包含损害你的电脑的功能。",
"save_n_restart" : "保存及重启"
"save_n_restart" : "保存及重启",
"language": "语",
"choose_language": "为矿工选择一种语言"
},
"tabbar" : {
"wallet" : "钱包",
Expand Down
22 changes: 22 additions & 0 deletions langs/lang.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package langs

type Lang interface {
GetCode() string
GetName() string
}

func GetLangs(lang string) []Lang {
return []Lang{
// add all languages
}
}

func GetLang(lang string) Lang {
langs := GetLangs(lang)
for _, p := range langs {
if p.GetCode() == lang {
return p
}
}
return langs[0]
}