From 26a361d873036b79bd5581af0ceb95ce7b08ba75 Mon Sep 17 00:00:00 2001 From: Fillerino Date: Sun, 2 Jul 2017 21:13:37 +0200 Subject: [PATCH 01/17] Added Language Downloading and Settings Added basic downloading of languages and a dynamic settings panel which allows the user to change the language between the downloaded ones. --- .gitignore | 1 + ui/js/langs.js | 196 +++++++++++++++++++++++++++++++++++ ui/js/main.js | 39 +++++++ ui/js/page/settings/view.jsx | 38 +++++++ 4 files changed, 274 insertions(+) create mode 100644 ui/js/langs.js diff --git a/.gitignore b/.gitignore index c212707ad..5ec3a5c07 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /app/dist +/app/locales /app/node_modules /build/venv /lbry-app-venv diff --git a/ui/js/langs.js b/ui/js/langs.js new file mode 100644 index 000000000..8bc52581f --- /dev/null +++ b/ui/js/langs.js @@ -0,0 +1,196 @@ +/* + This file contains the function to resolve a 2-letter country code + to the language name in both english and the local language. +*/ +const langs = { +"aa":["Afar","Afar"], +"ab":["Abkhazian","Аҧсуа"], +"af":["Afrikaans","Afrikaans"], +"ak":["Akan","Akana"], +"am":["Amharic","አማርኛ"], +"an":["Aragonese","Aragonés"], +"ar":["Arabic","العربية"], +"as":["Assamese","অসমীয়া"], +"av":["Avar","Авар"], +"ay":["Aymara","Aymar"], +"az":["Azerbaijani","Azərbaycanca / آذربايجان"], +"ba":["Bashkir","Башҡорт"], +"be":["Belarusian","Беларуская"], +"bg":["Bulgarian","Български"], +"bh":["Bihari","भोजपुरी"], +"bi":["Bislama","Bislama"], +"bm":["Bambara","Bamanankan"], +"bn":["Bengali","বাংলা"], +"bo":["Tibetan","བོད་ཡིག / Bod skad"], +"br":["Breton","Brezhoneg"], +"bs":["Bosnian","Bosanski"], +"ca":["Catalan","Català"], +"ce":["Chechen","Нохчийн"], +"ch":["Chamorro","Chamoru"], +"co":["Corsican","Corsu"], +"cr":["Cree","Nehiyaw"], +"cs":["Czech","Česky"], +"cu":["Old Church Slavonic / Old Bulgarian","словѣньскъ / slověnĭskŭ"], +"cv":["Chuvash","Чăваш"], +"cy":["Welsh","Cymraeg"], +"da":["Danish","Dansk"], +"de":["German","Deutsch"], +"dv":["Divehi","ދިވެހިބަސް"], +"dz":["Dzongkha","ཇོང་ཁ"], +"ee":["Ewe","Ɛʋɛ"], +"el":["Greek","Ελληνικά"], +"en":["English","English"], +"eo":["Esperanto","Esperanto"], +"es":["Spanish","Español"], +"et":["Estonian","Eesti"], +"eu":["Basque","Euskara"], +"fa":["Persian","فارسی"], +"ff":["Peul","Fulfulde"], +"fi":["Finnish","Suomi"], +"fj":["Fijian","Na Vosa Vakaviti"], +"fo":["Faroese","Føroyskt"], +"fr":["French","Français"], +"fy":["West Frisian","Frysk"], +"ga":["Irish","Gaeilge"], +"gd":["Scottish Gaelic","Gàidhlig"], +"gl":["Galician","Galego"], +"gn":["Guarani","Avañe'ẽ"], +"gu":["Gujarati","ગુજરાતી"], +"gv":["Manx","Gaelg"], +"ha":["Hausa","هَوُسَ"], +"he":["Hebrew","עברית"], +"hi":["Hindi","हिन्दी"], +"ho":["Hiri Motu","Hiri Motu"], +"hr":["Croatian","Hrvatski"], +"ht":["Haitian","Krèyol ayisyen"], +"hu":["Hungarian","Magyar"], +"hy":["Armenian","Հայերեն"], +"hz":["Herero","Otsiherero"], +"ia":["Interlingua","Interlingua"], +"id":["Indonesian","Bahasa Indonesia"], +"ie":["Interlingue","Interlingue"], +"ig":["Igbo","Igbo"], +"ii":["Sichuan Yi","ꆇꉙ / 四川彝语"], +"ik":["Inupiak","Iñupiak"], +"io":["Ido","Ido"], +"is":["Icelandic","Íslenska"], +"it":["Italian","Italiano"], +"iu":["Inuktitut","ᐃᓄᒃᑎᑐᑦ"], +"ja":["Japanese","日本語"], +"jv":["Javanese","Basa Jawa"], +"ka":["Georgian","ქართული"], +"kg":["Kongo","KiKongo"], +"ki":["Kikuyu","Gĩkũyũ"], +"kj":["Kuanyama","Kuanyama"], +"kk":["Kazakh","Қазақша"], +"kl":["Greenlandic","Kalaallisut"], +"km":["Cambodian","ភាសាខ្មែរ"], +"kn":["Kannada","ಕನ್ನಡ"], +"ko":["Korean","한국어"], +"kr":["Kanuri","Kanuri"], +"ks":["Kashmiri","कश्मीरी / كشميري"], +"ku":["Kurdish","Kurdî / كوردی"], +"kv":["Komi","Коми"], +"kw":["Cornish","Kernewek"], +"ky":["Kirghiz","Kırgızca / Кыргызча"], +"la":["Latin","Latina"], +"lb":["Luxembourgish","Lëtzebuergesch"], +"lg":["Ganda","Luganda"], +"li":["Limburgian","Limburgs"], +"ln":["Lingala","Lingála"], +"lo":["Laotian","ລາວ / Pha xa lao"], +"lt":["Lithuanian","Lietuvių"], +"lv":["Latvian","Latviešu"], +"mg":["Malagasy","Malagasy"], +"mh":["Marshallese","Kajin Majel / Ebon"], +"mi":["Maori","Māori"], +"mk":["Macedonian","Македонски"], +"ml":["Malayalam","മലയാളം"], +"mn":["Mongolian","Монгол"], +"mo":["Moldovan","Moldovenească"], +"mr":["Marathi","मराठी"], +"ms":["Malay","Bahasa Melayu"], +"mt":["Maltese","bil-Malti"], +"my":["Burmese","Myanmasa"], +"na":["Nauruan","Dorerin Naoero"], +"nd":["North Ndebele","Sindebele"], +"ne":["Nepali","नेपाली"], +"ng":["Ndonga","Oshiwambo"], +"nl":["Dutch","Nederlands"], +"nn":["Norwegian Nynorsk","Norsk (nynorsk)"], +"no":["Norwegian","Norsk (bokmål / riksmål)"], +"nr":["South Ndebele","isiNdebele"], +"nv":["Navajo","Diné bizaad"], +"ny":["Chichewa","Chi-Chewa"], +"oc":["Occitan","Occitan"], +"oj":["Ojibwa","ᐊᓂᔑᓈᐯᒧᐎᓐ / Anishinaabemowin"], +"om":["Oromo","Oromoo"], +"or":["Oriya","ଓଡ଼ିଆ"], +"os":["Ossetian / Ossetic","Иронау"], +"pa":["Panjabi / Punjabi","ਪੰਜਾਬੀ / पंजाबी / پنجابي"], +"pi":["Pali","Pāli / पाऴि"], +"pl":["Polish","Polski"], +"ps":["Pashto","پښتو"], +"pt":["Portuguese","Português"], +"qu":["Quechua","Runa Simi"], +"rm":["Raeto Romance","Rumantsch"], +"rn":["Kirundi","Kirundi"], +"ro":["Romanian","Română"], +"ru":["Russian","Русский"], +"rw":["Rwandi","Kinyarwandi"], +"sa":["Sanskrit","संस्कृतम्"], +"sc":["Sardinian","Sardu"], +"sd":["Sindhi","सिनधि"], +"se":["Northern Sami","Sámegiella"], +"sg":["Sango","Sängö"], +"sh":["Serbo-Croatian","Srpskohrvatski / Српскохрватски"], +"si":["Sinhalese","සිංහල"], +"sk":["Slovak","Slovenčina"], +"sl":["Slovenian","Slovenščina"], +"sm":["Samoan","Gagana Samoa"], +"sn":["Shona","chiShona"], +"so":["Somalia","Soomaaliga"], +"sq":["Albanian","Shqip"], +"sr":["Serbian","Српски"], +"ss":["Swati","SiSwati"], +"st":["Southern Sotho","Sesotho"], +"su":["Sundanese","Basa Sunda"], +"sv":["Swedish","Svenska"], +"sw":["Swahili","Kiswahili"], +"ta":["Tamil","தமிழ்"], +"te":["Telugu","తెలుగు"], +"tg":["Tajik","Тоҷикӣ"], +"th":["Thai","ไทย / Phasa Thai"], +"ti":["Tigrinya","ትግርኛ"], +"tk":["Turkmen","Туркмен / تركمن"], +"tl":["Tagalog / Filipino","Tagalog"], +"tn":["Tswana","Setswana"], +"to":["Tonga","Lea Faka-Tonga"], +"tr":["Turkish","Türkçe"], +"ts":["Tsonga","Xitsonga"], +"tt":["Tatar","Tatarça"], +"tw":["Twi","Twi"], +"ty":["Tahitian","Reo Mā`ohi"], +"ug":["Uyghur","Uyƣurqə / ئۇيغۇرچە"], +"uk":["Ukrainian","Українська"], +"ur":["Urdu","اردو"], +"uz":["Uzbek","Ўзбек"], +"ve":["Venda","Tshivenḓa"], +"vi":["Vietnamese","Tiếng Việt"], +"vo":["Volapük","Volapük"], +"wa":["Walloon","Walon"], +"wo":["Wolof","Wollof"], +"xh":["Xhosa","isiXhosa"], +"yi":["Yiddish","ייִדיש"], +"yo":["Yoruba","Yorùbá"], +"za":["Zhuang","Cuengh / Tôô / 壮语"], +"zh":["Chinese","中文"], +"zu":["Zulu","isiZulu"] +} + +const resLang = function(uLang) { + this.lang = uLang.substring(0, 2); + return (`${langs[this.lang][0]} (${langs[this.lang][1]})`) +} + +export default resLang; \ No newline at end of file diff --git a/ui/js/main.js b/ui/js/main.js index 9bef9aae1..1437fddce 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -11,11 +11,14 @@ import { doChangePath, doNavigate, doDaemonReady } from "actions/app"; import { toQueryString } from "util/query_params"; import { selectBadgeNumber } from "selectors/app"; import * as types from "constants/action_types"; +import fs from "fs"; +import http from "http"; const env = ENV; const { remote, ipcRenderer, shell } = require("electron"); const contextMenu = remote.require("./menu/context-menu"); const app = require("./app"); +app.i18n.resLang = require("./langs").default; lbry.showMenuIfNeeded(); @@ -130,4 +133,40 @@ var init = function() { } }; +const download = (url, dest, lang, cb) => { + const file = fs.createWriteStream(dest); + const request = http.get(url, response => { + response.pipe(file); + file.on('finish', () => { + file.close(cb); // close() is async, call cb after close completes. + app.i18n.localLanguages.push(lang.replace(".json", "")); // push to our local list + }); + }).on('error', err => { // Handle errors + fs.unlink(dest); // Delete the file async. (But we don't check the result) + if (cb) cb(err.message); + }); +}; + +const downloadLanguages = () => { + if (!fs.existsSync("app/locales")){ + fs.mkdirSync("app/locales"); + } + http.request({ host: 'i18n.lbry.io', path: '/' }, response => { + let str = ''; + + response.on('data', chunk => { + str += chunk; + }); + + response.on('end', () => { + const files = JSON.parse(str);JSON.parse(str); + app.i18n.localLanguages = []; + for (let i = 0; i < files.length; i++) { + download(`http://i18n.lbry.io/langs/${files[i]}`, `app/locales/${files[i]}`, files[i], () => {}); + } + }); + }).end(); +}; + +downloadLanguages(); init(); diff --git a/ui/js/page/settings/view.jsx b/ui/js/page/settings/view.jsx index 7704a37e1..4530f0b51 100644 --- a/ui/js/page/settings/view.jsx +++ b/ui/js/page/settings/view.jsx @@ -85,6 +85,12 @@ class SettingsPage extends React.PureComponent { this.props.setClientSetting("showNsfw", event.target.checked); } + onLanguageChange(language) { + lbry.setClientSetting('language', language); + window.app.i18n.setLocale(language); + this.setState({language: language}) + } + // onLanguageChange(language) { // lbry.setClientSetting('language', language); // i18n.setLocale(language); @@ -151,6 +157,38 @@ class SettingsPage extends React.PureComponent { return (
+
+
+

{__("Language")}

+
+
+
+ { + this.onLanguageChange("en"); + }} + defaultChecked={this.state.language == "en"} + /> +
+ {window.app.i18n.localLanguages.map((dLang) => ( +
+ { + this.onLanguageChange(dLang); + }} + defaultChecked={this.state.language == dLang} + /> +
+ ))} +
+

{__("Download Directory")}

From fdb3b1849c0660c6fb75e9e2373462ae732b0878 Mon Sep 17 00:00:00 2001 From: Fillerino Date: Tue, 4 Jul 2017 20:43:45 +0200 Subject: [PATCH 02/17] Moved the resLang function into utils to reduce top level files. --- ui/js/main.js | 2 +- ui/js/utils.js | 194 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 1 deletion(-) diff --git a/ui/js/main.js b/ui/js/main.js index 1437fddce..ba0cfdf54 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -18,7 +18,7 @@ const env = ENV; const { remote, ipcRenderer, shell } = require("electron"); const contextMenu = remote.require("./menu/context-menu"); const app = require("./app"); -app.i18n.resLang = require("./langs").default; +app.i18n.resLang = require("./utils").resLang; lbry.showMenuIfNeeded(); diff --git a/ui/js/utils.js b/ui/js/utils.js index 783f85113..682a79b53 100644 --- a/ui/js/utils.js +++ b/ui/js/utils.js @@ -29,3 +29,197 @@ export function getSession(key, fallback = undefined) { export function setSession(key, value) { sessionStorage.setItem(key, JSON.stringify(value)); } + +/** + * This file contains the function to resolve a 2-letter country code + * to the language name in both english and the local language. + */ +export function resLang(uLang) { + this.langs = { + aa: ["Afar", "Afar"], + ab: ["Abkhazian", "Аҧсуа"], + af: ["Afrikaans", "Afrikaans"], + ak: ["Akan", "Akana"], + am: ["Amharic", "አማርኛ"], + an: ["Aragonese", "Aragonés"], + ar: ["Arabic", "العربية"], + as: ["Assamese", "অসমীয়া"], + av: ["Avar", "Авар"], + ay: ["Aymara", "Aymar"], + az: ["Azerbaijani", "Azərbaycanca / آذربايجان"], + ba: ["Bashkir", "Башҡорт"], + be: ["Belarusian", "Беларуская"], + bg: ["Bulgarian", "Български"], + bh: ["Bihari", "भोजपुरी"], + bi: ["Bislama", "Bislama"], + bm: ["Bambara", "Bamanankan"], + bn: ["Bengali", "বাংলা"], + bo: ["Tibetan", "བོད་ཡིག / Bod skad"], + br: ["Breton", "Brezhoneg"], + bs: ["Bosnian", "Bosanski"], + ca: ["Catalan", "Català"], + ce: ["Chechen", "Нохчийн"], + ch: ["Chamorro", "Chamoru"], + co: ["Corsican", "Corsu"], + cr: ["Cree", "Nehiyaw"], + cs: ["Czech", "Česky"], + cu: ["Old Church Slavonic / Old Bulgarian", "словѣньскъ / slověnĭskŭ"], + cv: ["Chuvash", "Чăваш"], + cy: ["Welsh", "Cymraeg"], + da: ["Danish", "Dansk"], + de: ["German", "Deutsch"], + dv: ["Divehi", "ދިވެހިބަސް"], + dz: ["Dzongkha", "ཇོང་ཁ"], + ee: ["Ewe", "Ɛʋɛ"], + el: ["Greek", "Ελληνικά"], + en: ["English", "English"], + eo: ["Esperanto", "Esperanto"], + es: ["Spanish", "Español"], + et: ["Estonian", "Eesti"], + eu: ["Basque", "Euskara"], + fa: ["Persian", "فارسی"], + ff: ["Peul", "Fulfulde"], + fi: ["Finnish", "Suomi"], + fj: ["Fijian", "Na Vosa Vakaviti"], + fo: ["Faroese", "Føroyskt"], + fr: ["French", "Français"], + fy: ["West Frisian", "Frysk"], + ga: ["Irish", "Gaeilge"], + gd: ["Scottish Gaelic", "Gàidhlig"], + gl: ["Galician", "Galego"], + gn: ["Guarani", "Avañe'ẽ"], + gu: ["Gujarati", "ગુજરાતી"], + gv: ["Manx", "Gaelg"], + ha: ["Hausa", "هَوُسَ"], + he: ["Hebrew", "עברית"], + hi: ["Hindi", "हिन्दी"], + ho: ["Hiri Motu", "Hiri Motu"], + hr: ["Croatian", "Hrvatski"], + ht: ["Haitian", "Krèyol ayisyen"], + hu: ["Hungarian", "Magyar"], + hy: ["Armenian", "Հայերեն"], + hz: ["Herero", "Otsiherero"], + ia: ["Interlingua", "Interlingua"], + id: ["Indonesian", "Bahasa Indonesia"], + ie: ["Interlingue", "Interlingue"], + ig: ["Igbo", "Igbo"], + ii: ["Sichuan Yi", "ꆇꉙ / 四川彝语"], + ik: ["Inupiak", "Iñupiak"], + io: ["Ido", "Ido"], + is: ["Icelandic", "Íslenska"], + it: ["Italian", "Italiano"], + iu: ["Inuktitut", "ᐃᓄᒃᑎᑐᑦ"], + ja: ["Japanese", "日本語"], + jv: ["Javanese", "Basa Jawa"], + ka: ["Georgian", "ქართული"], + kg: ["Kongo", "KiKongo"], + ki: ["Kikuyu", "Gĩkũyũ"], + kj: ["Kuanyama", "Kuanyama"], + kk: ["Kazakh", "Қазақша"], + kl: ["Greenlandic", "Kalaallisut"], + km: ["Cambodian", "ភាសាខ្មែរ"], + kn: ["Kannada", "ಕನ್ನಡ"], + ko: ["Korean", "한국어"], + kr: ["Kanuri", "Kanuri"], + ks: ["Kashmiri", "कश्मीरी / كشميري"], + ku: ["Kurdish", "Kurdî / كوردی"], + kv: ["Komi", "Коми"], + kw: ["Cornish", "Kernewek"], + ky: ["Kirghiz", "Kırgızca / Кыргызча"], + la: ["Latin", "Latina"], + lb: ["Luxembourgish", "Lëtzebuergesch"], + lg: ["Ganda", "Luganda"], + li: ["Limburgian", "Limburgs"], + ln: ["Lingala", "Lingála"], + lo: ["Laotian", "ລາວ / Pha xa lao"], + lt: ["Lithuanian", "Lietuvių"], + lv: ["Latvian", "Latviešu"], + mg: ["Malagasy", "Malagasy"], + mh: ["Marshallese", "Kajin Majel / Ebon"], + mi: ["Maori", "Māori"], + mk: ["Macedonian", "Македонски"], + ml: ["Malayalam", "മലയാളം"], + mn: ["Mongolian", "Монгол"], + mo: ["Moldovan", "Moldovenească"], + mr: ["Marathi", "मराठी"], + ms: ["Malay", "Bahasa Melayu"], + mt: ["Maltese", "bil-Malti"], + my: ["Burmese", "Myanmasa"], + na: ["Nauruan", "Dorerin Naoero"], + nd: ["North Ndebele", "Sindebele"], + ne: ["Nepali", "नेपाली"], + ng: ["Ndonga", "Oshiwambo"], + nl: ["Dutch", "Nederlands"], + nn: ["Norwegian Nynorsk", "Norsk (nynorsk)"], + no: ["Norwegian", "Norsk (bokmål / riksmål)"], + nr: ["South Ndebele", "isiNdebele"], + nv: ["Navajo", "Diné bizaad"], + ny: ["Chichewa", "Chi-Chewa"], + oc: ["Occitan", "Occitan"], + oj: ["Ojibwa", "ᐊᓂᔑᓈᐯᒧᐎᓐ / Anishinaabemowin"], + om: ["Oromo", "Oromoo"], + or: ["Oriya", "ଓଡ଼ିଆ"], + os: ["Ossetian / Ossetic", "Иронау"], + pa: ["Panjabi / Punjabi", "ਪੰਜਾਬੀ / पंजाबी / پنجابي"], + pi: ["Pali", "Pāli / पाऴि"], + pl: ["Polish", "Polski"], + ps: ["Pashto", "پښتو"], + pt: ["Portuguese", "Português"], + qu: ["Quechua", "Runa Simi"], + rm: ["Raeto Romance", "Rumantsch"], + rn: ["Kirundi", "Kirundi"], + ro: ["Romanian", "Română"], + ru: ["Russian", "Русский"], + rw: ["Rwandi", "Kinyarwandi"], + sa: ["Sanskrit", "संस्कृतम्"], + sc: ["Sardinian", "Sardu"], + sd: ["Sindhi", "सिनधि"], + se: ["Northern Sami", "Sámegiella"], + sg: ["Sango", "Sängö"], + sh: ["Serbo-Croatian", "Srpskohrvatski / Српскохрватски"], + si: ["Sinhalese", "සිංහල"], + sk: ["Slovak", "Slovenčina"], + sl: ["Slovenian", "Slovenščina"], + sm: ["Samoan", "Gagana Samoa"], + sn: ["Shona", "chiShona"], + so: ["Somalia", "Soomaaliga"], + sq: ["Albanian", "Shqip"], + sr: ["Serbian", "Српски"], + ss: ["Swati", "SiSwati"], + st: ["Southern Sotho", "Sesotho"], + su: ["Sundanese", "Basa Sunda"], + sv: ["Swedish", "Svenska"], + sw: ["Swahili", "Kiswahili"], + ta: ["Tamil", "தமிழ்"], + te: ["Telugu", "తెలుగు"], + tg: ["Tajik", "Тоҷикӣ"], + th: ["Thai", "ไทย / Phasa Thai"], + ti: ["Tigrinya", "ትግርኛ"], + tk: ["Turkmen", "Туркмен / تركمن"], + tl: ["Tagalog / Filipino", "Tagalog"], + tn: ["Tswana", "Setswana"], + to: ["Tonga", "Lea Faka-Tonga"], + tr: ["Turkish", "Türkçe"], + ts: ["Tsonga", "Xitsonga"], + tt: ["Tatar", "Tatarça"], + tw: ["Twi", "Twi"], + ty: ["Tahitian", "Reo Mā`ohi"], + ug: ["Uyghur", "Uyƣurqə / ئۇيغۇرچە"], + uk: ["Ukrainian", "Українська"], + ur: ["Urdu", "اردو"], + uz: ["Uzbek", "Ўзбек"], + ve: ["Venda", "Tshivenḓa"], + vi: ["Vietnamese", "Tiếng Việt"], + vo: ["Volapük", "Volapük"], + wa: ["Walloon", "Walon"], + wo: ["Wolof", "Wollof"], + xh: ["Xhosa", "isiXhosa"], + yi: ["Yiddish", "ייִדיש"], + yo: ["Yoruba", "Yorùbá"], + za: ["Zhuang", "Cuengh / Tôô / 壮语"], + zh: ["Chinese", "中文"], + zu: ["Zulu", "isiZulu"], + }; + this.lang = uLang.substring(0, 2); + return `${this.langs[this.lang][0]} (${this.langs[this.lang][1]})`; +} From d41c9295bdd6ccc745429e28ce971ee9361f6171 Mon Sep 17 00:00:00 2001 From: Fillerino Date: Tue, 4 Jul 2017 20:45:35 +0200 Subject: [PATCH 03/17] =?UTF-8?q?Removed=20the=20old=20langs=20file=20as?= =?UTF-8?q?=20it=C2=B4s=20not=20needed=20anymore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/js/langs.js | 196 ------------------------------------------------- 1 file changed, 196 deletions(-) delete mode 100644 ui/js/langs.js diff --git a/ui/js/langs.js b/ui/js/langs.js deleted file mode 100644 index 8bc52581f..000000000 --- a/ui/js/langs.js +++ /dev/null @@ -1,196 +0,0 @@ -/* - This file contains the function to resolve a 2-letter country code - to the language name in both english and the local language. -*/ -const langs = { -"aa":["Afar","Afar"], -"ab":["Abkhazian","Аҧсуа"], -"af":["Afrikaans","Afrikaans"], -"ak":["Akan","Akana"], -"am":["Amharic","አማርኛ"], -"an":["Aragonese","Aragonés"], -"ar":["Arabic","العربية"], -"as":["Assamese","অসমীয়া"], -"av":["Avar","Авар"], -"ay":["Aymara","Aymar"], -"az":["Azerbaijani","Azərbaycanca / آذربايجان"], -"ba":["Bashkir","Башҡорт"], -"be":["Belarusian","Беларуская"], -"bg":["Bulgarian","Български"], -"bh":["Bihari","भोजपुरी"], -"bi":["Bislama","Bislama"], -"bm":["Bambara","Bamanankan"], -"bn":["Bengali","বাংলা"], -"bo":["Tibetan","བོད་ཡིག / Bod skad"], -"br":["Breton","Brezhoneg"], -"bs":["Bosnian","Bosanski"], -"ca":["Catalan","Català"], -"ce":["Chechen","Нохчийн"], -"ch":["Chamorro","Chamoru"], -"co":["Corsican","Corsu"], -"cr":["Cree","Nehiyaw"], -"cs":["Czech","Česky"], -"cu":["Old Church Slavonic / Old Bulgarian","словѣньскъ / slověnĭskŭ"], -"cv":["Chuvash","Чăваш"], -"cy":["Welsh","Cymraeg"], -"da":["Danish","Dansk"], -"de":["German","Deutsch"], -"dv":["Divehi","ދިވެހިބަސް"], -"dz":["Dzongkha","ཇོང་ཁ"], -"ee":["Ewe","Ɛʋɛ"], -"el":["Greek","Ελληνικά"], -"en":["English","English"], -"eo":["Esperanto","Esperanto"], -"es":["Spanish","Español"], -"et":["Estonian","Eesti"], -"eu":["Basque","Euskara"], -"fa":["Persian","فارسی"], -"ff":["Peul","Fulfulde"], -"fi":["Finnish","Suomi"], -"fj":["Fijian","Na Vosa Vakaviti"], -"fo":["Faroese","Føroyskt"], -"fr":["French","Français"], -"fy":["West Frisian","Frysk"], -"ga":["Irish","Gaeilge"], -"gd":["Scottish Gaelic","Gàidhlig"], -"gl":["Galician","Galego"], -"gn":["Guarani","Avañe'ẽ"], -"gu":["Gujarati","ગુજરાતી"], -"gv":["Manx","Gaelg"], -"ha":["Hausa","هَوُسَ"], -"he":["Hebrew","עברית"], -"hi":["Hindi","हिन्दी"], -"ho":["Hiri Motu","Hiri Motu"], -"hr":["Croatian","Hrvatski"], -"ht":["Haitian","Krèyol ayisyen"], -"hu":["Hungarian","Magyar"], -"hy":["Armenian","Հայերեն"], -"hz":["Herero","Otsiherero"], -"ia":["Interlingua","Interlingua"], -"id":["Indonesian","Bahasa Indonesia"], -"ie":["Interlingue","Interlingue"], -"ig":["Igbo","Igbo"], -"ii":["Sichuan Yi","ꆇꉙ / 四川彝语"], -"ik":["Inupiak","Iñupiak"], -"io":["Ido","Ido"], -"is":["Icelandic","Íslenska"], -"it":["Italian","Italiano"], -"iu":["Inuktitut","ᐃᓄᒃᑎᑐᑦ"], -"ja":["Japanese","日本語"], -"jv":["Javanese","Basa Jawa"], -"ka":["Georgian","ქართული"], -"kg":["Kongo","KiKongo"], -"ki":["Kikuyu","Gĩkũyũ"], -"kj":["Kuanyama","Kuanyama"], -"kk":["Kazakh","Қазақша"], -"kl":["Greenlandic","Kalaallisut"], -"km":["Cambodian","ភាសាខ្មែរ"], -"kn":["Kannada","ಕನ್ನಡ"], -"ko":["Korean","한국어"], -"kr":["Kanuri","Kanuri"], -"ks":["Kashmiri","कश्मीरी / كشميري"], -"ku":["Kurdish","Kurdî / كوردی"], -"kv":["Komi","Коми"], -"kw":["Cornish","Kernewek"], -"ky":["Kirghiz","Kırgızca / Кыргызча"], -"la":["Latin","Latina"], -"lb":["Luxembourgish","Lëtzebuergesch"], -"lg":["Ganda","Luganda"], -"li":["Limburgian","Limburgs"], -"ln":["Lingala","Lingála"], -"lo":["Laotian","ລາວ / Pha xa lao"], -"lt":["Lithuanian","Lietuvių"], -"lv":["Latvian","Latviešu"], -"mg":["Malagasy","Malagasy"], -"mh":["Marshallese","Kajin Majel / Ebon"], -"mi":["Maori","Māori"], -"mk":["Macedonian","Македонски"], -"ml":["Malayalam","മലയാളം"], -"mn":["Mongolian","Монгол"], -"mo":["Moldovan","Moldovenească"], -"mr":["Marathi","मराठी"], -"ms":["Malay","Bahasa Melayu"], -"mt":["Maltese","bil-Malti"], -"my":["Burmese","Myanmasa"], -"na":["Nauruan","Dorerin Naoero"], -"nd":["North Ndebele","Sindebele"], -"ne":["Nepali","नेपाली"], -"ng":["Ndonga","Oshiwambo"], -"nl":["Dutch","Nederlands"], -"nn":["Norwegian Nynorsk","Norsk (nynorsk)"], -"no":["Norwegian","Norsk (bokmål / riksmål)"], -"nr":["South Ndebele","isiNdebele"], -"nv":["Navajo","Diné bizaad"], -"ny":["Chichewa","Chi-Chewa"], -"oc":["Occitan","Occitan"], -"oj":["Ojibwa","ᐊᓂᔑᓈᐯᒧᐎᓐ / Anishinaabemowin"], -"om":["Oromo","Oromoo"], -"or":["Oriya","ଓଡ଼ିଆ"], -"os":["Ossetian / Ossetic","Иронау"], -"pa":["Panjabi / Punjabi","ਪੰਜਾਬੀ / पंजाबी / پنجابي"], -"pi":["Pali","Pāli / पाऴि"], -"pl":["Polish","Polski"], -"ps":["Pashto","پښتو"], -"pt":["Portuguese","Português"], -"qu":["Quechua","Runa Simi"], -"rm":["Raeto Romance","Rumantsch"], -"rn":["Kirundi","Kirundi"], -"ro":["Romanian","Română"], -"ru":["Russian","Русский"], -"rw":["Rwandi","Kinyarwandi"], -"sa":["Sanskrit","संस्कृतम्"], -"sc":["Sardinian","Sardu"], -"sd":["Sindhi","सिनधि"], -"se":["Northern Sami","Sámegiella"], -"sg":["Sango","Sängö"], -"sh":["Serbo-Croatian","Srpskohrvatski / Српскохрватски"], -"si":["Sinhalese","සිංහල"], -"sk":["Slovak","Slovenčina"], -"sl":["Slovenian","Slovenščina"], -"sm":["Samoan","Gagana Samoa"], -"sn":["Shona","chiShona"], -"so":["Somalia","Soomaaliga"], -"sq":["Albanian","Shqip"], -"sr":["Serbian","Српски"], -"ss":["Swati","SiSwati"], -"st":["Southern Sotho","Sesotho"], -"su":["Sundanese","Basa Sunda"], -"sv":["Swedish","Svenska"], -"sw":["Swahili","Kiswahili"], -"ta":["Tamil","தமிழ்"], -"te":["Telugu","తెలుగు"], -"tg":["Tajik","Тоҷикӣ"], -"th":["Thai","ไทย / Phasa Thai"], -"ti":["Tigrinya","ትግርኛ"], -"tk":["Turkmen","Туркмен / تركمن"], -"tl":["Tagalog / Filipino","Tagalog"], -"tn":["Tswana","Setswana"], -"to":["Tonga","Lea Faka-Tonga"], -"tr":["Turkish","Türkçe"], -"ts":["Tsonga","Xitsonga"], -"tt":["Tatar","Tatarça"], -"tw":["Twi","Twi"], -"ty":["Tahitian","Reo Mā`ohi"], -"ug":["Uyghur","Uyƣurqə / ئۇيغۇرچە"], -"uk":["Ukrainian","Українська"], -"ur":["Urdu","اردو"], -"uz":["Uzbek","Ўзбек"], -"ve":["Venda","Tshivenḓa"], -"vi":["Vietnamese","Tiếng Việt"], -"vo":["Volapük","Volapük"], -"wa":["Walloon","Walon"], -"wo":["Wolof","Wollof"], -"xh":["Xhosa","isiXhosa"], -"yi":["Yiddish","ייִדיש"], -"yo":["Yoruba","Yorùbá"], -"za":["Zhuang","Cuengh / Tôô / 壮语"], -"zh":["Chinese","中文"], -"zu":["Zulu","isiZulu"] -} - -const resLang = function(uLang) { - this.lang = uLang.substring(0, 2); - return (`${langs[this.lang][0]} (${langs[this.lang][1]})`) -} - -export default resLang; \ No newline at end of file From d733a7b1b47502f23b7c541df857113e12656fde Mon Sep 17 00:00:00 2001 From: Fillerino Date: Fri, 7 Jul 2017 15:15:45 +0200 Subject: [PATCH 04/17] Trying to get redux stuff to work... --- ui/js/actions/app.js | 8 ++++++++ ui/js/constants/action_types.js | 3 +++ ui/js/page/settings/index.js | 6 ++++-- ui/js/page/settings/view.jsx | 10 ++++------ ui/js/reducers/settings.js | 1 + ui/js/selectors/app.js | 5 +++++ 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js index 35049d435..62eaeb5e1 100644 --- a/ui/js/actions/app.js +++ b/ui/js/actions/app.js @@ -248,3 +248,11 @@ export function doClearCache() { return Promise.resolve(); }; } + +export function doChangeLanguage(newLanguage) { + app.i18n.setLocale(newLanguage); + return { + type: types.CHANGE_LANGUAGE, + data: { newLanguage: newLanguage } + } +} diff --git a/ui/js/constants/action_types.js b/ui/js/constants/action_types.js index 216c84762..32f7b3ef3 100644 --- a/ui/js/constants/action_types.js +++ b/ui/js/constants/action_types.js @@ -97,3 +97,6 @@ export const CLAIM_REWARD_STARTED = "CLAIM_REWARD_STARTED"; export const CLAIM_REWARD_SUCCESS = "CLAIM_REWARD_SUCCESS"; export const CLAIM_REWARD_FAILURE = "CLAIM_REWARD_FAILURE"; export const CLAIM_REWARD_CLEAR_ERROR = "CLAIM_REWARD_CLEAR_ERROR"; + +//Language +export const LANGUAGE_CHANGED = "LANGUAGE_CHANGED"; \ No newline at end of file diff --git a/ui/js/page/settings/index.js b/ui/js/page/settings/index.js index c74b918af..bd41c6844 100644 --- a/ui/js/page/settings/index.js +++ b/ui/js/page/settings/index.js @@ -1,19 +1,21 @@ import React from "react"; import { connect } from "react-redux"; import { doClearCache } from "actions/app"; -import { doSetDaemonSetting, doSetClientSetting } from "actions/settings"; -import { selectDaemonSettings, selectShowNsfw } from "selectors/settings"; +import { doSetDaemonSetting, doSetClientSetting, doChangeLanguage } from "actions/settings"; +import { selectDaemonSettings, selectShowNsfw, selectCurrentLanguage } from "selectors/settings"; import SettingsPage from "./view"; const select = state => ({ daemonSettings: selectDaemonSettings(state), showNsfw: selectShowNsfw(state), + language: selectCurrentLanguage(state), }); const perform = dispatch => ({ setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)), clearCache: () => dispatch(doClearCache()), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), + changeLanguage: (newLanguage) => dispatch(doChangeLanguage), }); export default connect(select, perform)(SettingsPage); diff --git a/ui/js/page/settings/view.jsx b/ui/js/page/settings/view.jsx index 4530f0b51..dc4d55d60 100644 --- a/ui/js/page/settings/view.jsx +++ b/ui/js/page/settings/view.jsx @@ -85,10 +85,8 @@ class SettingsPage extends React.PureComponent { this.props.setClientSetting("showNsfw", event.target.checked); } - onLanguageChange(language) { - lbry.setClientSetting('language', language); - window.app.i18n.setLocale(language); - this.setState({language: language}) + onLanguageChange(e) { + this.props.changeLanguage(e.target.value) } // onLanguageChange(language) { @@ -168,7 +166,7 @@ class SettingsPage extends React.PureComponent { name="language" label={__("English")} onChange={() => { - this.onLanguageChange("en"); + this.onLanguageChange.bind(this); }} defaultChecked={this.state.language == "en"} /> @@ -181,7 +179,7 @@ class SettingsPage extends React.PureComponent { key={dLang} label={window.app.i18n.resLang(dLang)} onChange={() => { - this.onLanguageChange(dLang); + this.onLanguageChange.bind(this); }} defaultChecked={this.state.language == dLang} /> diff --git a/ui/js/reducers/settings.js b/ui/js/reducers/settings.js index 4b78284cc..21cb2506b 100644 --- a/ui/js/reducers/settings.js +++ b/ui/js/reducers/settings.js @@ -5,6 +5,7 @@ const reducers = {}; const defaultState = { clientSettings: { showNsfw: lbry.getClientSetting("showNsfw"), + language: lbry.getClientSetting("language"), }, }; diff --git a/ui/js/selectors/app.js b/ui/js/selectors/app.js index f6acd6d07..d9b743d2a 100644 --- a/ui/js/selectors/app.js +++ b/ui/js/selectors/app.js @@ -191,3 +191,8 @@ export const selectBadgeNumber = createSelector( _selectState, state => state.badgeNumber ); + +export const selectCurrentLanguage = createSelector( + _selectState, + (state) => state.currentLanguage || "en" +) \ No newline at end of file From 2ca08f92b52a1fd545d7ca9cf971f7e34b300dc7 Mon Sep 17 00:00:00 2001 From: Fillerino Date: Fri, 7 Jul 2017 15:26:03 +0200 Subject: [PATCH 05/17] Fixing some stuff... --- ui/js/actions/app.js | 4 ++-- ui/js/constants/action_types.js | 2 +- ui/js/page/settings/index.js | 17 +++++++++++++---- ui/js/page/settings/view.jsx | 34 ++++++++++++++++----------------- ui/js/selectors/app.js | 4 ++-- 5 files changed, 35 insertions(+), 26 deletions(-) diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js index 62eaeb5e1..de0f158c9 100644 --- a/ui/js/actions/app.js +++ b/ui/js/actions/app.js @@ -253,6 +253,6 @@ export function doChangeLanguage(newLanguage) { app.i18n.setLocale(newLanguage); return { type: types.CHANGE_LANGUAGE, - data: { newLanguage: newLanguage } - } + data: { newLanguage: newLanguage }, + }; } diff --git a/ui/js/constants/action_types.js b/ui/js/constants/action_types.js index 32f7b3ef3..b85cf8c8f 100644 --- a/ui/js/constants/action_types.js +++ b/ui/js/constants/action_types.js @@ -99,4 +99,4 @@ export const CLAIM_REWARD_FAILURE = "CLAIM_REWARD_FAILURE"; export const CLAIM_REWARD_CLEAR_ERROR = "CLAIM_REWARD_CLEAR_ERROR"; //Language -export const LANGUAGE_CHANGED = "LANGUAGE_CHANGED"; \ No newline at end of file +export const LANGUAGE_CHANGED = "LANGUAGE_CHANGED"; diff --git a/ui/js/page/settings/index.js b/ui/js/page/settings/index.js index bd41c6844..de4b57f84 100644 --- a/ui/js/page/settings/index.js +++ b/ui/js/page/settings/index.js @@ -1,8 +1,17 @@ import React from "react"; import { connect } from "react-redux"; -import { doClearCache } from "actions/app"; -import { doSetDaemonSetting, doSetClientSetting, doChangeLanguage } from "actions/settings"; -import { selectDaemonSettings, selectShowNsfw, selectCurrentLanguage } from "selectors/settings"; +import { doClearCache, doChangeLanguage } from "actions/app"; +import { + doSetDaemonSetting, + doSetClientSetting, +} from "actions/settings"; +import { + selectDaemonSettings, + selectShowNsfw, +} from "selectors/settings"; +import { + selectCurrentLanguage, +} from "selectors/app" import SettingsPage from "./view"; const select = state => ({ @@ -15,7 +24,7 @@ const perform = dispatch => ({ setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)), clearCache: () => dispatch(doClearCache()), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), - changeLanguage: (newLanguage) => dispatch(doChangeLanguage), + changeLanguage: newLanguage => dispatch(doChangeLanguage), }); export default connect(select, perform)(SettingsPage); diff --git a/ui/js/page/settings/view.jsx b/ui/js/page/settings/view.jsx index dc4d55d60..d735851dc 100644 --- a/ui/js/page/settings/view.jsx +++ b/ui/js/page/settings/view.jsx @@ -86,7 +86,7 @@ class SettingsPage extends React.PureComponent { } onLanguageChange(e) { - this.props.changeLanguage(e.target.value) + this.props.changeLanguage(e.target.value); } // onLanguageChange(language) { @@ -166,27 +166,27 @@ class SettingsPage extends React.PureComponent { name="language" label={__("English")} onChange={() => { - this.onLanguageChange.bind(this); + this.onLanguageChange.bind(this); }} defaultChecked={this.state.language == "en"} />
- {window.app.i18n.localLanguages.map((dLang) => ( -
- { - this.onLanguageChange.bind(this); - }} - defaultChecked={this.state.language == dLang} - /> + {window.app.i18n.localLanguages.map(dLang => +
+ { + this.onLanguageChange.bind(this); + }} + defaultChecked={this.state.language == dLang} + /> +
+ )}
- ))} - -
+

{__("Download Directory")}

diff --git a/ui/js/selectors/app.js b/ui/js/selectors/app.js index d9b743d2a..5265a3df1 100644 --- a/ui/js/selectors/app.js +++ b/ui/js/selectors/app.js @@ -194,5 +194,5 @@ export const selectBadgeNumber = createSelector( export const selectCurrentLanguage = createSelector( _selectState, - (state) => state.currentLanguage || "en" -) \ No newline at end of file + state => state.currentLanguage || "en" +); From 15e765b65bf8da4ae325ed23bed44fcfaa28cdb4 Mon Sep 17 00:00:00 2001 From: Fillerino Date: Fri, 7 Jul 2017 15:27:52 +0200 Subject: [PATCH 06/17] Fixing more stuff... --- ui/js/page/settings/index.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/ui/js/page/settings/index.js b/ui/js/page/settings/index.js index de4b57f84..a9bfbfa83 100644 --- a/ui/js/page/settings/index.js +++ b/ui/js/page/settings/index.js @@ -1,17 +1,9 @@ import React from "react"; import { connect } from "react-redux"; import { doClearCache, doChangeLanguage } from "actions/app"; -import { - doSetDaemonSetting, - doSetClientSetting, -} from "actions/settings"; -import { - selectDaemonSettings, - selectShowNsfw, -} from "selectors/settings"; -import { - selectCurrentLanguage, -} from "selectors/app" +import { doSetDaemonSetting, doSetClientSetting } from "actions/settings"; +import { selectDaemonSettings, selectShowNsfw } from "selectors/settings"; +import { selectCurrentLanguage } from "selectors/app"; import SettingsPage from "./view"; const select = state => ({ From 7b8de81567e20c75bac24816d17026561e6078ff Mon Sep 17 00:00:00 2001 From: Fillerino Date: Fri, 7 Jul 2017 15:37:24 +0200 Subject: [PATCH 07/17] More fixing... --- ui/js/page/settings/view.jsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ui/js/page/settings/view.jsx b/ui/js/page/settings/view.jsx index d735851dc..d9b45bbca 100644 --- a/ui/js/page/settings/view.jsx +++ b/ui/js/page/settings/view.jsx @@ -86,6 +86,7 @@ class SettingsPage extends React.PureComponent { } onLanguageChange(e) { + console.log(e); this.props.changeLanguage(e.target.value); } @@ -165,9 +166,7 @@ class SettingsPage extends React.PureComponent { type="radio" name="language" label={__("English")} - onChange={() => { - this.onLanguageChange.bind(this); - }} + onChange={this.onLanguageChange.bind(this)} defaultChecked={this.state.language == "en"} />
@@ -178,9 +177,7 @@ class SettingsPage extends React.PureComponent { name="language" key={dLang} label={window.app.i18n.resLang(dLang)} - onChange={() => { - this.onLanguageChange.bind(this); - }} + onChange={this.onLanguageChange.bind(this)} defaultChecked={this.state.language == dLang} /> From 66287079e7623b82fde82697cef46e8d7b4d75f5 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Tue, 8 Aug 2017 14:33:21 +0100 Subject: [PATCH 08/17] removed unused code --- ui/js/main.js | 1 - ui/js/utils.js | 196 ------------------------------------------------- 2 files changed, 197 deletions(-) diff --git a/ui/js/main.js b/ui/js/main.js index 957d2b5fb..1b3709a25 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -17,7 +17,6 @@ const env = ENV; const { remote, ipcRenderer, shell } = require("electron"); const contextMenu = remote.require("./menu/context-menu"); const app = require("./app"); -app.i18n.resLang = require("./utils").resLang; lbry.showMenuIfNeeded(); diff --git a/ui/js/utils.js b/ui/js/utils.js index 3ec7cc37f..b41a2e0d4 100644 --- a/ui/js/utils.js +++ b/ui/js/utils.js @@ -1,5 +1,3 @@ -const { remote } = require("electron"); - /** * Thin wrapper around localStorage.getItem(). Parses JSON and returns undefined if the value * is not set yet. @@ -32,200 +30,6 @@ export function setSession(key, value) { sessionStorage.setItem(key, JSON.stringify(value)); } -/** - * This file contains the function to resolve a 2-letter country code - * to the language name in both english and the local language. - */ -export function resLang(uLang) { - this.langs = { - aa: ["Afar", "Afar"], - ab: ["Abkhazian", "Аҧсуа"], - af: ["Afrikaans", "Afrikaans"], - ak: ["Akan", "Akana"], - am: ["Amharic", "አማርኛ"], - an: ["Aragonese", "Aragonés"], - ar: ["Arabic", "العربية"], - as: ["Assamese", "অসমীয়া"], - av: ["Avar", "Авар"], - ay: ["Aymara", "Aymar"], - az: ["Azerbaijani", "Azərbaycanca / آذربايجان"], - ba: ["Bashkir", "Башҡорт"], - be: ["Belarusian", "Беларуская"], - bg: ["Bulgarian", "Български"], - bh: ["Bihari", "भोजपुरी"], - bi: ["Bislama", "Bislama"], - bm: ["Bambara", "Bamanankan"], - bn: ["Bengali", "বাংলা"], - bo: ["Tibetan", "བོད་ཡིག / Bod skad"], - br: ["Breton", "Brezhoneg"], - bs: ["Bosnian", "Bosanski"], - ca: ["Catalan", "Català"], - ce: ["Chechen", "Нохчийн"], - ch: ["Chamorro", "Chamoru"], - co: ["Corsican", "Corsu"], - cr: ["Cree", "Nehiyaw"], - cs: ["Czech", "Česky"], - cu: ["Old Church Slavonic / Old Bulgarian", "словѣньскъ / slověnĭskŭ"], - cv: ["Chuvash", "Чăваш"], - cy: ["Welsh", "Cymraeg"], - da: ["Danish", "Dansk"], - de: ["German", "Deutsch"], - dv: ["Divehi", "ދިވެހިބަސް"], - dz: ["Dzongkha", "ཇོང་ཁ"], - ee: ["Ewe", "Ɛʋɛ"], - el: ["Greek", "Ελληνικά"], - en: ["English", "English"], - eo: ["Esperanto", "Esperanto"], - es: ["Spanish", "Español"], - et: ["Estonian", "Eesti"], - eu: ["Basque", "Euskara"], - fa: ["Persian", "فارسی"], - ff: ["Peul", "Fulfulde"], - fi: ["Finnish", "Suomi"], - fj: ["Fijian", "Na Vosa Vakaviti"], - fo: ["Faroese", "Føroyskt"], - fr: ["French", "Français"], - fy: ["West Frisian", "Frysk"], - ga: ["Irish", "Gaeilge"], - gd: ["Scottish Gaelic", "Gàidhlig"], - gl: ["Galician", "Galego"], - gn: ["Guarani", "Avañe'ẽ"], - gu: ["Gujarati", "ગુજરાતી"], - gv: ["Manx", "Gaelg"], - ha: ["Hausa", "هَوُسَ"], - he: ["Hebrew", "עברית"], - hi: ["Hindi", "हिन्दी"], - ho: ["Hiri Motu", "Hiri Motu"], - hr: ["Croatian", "Hrvatski"], - ht: ["Haitian", "Krèyol ayisyen"], - hu: ["Hungarian", "Magyar"], - hy: ["Armenian", "Հայերեն"], - hz: ["Herero", "Otsiherero"], - ia: ["Interlingua", "Interlingua"], - id: ["Indonesian", "Bahasa Indonesia"], - ie: ["Interlingue", "Interlingue"], - ig: ["Igbo", "Igbo"], - ii: ["Sichuan Yi", "ꆇꉙ / 四川彝语"], - ik: ["Inupiak", "Iñupiak"], - io: ["Ido", "Ido"], - is: ["Icelandic", "Íslenska"], - it: ["Italian", "Italiano"], - iu: ["Inuktitut", "ᐃᓄᒃᑎᑐᑦ"], - ja: ["Japanese", "日本語"], - jv: ["Javanese", "Basa Jawa"], - ka: ["Georgian", "ქართული"], - kg: ["Kongo", "KiKongo"], - ki: ["Kikuyu", "Gĩkũyũ"], - kj: ["Kuanyama", "Kuanyama"], - kk: ["Kazakh", "Қазақша"], - kl: ["Greenlandic", "Kalaallisut"], - km: ["Cambodian", "ភាសាខ្មែរ"], - kn: ["Kannada", "ಕನ್ನಡ"], - ko: ["Korean", "한국어"], - kr: ["Kanuri", "Kanuri"], - ks: ["Kashmiri", "कश्मीरी / كشميري"], - ku: ["Kurdish", "Kurdî / كوردی"], - kv: ["Komi", "Коми"], - kw: ["Cornish", "Kernewek"], - ky: ["Kirghiz", "Kırgızca / Кыргызча"], - la: ["Latin", "Latina"], - lb: ["Luxembourgish", "Lëtzebuergesch"], - lg: ["Ganda", "Luganda"], - li: ["Limburgian", "Limburgs"], - ln: ["Lingala", "Lingála"], - lo: ["Laotian", "ລາວ / Pha xa lao"], - lt: ["Lithuanian", "Lietuvių"], - lv: ["Latvian", "Latviešu"], - mg: ["Malagasy", "Malagasy"], - mh: ["Marshallese", "Kajin Majel / Ebon"], - mi: ["Maori", "Māori"], - mk: ["Macedonian", "Македонски"], - ml: ["Malayalam", "മലയാളം"], - mn: ["Mongolian", "Монгол"], - mo: ["Moldovan", "Moldovenească"], - mr: ["Marathi", "मराठी"], - ms: ["Malay", "Bahasa Melayu"], - mt: ["Maltese", "bil-Malti"], - my: ["Burmese", "Myanmasa"], - na: ["Nauruan", "Dorerin Naoero"], - nd: ["North Ndebele", "Sindebele"], - ne: ["Nepali", "नेपाली"], - ng: ["Ndonga", "Oshiwambo"], - nl: ["Dutch", "Nederlands"], - nn: ["Norwegian Nynorsk", "Norsk (nynorsk)"], - no: ["Norwegian", "Norsk (bokmål / riksmål)"], - nr: ["South Ndebele", "isiNdebele"], - nv: ["Navajo", "Diné bizaad"], - ny: ["Chichewa", "Chi-Chewa"], - oc: ["Occitan", "Occitan"], - oj: ["Ojibwa", "ᐊᓂᔑᓈᐯᒧᐎᓐ / Anishinaabemowin"], - om: ["Oromo", "Oromoo"], - or: ["Oriya", "ଓଡ଼ିଆ"], - os: ["Ossetian / Ossetic", "Иронау"], - pa: ["Panjabi / Punjabi", "ਪੰਜਾਬੀ / पंजाबी / پنجابي"], - pi: ["Pali", "Pāli / पाऴि"], - pl: ["Polish", "Polski"], - ps: ["Pashto", "پښتو"], - pt: ["Portuguese", "Português"], - qu: ["Quechua", "Runa Simi"], - rm: ["Raeto Romance", "Rumantsch"], - rn: ["Kirundi", "Kirundi"], - ro: ["Romanian", "Română"], - ru: ["Russian", "Русский"], - rw: ["Rwandi", "Kinyarwandi"], - sa: ["Sanskrit", "संस्कृतम्"], - sc: ["Sardinian", "Sardu"], - sd: ["Sindhi", "सिनधि"], - se: ["Northern Sami", "Sámegiella"], - sg: ["Sango", "Sängö"], - sh: ["Serbo-Croatian", "Srpskohrvatski / Српскохрватски"], - si: ["Sinhalese", "සිංහල"], - sk: ["Slovak", "Slovenčina"], - sl: ["Slovenian", "Slovenščina"], - sm: ["Samoan", "Gagana Samoa"], - sn: ["Shona", "chiShona"], - so: ["Somalia", "Soomaaliga"], - sq: ["Albanian", "Shqip"], - sr: ["Serbian", "Српски"], - ss: ["Swati", "SiSwati"], - st: ["Southern Sotho", "Sesotho"], - su: ["Sundanese", "Basa Sunda"], - sv: ["Swedish", "Svenska"], - sw: ["Swahili", "Kiswahili"], - ta: ["Tamil", "தமிழ்"], - te: ["Telugu", "తెలుగు"], - tg: ["Tajik", "Тоҷикӣ"], - th: ["Thai", "ไทย / Phasa Thai"], - ti: ["Tigrinya", "ትግርኛ"], - tk: ["Turkmen", "Туркмен / تركمن"], - tl: ["Tagalog / Filipino", "Tagalog"], - tn: ["Tswana", "Setswana"], - to: ["Tonga", "Lea Faka-Tonga"], - tr: ["Turkish", "Türkçe"], - ts: ["Tsonga", "Xitsonga"], - tt: ["Tatar", "Tatarça"], - tw: ["Twi", "Twi"], - ty: ["Tahitian", "Reo Mā`ohi"], - ug: ["Uyghur", "Uyƣurqə / ئۇيغۇرچە"], - uk: ["Ukrainian", "Українська"], - ur: ["Urdu", "اردو"], - uz: ["Uzbek", "Ўзбек"], - ve: ["Venda", "Tshivenḓa"], - vi: ["Vietnamese", "Tiếng Việt"], - vo: ["Volapük", "Volapük"], - wa: ["Walloon", "Walon"], - wo: ["Wolof", "Wollof"], - xh: ["Xhosa", "isiXhosa"], - yi: ["Yiddish", "ייִדיש"], - yo: ["Yoruba", "Yorùbá"], - za: ["Zhuang", "Cuengh / Tôô / 壮语"], - zh: ["Chinese", "中文"], - zu: ["Zulu", "isiZulu"], - }; - this.lang = uLang.substring(0, 2); - return `${this.langs[this.lang][0]} (${this.langs[this.lang][1]})`; -} - export function formatCredits(amount, precision) { return amount.toFixed(precision || 1).replace(/\.?0+$/, ""); } From fe5ba7cb9eecd31542a673be40061da835683b14 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Sun, 13 Aug 2017 13:28:18 +0100 Subject: [PATCH 09/17] updated doDownloadLanguages to use the app.i18n.directory property instead of 'app/locales' string --- ui/js/actions/settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/js/actions/settings.js b/ui/js/actions/settings.js index fccc16e9c..c55c1eece 100644 --- a/ui/js/actions/settings.js +++ b/ui/js/actions/settings.js @@ -291,8 +291,8 @@ export function doDownloadLanguage(lang, destinationPath) { export function doDownloadLanguages() { return function(dispatch, getState) { - if (!fs.existsSync("app/locales")) { - fs.mkdirSync("app/locales"); + if (!fs.existsSync(app.i18n.directory)) { + fs.mkdirSync(app.i18n.directory); } dispatch({ From 4ea5e8b937cf4780232ce2f1b25b7f00842b4f24 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Tue, 15 Aug 2017 15:59:38 +0100 Subject: [PATCH 10/17] removed unused action types --- ui/js/actions/app.js | 6 ++---- ui/js/constants/action_types.js | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js index 3640e8623..19e9025e0 100644 --- a/ui/js/actions/app.js +++ b/ui/js/actions/app.js @@ -298,10 +298,8 @@ export function doClearCache() { } export function doChangeLanguage(newLanguage) { - app.i18n.setLocale(newLanguage); - return { - type: types.CHANGE_LANGUAGE, - data: { newLanguage: newLanguage }, + return function(dispatch, getState) { + app.i18n.setLocale(newLanguage); }; } diff --git a/ui/js/constants/action_types.js b/ui/js/constants/action_types.js index 9057108bb..fcd8c9c12 100644 --- a/ui/js/constants/action_types.js +++ b/ui/js/constants/action_types.js @@ -115,8 +115,6 @@ export const CLAIM_REWARD_CLEAR_ERROR = "CLAIM_REWARD_CLEAR_ERROR"; export const FETCH_REWARD_CONTENT_COMPLETED = "FETCH_REWARD_CONTENT_COMPLETED"; //Language -export const CHANGE_LANGUAGE = "CHANGE_LANGUAGE"; -export const LANGUAGE_CHANGED = "LANGUAGE_CHANGED"; export const LANGUAGE_RESOLVED = "LANGUAGE_RESOLVED"; export const DOWNLOAD_LANGUAGE_STARTED = "DOWNLOAD_LANGUAGE_STARTED"; export const DOWNLOAD_LANGUAGE_SUCCEEDED = "DOWNLOAD_LANGUAGE_SUCCEEDED"; From 9b6ae50c51b4d7b6c446a768601f9771e0c12673 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Tue, 15 Aug 2017 22:15:03 -0400 Subject: [PATCH 11/17] skip downloading the daemon if it exists and the version matches --- .gitignore | 1 + build/build.sh | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index dc61fadfe..00be3730e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ /app/dist /app/node_modules /build/venv +/build/daemon.ver /lbry-app-venv /lbry-app /lbry-venv diff --git a/build/build.sh b/build/build.sh index c0e60e79c..1863a0361 100755 --- a/build/build.sh +++ b/build/build.sh @@ -82,9 +82,17 @@ fi DAEMON_VER=$(node -e "console.log(require(\"$ROOT/app/package.json\").lbrySettings.lbrynetDaemonVersion)") DAEMON_URL_TEMPLATE=$(node -e "console.log(require(\"$ROOT/app/package.json\").lbrySettings.lbrynetDaemonUrlTemplate)") DAEMON_URL=$(echo ${DAEMON_URL_TEMPLATE//DAEMONVER/$DAEMON_VER} | sed "s/OSNAME/$OSNAME/g") -wget --quiet "$DAEMON_URL" -O "$BUILD_DIR/daemon.zip" -unzip "$BUILD_DIR/daemon.zip" -d "$ROOT/app/dist/" -rm "$BUILD_DIR/daemon.zip" +DAEMON_VER_PATH="$BUILD_DIR/daemon.ver" +echo "$DAEMON_VER_PATH" +if [[ ! -f $DAEMON_VER_PATH || ! -f $ROOT/app/dist/lbrynet-daemon || $(< $DAEMON_VER_PATH) != $DAEMON_VER ]]; then + wget --quiet "$DAEMON_URL" -O "$BUILD_DIR/daemon.zip" + unzip "$BUILD_DIR/daemon.zip" -d "$ROOT/app/dist/" + rm "$BUILD_DIR/daemon.zip" + echo "$DAEMON_VER" > "$DAEMON_VER_PATH" +else + echo "Already have daemon version $DAEMON_VER, skipping download" +fi + From cefc8824740f9ba3ccdf1a5ed7c4680af778b04b Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Sat, 19 Aug 2017 14:03:51 -0400 Subject: [PATCH 12/17] more i18n progress --- ui/js/actions/app.js | 6 - ui/js/actions/settings.js | 318 ++++++-------------------------- ui/js/constants/action_types.js | 4 - ui/js/constants/languages.js | 187 +++++++++++++++++++ ui/js/main.js | 2 - ui/js/page/settings/index.js | 11 +- ui/js/page/settings/view.jsx | 49 ++--- ui/js/reducers/settings.js | 35 ++-- ui/js/selectors/app.js | 2 +- ui/js/selectors/settings.js | 9 +- 10 files changed, 283 insertions(+), 340 deletions(-) create mode 100644 ui/js/constants/languages.js diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js index 07935754f..e70e9767f 100644 --- a/ui/js/actions/app.js +++ b/ui/js/actions/app.js @@ -346,12 +346,6 @@ export function doClearCache() { }; } -export function doChangeLanguage(newLanguage) { - return function(dispatch, getState) { - app.i18n.setLocale(newLanguage); - }; -} - export function doQuit() { return function(dispatch, getState) { remote.app.quit(); diff --git a/ui/js/actions/settings.js b/ui/js/actions/settings.js index c55c1eece..5c230498c 100644 --- a/ui/js/actions/settings.js +++ b/ui/js/actions/settings.js @@ -45,247 +45,56 @@ export function doSetClientSetting(key, value) { }; } -export function doResolveLanguage(locale) { - const langs = { - aa: ["Afar", "Afar"], - ab: ["Abkhazian", "Аҧсуа"], - af: ["Afrikaans", "Afrikaans"], - ak: ["Akan", "Akana"], - am: ["Amharic", "አማርኛ"], - an: ["Aragonese", "Aragonés"], - ar: ["Arabic", "العربية"], - as: ["Assamese", "অসমীয়া"], - av: ["Avar", "Авар"], - ay: ["Aymara", "Aymar"], - az: ["Azerbaijani", "Azərbaycanca / آذربايجان"], - ba: ["Bashkir", "Башҡорт"], - be: ["Belarusian", "Беларуская"], - bg: ["Bulgarian", "Български"], - bh: ["Bihari", "भोजपुरी"], - bi: ["Bislama", "Bislama"], - bm: ["Bambara", "Bamanankan"], - bn: ["Bengali", "বাংলা"], - bo: ["Tibetan", "བོད་ཡིག / Bod skad"], - br: ["Breton", "Brezhoneg"], - bs: ["Bosnian", "Bosanski"], - ca: ["Catalan", "Català"], - ce: ["Chechen", "Нохчийн"], - ch: ["Chamorro", "Chamoru"], - co: ["Corsican", "Corsu"], - cr: ["Cree", "Nehiyaw"], - cs: ["Czech", "Česky"], - cu: ["Old Church Slavonic / Old Bulgarian", "словѣньскъ / slověnĭskŭ"], - cv: ["Chuvash", "Чăваш"], - cy: ["Welsh", "Cymraeg"], - da: ["Danish", "Dansk"], - de: ["German", "Deutsch"], - dv: ["Divehi", "ދިވެހިބަސް"], - dz: ["Dzongkha", "ཇོང་ཁ"], - ee: ["Ewe", "Ɛʋɛ"], - el: ["Greek", "Ελληνικά"], - en: ["English", "English"], - eo: ["Esperanto", "Esperanto"], - es: ["Spanish", "Español"], - et: ["Estonian", "Eesti"], - eu: ["Basque", "Euskara"], - fa: ["Persian", "فارسی"], - ff: ["Peul", "Fulfulde"], - fi: ["Finnish", "Suomi"], - fj: ["Fijian", "Na Vosa Vakaviti"], - fo: ["Faroese", "Føroyskt"], - fr: ["French", "Français"], - fy: ["West Frisian", "Frysk"], - ga: ["Irish", "Gaeilge"], - gd: ["Scottish Gaelic", "Gàidhlig"], - gl: ["Galician", "Galego"], - gn: ["Guarani", "Avañe'ẽ"], - gu: ["Gujarati", "ગુજરાતી"], - gv: ["Manx", "Gaelg"], - ha: ["Hausa", "هَوُسَ"], - he: ["Hebrew", "עברית"], - hi: ["Hindi", "हिन्दी"], - ho: ["Hiri Motu", "Hiri Motu"], - hr: ["Croatian", "Hrvatski"], - ht: ["Haitian", "Krèyol ayisyen"], - hu: ["Hungarian", "Magyar"], - hy: ["Armenian", "Հայերեն"], - hz: ["Herero", "Otsiherero"], - ia: ["Interlingua", "Interlingua"], - id: ["Indonesian", "Bahasa Indonesia"], - ie: ["Interlingue", "Interlingue"], - ig: ["Igbo", "Igbo"], - ii: ["Sichuan Yi", "ꆇꉙ / 四川彝语"], - ik: ["Inupiak", "Iñupiak"], - io: ["Ido", "Ido"], - is: ["Icelandic", "Íslenska"], - it: ["Italian", "Italiano"], - iu: ["Inuktitut", "ᐃᓄᒃᑎᑐᑦ"], - ja: ["Japanese", "日本語"], - jv: ["Javanese", "Basa Jawa"], - ka: ["Georgian", "ქართული"], - kg: ["Kongo", "KiKongo"], - ki: ["Kikuyu", "Gĩkũyũ"], - kj: ["Kuanyama", "Kuanyama"], - kk: ["Kazakh", "Қазақша"], - kl: ["Greenlandic", "Kalaallisut"], - km: ["Cambodian", "ភាសាខ្មែរ"], - kn: ["Kannada", "ಕನ್ನಡ"], - ko: ["Korean", "한국어"], - kr: ["Kanuri", "Kanuri"], - ks: ["Kashmiri", "कश्मीरी / كشميري"], - ku: ["Kurdish", "Kurdî / كوردی"], - kv: ["Komi", "Коми"], - kw: ["Cornish", "Kernewek"], - ky: ["Kirghiz", "Kırgızca / Кыргызча"], - la: ["Latin", "Latina"], - lb: ["Luxembourgish", "Lëtzebuergesch"], - lg: ["Ganda", "Luganda"], - li: ["Limburgian", "Limburgs"], - ln: ["Lingala", "Lingála"], - lo: ["Laotian", "ລາວ / Pha xa lao"], - lt: ["Lithuanian", "Lietuvių"], - lv: ["Latvian", "Latviešu"], - mg: ["Malagasy", "Malagasy"], - mh: ["Marshallese", "Kajin Majel / Ebon"], - mi: ["Maori", "Māori"], - mk: ["Macedonian", "Македонски"], - ml: ["Malayalam", "മലയാളം"], - mn: ["Mongolian", "Монгол"], - mo: ["Moldovan", "Moldovenească"], - mr: ["Marathi", "मराठी"], - ms: ["Malay", "Bahasa Melayu"], - mt: ["Maltese", "bil-Malti"], - my: ["Burmese", "Myanmasa"], - na: ["Nauruan", "Dorerin Naoero"], - nd: ["North Ndebele", "Sindebele"], - ne: ["Nepali", "नेपाली"], - ng: ["Ndonga", "Oshiwambo"], - nl: ["Dutch", "Nederlands"], - nn: ["Norwegian Nynorsk", "Norsk (nynorsk)"], - no: ["Norwegian", "Norsk (bokmål / riksmål)"], - nr: ["South Ndebele", "isiNdebele"], - nv: ["Navajo", "Diné bizaad"], - ny: ["Chichewa", "Chi-Chewa"], - oc: ["Occitan", "Occitan"], - oj: ["Ojibwa", "ᐊᓂᔑᓈᐯᒧᐎᓐ / Anishinaabemowin"], - om: ["Oromo", "Oromoo"], - or: ["Oriya", "ଓଡ଼ିଆ"], - os: ["Ossetian / Ossetic", "Иронау"], - pa: ["Panjabi / Punjabi", "ਪੰਜਾਬੀ / पंजाबी / پنجابي"], - pi: ["Pali", "Pāli / पाऴि"], - pl: ["Polish", "Polski"], - ps: ["Pashto", "پښتو"], - pt: ["Portuguese", "Português"], - qu: ["Quechua", "Runa Simi"], - rm: ["Raeto Romance", "Rumantsch"], - rn: ["Kirundi", "Kirundi"], - ro: ["Romanian", "Română"], - ru: ["Russian", "Русский"], - rw: ["Rwandi", "Kinyarwandi"], - sa: ["Sanskrit", "संस्कृतम्"], - sc: ["Sardinian", "Sardu"], - sd: ["Sindhi", "सिनधि"], - se: ["Northern Sami", "Sámegiella"], - sg: ["Sango", "Sängö"], - sh: ["Serbo-Croatian", "Srpskohrvatski / Српскохрватски"], - si: ["Sinhalese", "සිංහල"], - sk: ["Slovak", "Slovenčina"], - sl: ["Slovenian", "Slovenščina"], - sm: ["Samoan", "Gagana Samoa"], - sn: ["Shona", "chiShona"], - so: ["Somalia", "Soomaaliga"], - sq: ["Albanian", "Shqip"], - sr: ["Serbian", "Српски"], - ss: ["Swati", "SiSwati"], - st: ["Southern Sotho", "Sesotho"], - su: ["Sundanese", "Basa Sunda"], - sv: ["Swedish", "Svenska"], - sw: ["Swahili", "Kiswahili"], - ta: ["Tamil", "தமிழ்"], - te: ["Telugu", "తెలుగు"], - tg: ["Tajik", "Тоҷикӣ"], - th: ["Thai", "ไทย / Phasa Thai"], - ti: ["Tigrinya", "ትግርኛ"], - tk: ["Turkmen", "Туркмен / تركمن"], - tl: ["Tagalog / Filipino", "Tagalog"], - tn: ["Tswana", "Setswana"], - to: ["Tonga", "Lea Faka-Tonga"], - tr: ["Turkish", "Türkçe"], - ts: ["Tsonga", "Xitsonga"], - tt: ["Tatar", "Tatarça"], - tw: ["Twi", "Twi"], - ty: ["Tahitian", "Reo Mā`ohi"], - ug: ["Uyghur", "Uyƣurqə / ئۇيغۇرچە"], - uk: ["Ukrainian", "Українська"], - ur: ["Urdu", "اردو"], - uz: ["Uzbek", "Ўзбек"], - ve: ["Venda", "Tshivenḓa"], - vi: ["Vietnamese", "Tiếng Việt"], - vo: ["Volapük", "Volapük"], - wa: ["Walloon", "Walon"], - wo: ["Wolof", "Wollof"], - xh: ["Xhosa", "isiXhosa"], - yi: ["Yiddish", "ייִדיש"], - yo: ["Yoruba", "Yorùbá"], - za: ["Zhuang", "Cuengh / Tôô / 壮语"], - zh: ["Chinese", "中文"], - zu: ["Zulu", "isiZulu"], - }; - - const lang = locale.substring(0, 2); - return { - type: types.LANGUAGE_RESOLVED, - data: { key: locale, value: `${langs[lang][0]} (${langs[lang][1]})` }, - }; -} - -export function doDownloadLanguage(lang, destinationPath) { +export function doDownloadLanguage(langFile) { return function(dispatch, getState) { - const plainLanguage = lang.replace(".json", ""); + const destinationPath = `app/locales/${langFile}`; + const language = langFile.replace(".json", ""); + const req = http.get( + { + headers: { + "Content-Type": "text/html", + }, + host: "i18n.lbry.io", + path: `/langs/${langFile}`, + }, + response => { + if (response.statusCode === 200) { + const file = fs.createWriteStream(destinationPath); - dispatch({ - type: types.DOWNLOAD_LANGUAGE_STARTED, - data: plainLanguage, - }); - - return new Promise((resolve, reject) => { - const file = fs.createWriteStream(destinationPath); - const req = http.request( - `http://i18n.lbry.io/langs/${lang}`, - response => { + file.on("error", errorHandler); file.on("finish", () => { file.close(); // push to our local list dispatch({ type: types.DOWNLOAD_LANGUAGE_SUCCEEDED, - data: plainLanguage, + data: { language: language }, }); - - resolve(); }); response.pipe(file); + } else { + errorHandler(new Error("Language request failed.")); } - ); + } + ); - const errorHandler = err => { - if (file) { - file.close(); - } + const errorHandler = err => { + fs.unlink(destinationPath, () => {}); // Delete the file async. (But we don't check the result) - fs.unlink(destinationPath); // Delete the file async. (But we don't check the result) - dispatch({ - type: types.DOWNLOAD_LANGUAGE_FAILED, - data: plainLanguage, - }); - reject(err); - }; - req.on("error", errorHandler); - file.on("error", errorHandler); + dispatch({ + type: types.DOWNLOAD_LANGUAGE_FAILED, + data: { language }, + }); + }; - req.end(); + req.setTimeout(30000, function() { + req.abort(); }); + + req.on("error", errorHandler); + + req.end(); }; } @@ -295,45 +104,34 @@ export function doDownloadLanguages() { fs.mkdirSync(app.i18n.directory); } - dispatch({ - type: types.DOWNLOAD_LANGUAGES_STARTED, - data: {}, - }); + const req = http.request({ host: "i18n.lbry.io", path: "/" }, response => { + let str = ""; - return new Promise((resolve, reject) => { - const req = http.request( - { host: "i18n.lbry.io", path: "/" }, - response => { - let str = ""; - - response.on("data", chunk => { - str += chunk; - }); - - response.on("end", () => { - const files = JSON.parse(str); - const actions = []; - files.forEach(file => { - actions.push(doDownloadLanguage(file, `app/locales/${file}`)); - }); - - dispatch(batchActions(...actions)); - - dispatch({ - type: types.DOWNLOAD_LANGUAGES_COMPLETED, - data: {}, - }); - - resolve(); - }); - } - ); - - req.on("error", err => { - reject(err); + response.on("data", chunk => { + str += chunk; }); - req.end(); + response.on("end", () => { + const files = JSON.parse(str); + const actions = []; + files.forEach(file => { + actions.push(doDownloadLanguage(file)); + }); + + dispatch(batchActions(...actions)); + }); }); + + req.on("error", err => { + throw err; //this ought to be cleanly handled + }); + + req.end(); + }; +} + +export function doChangeLanguage(language) { + return function(dispatch, getState) { + app.i18n.setLocale(language); }; } diff --git a/ui/js/constants/action_types.js b/ui/js/constants/action_types.js index 8dbb11f0f..7b2a7456d 100644 --- a/ui/js/constants/action_types.js +++ b/ui/js/constants/action_types.js @@ -115,9 +115,5 @@ export const CLAIM_REWARD_CLEAR_ERROR = "CLAIM_REWARD_CLEAR_ERROR"; export const FETCH_REWARD_CONTENT_COMPLETED = "FETCH_REWARD_CONTENT_COMPLETED"; //Language -export const LANGUAGE_RESOLVED = "LANGUAGE_RESOLVED"; -export const DOWNLOAD_LANGUAGE_STARTED = "DOWNLOAD_LANGUAGE_STARTED"; export const DOWNLOAD_LANGUAGE_SUCCEEDED = "DOWNLOAD_LANGUAGE_SUCCEEDED"; export const DOWNLOAD_LANGUAGE_FAILED = "DOWNLOAD_LANGUAGE_FAILED"; -export const DOWNLOAD_LANGUAGES_STARTED = "DOWNLOAD_LANGUAGES_STARTED"; -export const DOWNLOAD_LANGUAGES_COMPLETED = "DOWNLOAD_LANGUAGES_COMPLETED"; diff --git a/ui/js/constants/languages.js b/ui/js/constants/languages.js new file mode 100644 index 000000000..f1879e904 --- /dev/null +++ b/ui/js/constants/languages.js @@ -0,0 +1,187 @@ +const LANGUAGES = { + aa: ["Afar", "Afar"], + ab: ["Abkhazian", "Аҧсуа"], + af: ["Afrikaans", "Afrikaans"], + ak: ["Akan", "Akana"], + am: ["Amharic", "አማርኛ"], + an: ["Aragonese", "Aragonés"], + ar: ["Arabic", "العربية"], + as: ["Assamese", "অসমীয়া"], + av: ["Avar", "Авар"], + ay: ["Aymara", "Aymar"], + az: ["Azerbaijani", "Azərbaycanca / آذربايجان"], + ba: ["Bashkir", "Башҡорт"], + be: ["Belarusian", "Беларуская"], + bg: ["Bulgarian", "Български"], + bh: ["Bihari", "भोजपुरी"], + bi: ["Bislama", "Bislama"], + bm: ["Bambara", "Bamanankan"], + bn: ["Bengali", "বাংলা"], + bo: ["Tibetan", "བོད་ཡིག / Bod skad"], + br: ["Breton", "Brezhoneg"], + bs: ["Bosnian", "Bosanski"], + ca: ["Catalan", "Català"], + ce: ["Chechen", "Нохчийн"], + ch: ["Chamorro", "Chamoru"], + co: ["Corsican", "Corsu"], + cr: ["Cree", "Nehiyaw"], + cs: ["Czech", "Česky"], + cu: ["Old Church Slavonic / Old Bulgarian", "словѣньскъ / slověnĭskŭ"], + cv: ["Chuvash", "Чăваш"], + cy: ["Welsh", "Cymraeg"], + da: ["Danish", "Dansk"], + de: ["German", "Deutsch"], + dv: ["Divehi", "ދިވެހިބަސް"], + dz: ["Dzongkha", "ཇོང་ཁ"], + ee: ["Ewe", "Ɛʋɛ"], + el: ["Greek", "Ελληνικά"], + en: ["English", "English"], + eo: ["Esperanto", "Esperanto"], + es: ["Spanish", "Español"], + et: ["Estonian", "Eesti"], + eu: ["Basque", "Euskara"], + fa: ["Persian", "فارسی"], + ff: ["Peul", "Fulfulde"], + fi: ["Finnish", "Suomi"], + fj: ["Fijian", "Na Vosa Vakaviti"], + fo: ["Faroese", "Føroyskt"], + fr: ["French", "Français"], + fy: ["West Frisian", "Frysk"], + ga: ["Irish", "Gaeilge"], + gd: ["Scottish Gaelic", "Gàidhlig"], + gl: ["Galician", "Galego"], + gn: ["Guarani", "Avañe'ẽ"], + gu: ["Gujarati", "ગુજરાતી"], + gv: ["Manx", "Gaelg"], + ha: ["Hausa", "هَوُسَ"], + he: ["Hebrew", "עברית"], + hi: ["Hindi", "हिन्दी"], + ho: ["Hiri Motu", "Hiri Motu"], + hr: ["Croatian", "Hrvatski"], + ht: ["Haitian", "Krèyol ayisyen"], + hu: ["Hungarian", "Magyar"], + hy: ["Armenian", "Հայերեն"], + hz: ["Herero", "Otsiherero"], + ia: ["Interlingua", "Interlingua"], + id: ["Indonesian", "Bahasa Indonesia"], + ie: ["Interlingue", "Interlingue"], + ig: ["Igbo", "Igbo"], + ii: ["Sichuan Yi", "ꆇꉙ / 四川彝语"], + ik: ["Inupiak", "Iñupiak"], + io: ["Ido", "Ido"], + is: ["Icelandic", "Íslenska"], + it: ["Italian", "Italiano"], + iu: ["Inuktitut", "ᐃᓄᒃᑎᑐᑦ"], + ja: ["Japanese", "日本語"], + jv: ["Javanese", "Basa Jawa"], + ka: ["Georgian", "ქართული"], + kg: ["Kongo", "KiKongo"], + ki: ["Kikuyu", "Gĩkũyũ"], + kj: ["Kuanyama", "Kuanyama"], + kk: ["Kazakh", "Қазақша"], + kl: ["Greenlandic", "Kalaallisut"], + km: ["Cambodian", "ភាសាខ្មែរ"], + kn: ["Kannada", "ಕನ್ನಡ"], + ko: ["Korean", "한국어"], + kr: ["Kanuri", "Kanuri"], + ks: ["Kashmiri", "कश्मीरी / كشميري"], + ku: ["Kurdish", "Kurdî / كوردی"], + kv: ["Komi", "Коми"], + kw: ["Cornish", "Kernewek"], + ky: ["Kirghiz", "Kırgızca / Кыргызча"], + la: ["Latin", "Latina"], + lb: ["Luxembourgish", "Lëtzebuergesch"], + lg: ["Ganda", "Luganda"], + li: ["Limburgian", "Limburgs"], + ln: ["Lingala", "Lingála"], + lo: ["Laotian", "ລາວ / Pha xa lao"], + lt: ["Lithuanian", "Lietuvių"], + lv: ["Latvian", "Latviešu"], + mg: ["Malagasy", "Malagasy"], + mh: ["Marshallese", "Kajin Majel / Ebon"], + mi: ["Maori", "Māori"], + mk: ["Macedonian", "Македонски"], + ml: ["Malayalam", "മലയാളം"], + mn: ["Mongolian", "Монгол"], + mo: ["Moldovan", "Moldovenească"], + mr: ["Marathi", "मराठी"], + ms: ["Malay", "Bahasa Melayu"], + mt: ["Maltese", "bil-Malti"], + my: ["Burmese", "Myanmasa"], + na: ["Nauruan", "Dorerin Naoero"], + nd: ["North Ndebele", "Sindebele"], + ne: ["Nepali", "नेपाली"], + ng: ["Ndonga", "Oshiwambo"], + nl: ["Dutch", "Nederlands"], + nn: ["Norwegian Nynorsk", "Norsk (nynorsk)"], + no: ["Norwegian", "Norsk (bokmål / riksmål)"], + nr: ["South Ndebele", "isiNdebele"], + nv: ["Navajo", "Diné bizaad"], + ny: ["Chichewa", "Chi-Chewa"], + oc: ["Occitan", "Occitan"], + oj: ["Ojibwa", "ᐊᓂᔑᓈᐯᒧᐎᓐ / Anishinaabemowin"], + om: ["Oromo", "Oromoo"], + or: ["Oriya", "ଓଡ଼ିଆ"], + os: ["Ossetian / Ossetic", "Иронау"], + pa: ["Panjabi / Punjabi", "ਪੰਜਾਬੀ / पंजाबी / پنجابي"], + pi: ["Pali", "Pāli / पाऴि"], + pl: ["Polish", "Polski"], + ps: ["Pashto", "پښتو"], + pt: ["Portuguese", "Português"], + qu: ["Quechua", "Runa Simi"], + rm: ["Raeto Romance", "Rumantsch"], + rn: ["Kirundi", "Kirundi"], + ro: ["Romanian", "Română"], + ru: ["Russian", "Русский"], + rw: ["Rwandi", "Kinyarwandi"], + sa: ["Sanskrit", "संस्कृतम्"], + sc: ["Sardinian", "Sardu"], + sd: ["Sindhi", "सिनधि"], + se: ["Northern Sami", "Sámegiella"], + sg: ["Sango", "Sängö"], + sh: ["Serbo-Croatian", "Srpskohrvatski / Српскохрватски"], + si: ["Sinhalese", "සිංහල"], + sk: ["Slovak", "Slovenčina"], + sl: ["Slovenian", "Slovenščina"], + sm: ["Samoan", "Gagana Samoa"], + sn: ["Shona", "chiShona"], + so: ["Somalia", "Soomaaliga"], + sq: ["Albanian", "Shqip"], + sr: ["Serbian", "Српски"], + ss: ["Swati", "SiSwati"], + st: ["Southern Sotho", "Sesotho"], + su: ["Sundanese", "Basa Sunda"], + sv: ["Swedish", "Svenska"], + sw: ["Swahili", "Kiswahili"], + ta: ["Tamil", "தமிழ்"], + te: ["Telugu", "తెలుగు"], + tg: ["Tajik", "Тоҷикӣ"], + th: ["Thai", "ไทย / Phasa Thai"], + ti: ["Tigrinya", "ትግርኛ"], + tk: ["Turkmen", "Туркмен / تركمن"], + tl: ["Tagalog / Filipino", "Tagalog"], + tn: ["Tswana", "Setswana"], + to: ["Tonga", "Lea Faka-Tonga"], + tr: ["Turkish", "Türkçe"], + ts: ["Tsonga", "Xitsonga"], + tt: ["Tatar", "Tatarça"], + tw: ["Twi", "Twi"], + ty: ["Tahitian", "Reo Mā`ohi"], + ug: ["Uyghur", "Uyƣurqə / ئۇيغۇرچە"], + uk: ["Ukrainian", "Українська"], + ur: ["Urdu", "اردو"], + uz: ["Uzbek", "Ўзбек"], + ve: ["Venda", "Tshivenḓa"], + vi: ["Vietnamese", "Tiếng Việt"], + vo: ["Volapük", "Volapük"], + wa: ["Walloon", "Walon"], + wo: ["Wolof", "Wollof"], + xh: ["Xhosa", "isiXhosa"], + yi: ["Yiddish", "ייִדיש"], + yo: ["Yoruba", "Yorùbá"], + za: ["Zhuang", "Cuengh / Tôô / 壮语"], + zh: ["Chinese", "中文"], + zu: ["Zulu", "isiZulu"], +}; + +export default LANGUAGES; diff --git a/ui/js/main.js b/ui/js/main.js index 1b3709a25..42c40a3a2 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -10,8 +10,6 @@ import { doChangePath, doNavigate, doDaemonReady } from "actions/app"; import { doDownloadLanguages } from "actions/settings"; import { toQueryString } from "util/query_params"; import * as types from "constants/action_types"; -import fs from "fs"; -import http from "http"; const env = ENV; const { remote, ipcRenderer, shell } = require("electron"); diff --git a/ui/js/page/settings/index.js b/ui/js/page/settings/index.js index 27df5cb09..e97ae7e4e 100644 --- a/ui/js/page/settings/index.js +++ b/ui/js/page/settings/index.js @@ -1,16 +1,15 @@ import React from "react"; import { connect } from "react-redux"; -import { doClearCache, doChangeLanguage } from "actions/app"; +import { doClearCache } from "actions/app"; import { doSetDaemonSetting, doSetClientSetting, - doResolveLanguage, + doChangeLanguage, } from "actions/settings"; import { selectDaemonSettings, selectShowNsfw, - selectLocalLanguages, - selectResolvedLanguages, + selectLanguages, } from "selectors/settings"; import { selectCurrentLanguage } from "selectors/app"; import SettingsPage from "./view"; @@ -19,8 +18,7 @@ const select = state => ({ daemonSettings: selectDaemonSettings(state), showNsfw: selectShowNsfw(state), language: selectCurrentLanguage(state), - localLanguages: selectLocalLanguages(state), - resolvedLanguages: selectResolvedLanguages(state), + languages: selectLanguages(state), }); const perform = dispatch => ({ @@ -28,7 +26,6 @@ const perform = dispatch => ({ clearCache: () => dispatch(doClearCache()), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), changeLanguage: newLanguage => dispatch(doChangeLanguage(newLanguage)), - resolveLanguage: lang => dispatch(doResolveLanguage(lang)), }); export default connect(select, perform)(SettingsPage); diff --git a/ui/js/page/settings/view.jsx b/ui/js/page/settings/view.jsx index 41327e56c..2cc699cab 100644 --- a/ui/js/page/settings/view.jsx +++ b/ui/js/page/settings/view.jsx @@ -24,13 +24,6 @@ class SettingsPage extends React.PureComponent { }; } - componentWillMount() { - const { localLanguages, resolveLanguage } = this.props; - localLanguages.forEach(lang => { - resolveLanguage(lang); - }); - } - clearCache() { this.setState({ clearingCache: true, @@ -107,21 +100,10 @@ class SettingsPage extends React.PureComponent { this.props.changeLanguage(e.target.value); } - // onLanguageChange(language) { - // lbry.setClientSetting('language', language); - // i18n.setLocale(language); - // this.setState({language: language}) - // } - onShowUnavailableChange(event) {} render() { - const { - daemonSettings, - language, - localLanguages, - resolvedLanguages, - } = this.props; + const { daemonSettings, language, languages } = this.props; if (!daemonSettings || Object.keys(daemonSettings).length === 0) { return ( @@ -140,25 +122,22 @@ class SettingsPage extends React.PureComponent {
+ > + + {Object.keys(languages).map(dLang => + + )} +
- {localLanguages.map(dLang => -
- -
- )}
diff --git a/ui/js/reducers/settings.js b/ui/js/reducers/settings.js index 85ab0c074..962ac068a 100644 --- a/ui/js/reducers/settings.js +++ b/ui/js/reducers/settings.js @@ -1,4 +1,5 @@ import * as types from "constants/action_types"; +import LANGUAGES from "constants/languages"; import lbry from "lbry"; const reducers = {}; @@ -7,6 +8,7 @@ const defaultState = { showNsfw: lbry.getClientSetting("showNsfw"), language: lbry.getClientSetting("language"), }, + languages: {}, }; reducers[types.DAEMON_SETTINGS_RECEIVED] = function(state, action) { @@ -27,28 +29,25 @@ reducers[types.CLIENT_SETTING_CHANGED] = function(state, action) { }; reducers[types.DOWNLOAD_LANGUAGE_SUCCEEDED] = function(state, action) { - const localLanguages = [].concat( - state.localLanguages ? state.localLanguages : [] - ); - const language = action.data; - if (localLanguages.indexOf(language) === -1) { - localLanguages.push(language); + const languages = Object.assign({}, state.languages); + const language = action.data.language; + + const langCode = language.substring(0, 2); + + if (LANGUAGES[langCode]) { + languages[langCode] = + LANGUAGES[langCode][0] + " (" + LANGUAGES[langCode][1] + ")"; + } else { + languages[langCode] = langCode; } - return Object.assign({}, state, { - localLanguages, - }); + return Object.assign({}, state, { languages }); }; -reducers[types.LANGUAGE_RESOLVED] = function(state, action) { - const { key, value } = action.data; - const resolvedLanguages = Object.assign({}, state.resolvedLanguages); - - resolvedLanguages[key] = value; - - return Object.assign({}, state, { - resolvedLanguages, - }); +reducers[types.DOWNLOAD_LANGUAGE_FAILED] = function(state, action) { + const languages = Object.assign({}, state.languages); + delete languages[action.data.language]; + return Object.assign({}, state, { languages }); }; export default function reducer(state = defaultState, action) { diff --git a/ui/js/selectors/app.js b/ui/js/selectors/app.js index f25e8f742..8d9f34741 100644 --- a/ui/js/selectors/app.js +++ b/ui/js/selectors/app.js @@ -220,7 +220,7 @@ export const selectBadgeNumber = createSelector( export const selectCurrentLanguage = createSelector( _selectState, - () => lbry.getClientSetting("language") || "en" + () => app.i18n.getLocale() || "en" ); export const selectPathAfterAuth = createSelector( diff --git a/ui/js/selectors/settings.js b/ui/js/selectors/settings.js index bff7480e2..61c7dc4f0 100644 --- a/ui/js/selectors/settings.js +++ b/ui/js/selectors/settings.js @@ -22,12 +22,7 @@ export const selectShowNsfw = createSelector( clientSettings => !!clientSettings.showNsfw ); -export const selectLocalLanguages = createSelector( +export const selectLanguages = createSelector( _selectState, - state => state.localLanguages || [] -); - -export const selectResolvedLanguages = createSelector( - _selectState, - state => state.resolvedLanguages || {} + state => state.languages || {} ); From efd2b99cda762496dc718fca0132643f8e28125f Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Mon, 21 Aug 2017 16:03:51 +0100 Subject: [PATCH 13/17] modified doDownloadLanguages to use XMLHttpRequest instead of http.request --- ui/js/actions/settings.js | 45 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/ui/js/actions/settings.js b/ui/js/actions/settings.js index 5c230498c..d0fd40102 100644 --- a/ui/js/actions/settings.js +++ b/ui/js/actions/settings.js @@ -104,29 +104,30 @@ export function doDownloadLanguages() { fs.mkdirSync(app.i18n.directory); } - const req = http.request({ host: "i18n.lbry.io", path: "/" }, response => { - let str = ""; + const xhr = new XMLHttpRequest(); + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + if (xhr.status === 200) { + try { + const files = JSON.parse(xhr.responseText); + const actions = []; + files.forEach(file => { + actions.push(doDownloadLanguage(file)); + }); - response.on("data", chunk => { - str += chunk; - }); - - response.on("end", () => { - const files = JSON.parse(str); - const actions = []; - files.forEach(file => { - actions.push(doDownloadLanguage(file)); - }); - - dispatch(batchActions(...actions)); - }); - }); - - req.on("error", err => { - throw err; //this ought to be cleanly handled - }); - - req.end(); + dispatch(batchActions(...actions)); + } catch (err) { + throw err; + } + } else { + throw new Error( + __("The list of available languages could not be retrieved.") + ); + } + } + }; + xhr.open("get", "http://i18n.lbry.io"); + xhr.send(); }; } From cd37c80b9a69243e6c453373323a156f681119f5 Mon Sep 17 00:00:00 2001 From: Alex Grin Date: Mon, 21 Aug 2017 12:06:56 -0400 Subject: [PATCH 14/17] quotes --- build/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build.sh b/build/build.sh index 1863a0361..92c2c5e8f 100755 --- a/build/build.sh +++ b/build/build.sh @@ -84,7 +84,7 @@ DAEMON_URL_TEMPLATE=$(node -e "console.log(require(\"$ROOT/app/package.json\").l DAEMON_URL=$(echo ${DAEMON_URL_TEMPLATE//DAEMONVER/$DAEMON_VER} | sed "s/OSNAME/$OSNAME/g") DAEMON_VER_PATH="$BUILD_DIR/daemon.ver" echo "$DAEMON_VER_PATH" -if [[ ! -f $DAEMON_VER_PATH || ! -f $ROOT/app/dist/lbrynet-daemon || $(< $DAEMON_VER_PATH) != $DAEMON_VER ]]; then +if [[ ! -f $DAEMON_VER_PATH || ! -f $ROOT/app/dist/lbrynet-daemon || "$(< "$DAEMON_VER_PATH")" != "$DAEMON_VER" ]]; then wget --quiet "$DAEMON_URL" -O "$BUILD_DIR/daemon.zip" unzip "$BUILD_DIR/daemon.zip" -d "$ROOT/app/dist/" rm "$BUILD_DIR/daemon.zip" From 6e61a9f73c74eaf733b4390458661b361c9c6567 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Tue, 22 Aug 2017 17:28:01 -0400 Subject: [PATCH 15/17] further improvements to backup wallet content --- ui/js/page/backup/view.jsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ui/js/page/backup/view.jsx b/ui/js/page/backup/view.jsx index f3d930a17..6ce9de6b6 100644 --- a/ui/js/page/backup/view.jsx +++ b/ui/js/page/backup/view.jsx @@ -20,17 +20,22 @@ class BackupPage extends React.PureComponent {
-

{__("Backup Wallet")}

+

{__("Backup Your LBRY Credits")}

{__( - "Currently, there is no automatic wallet backup, but it is fairly easy to back up manually." + "Your LBRY credits are controllable by you and only you, via wallet file(s) stored locally on your computer." )}

{__( - "To backup your wallet, make a copy of the folder listed below:" + "Currently, there is no automatic wallet backup. If you lose access to these files, you will lose your credits permanently." + )} +

+

+ {__( + "However, it is fairly easy to back up manually. To backup your wallet, make a copy of the folder listed below:" )}

@@ -45,6 +50,13 @@ class BackupPage extends React.PureComponent { )}

+

+ For more details on backing up and best practices,{" "} + . +

From 48b02567a077ee9c4beee6aea319c89460a3a6a7 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 23 Aug 2017 00:50:59 +0100 Subject: [PATCH 16/17] fixed locale change bug --- ui/js/page/settings/view.jsx | 3 ++- ui/js/reducers/settings.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/js/page/settings/view.jsx b/ui/js/page/settings/view.jsx index 2cc699cab..deeff92ae 100644 --- a/ui/js/page/settings/view.jsx +++ b/ui/js/page/settings/view.jsx @@ -98,6 +98,7 @@ class SettingsPage extends React.PureComponent { onLanguageChange(e) { this.props.changeLanguage(e.target.value); + this.forceUpdate(); } onShowUnavailableChange(event) {} @@ -131,7 +132,7 @@ class SettingsPage extends React.PureComponent { diff --git a/ui/js/reducers/settings.js b/ui/js/reducers/settings.js index 962ac068a..e6d32f0f0 100644 --- a/ui/js/reducers/settings.js +++ b/ui/js/reducers/settings.js @@ -35,7 +35,7 @@ reducers[types.DOWNLOAD_LANGUAGE_SUCCEEDED] = function(state, action) { const langCode = language.substring(0, 2); if (LANGUAGES[langCode]) { - languages[langCode] = + languages[language] = LANGUAGES[langCode][0] + " (" + LANGUAGES[langCode][1] + ")"; } else { languages[langCode] = langCode; From 68e0eb66d2cd02049ebe7b7f25dc7db56037822c Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Thu, 24 Aug 2017 13:33:41 -0400 Subject: [PATCH 17/17] save setting, fix warning --- ui/js/actions/settings.js | 2 ++ ui/js/page/settings/view.jsx | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ui/js/actions/settings.js b/ui/js/actions/settings.js index d0fd40102..4bdec4300 100644 --- a/ui/js/actions/settings.js +++ b/ui/js/actions/settings.js @@ -1,4 +1,5 @@ import * as types from "constants/action_types"; +import * as settings from "constants/settings"; import batchActions from "util/batchActions"; import lbry from "lbry"; import fs from "fs"; @@ -133,6 +134,7 @@ export function doDownloadLanguages() { export function doChangeLanguage(language) { return function(dispatch, getState) { + lbry.setClientSetting(settings.LANGUAGE, language); app.i18n.setLocale(language); }; } diff --git a/ui/js/page/settings/view.jsx b/ui/js/page/settings/view.jsx index deeff92ae..1813e83bb 100644 --- a/ui/js/page/settings/view.jsx +++ b/ui/js/page/settings/view.jsx @@ -125,15 +125,12 @@ class SettingsPage extends React.PureComponent { {Object.keys(languages).map(dLang => - )}