Skip to content

Commit

Permalink
Make corrections to language display #10
Browse files Browse the repository at this point in the history
1. display profile languages instead of currently logged in user
2. hide languages div when there are no languages
3. Reduce the list of languages by removing the historical languages
4. Make convert.rb
  • Loading branch information
aurimus committed Oct 9, 2014
1 parent d779b99 commit 1985ed7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
4 changes: 3 additions & 1 deletion app/controllers/users/users.profile.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ exports.userByID = function(req, res, next, id) {
if (err) return next(err);
if (!user) return next(new Error('Failed to load user ' + id));

// Make sure we're not sending unsequre content (eg. passwords)
// Make sure we're not sending unsecure content (eg. passwords)
// Pick here fields to send
user = _.pick(user, 'id',
'displayName',
Expand All @@ -133,6 +133,7 @@ exports.userByID = function(req, res, next, id) {
'description',
'locationFrom',
'locationLiving',
'languages',
'birthdate',
'seen',
'created',
Expand Down Expand Up @@ -176,6 +177,7 @@ exports.userByUsername = function(req, res, next, username) {
'description',
'locationFrom',
'locationLiving',
'languages',
'birthdate',
'seen',
'created',
Expand Down
21 changes: 9 additions & 12 deletions public/modules/core/languages/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
The languages.json is a custom made file which contains languages from languages_orig.json that has iso_639_2 standard defined.

cd to dir and type `ruby convert.rb`

OR

Ruby commands to make the new file out of the original:
(cd to the directory and type irb to open ruby console and require 'json')
(cd to the directory and type irb to open ruby console)

Two liner:
```
langs = File.read("languages_orig.json")
langs = JSON.parse(langs)
langs = langs.select { |lang| lang.has_key?('iso_639_2b')}
langs = langs.collect {|lang| { lang['iso_639_2b'] => lang['name'] } }
langs = langs.reduce(Hash.new, :merge)
File.open('languages.json', 'w') { |f| f.write(langs.to_json)}
```
require 'json'
One liner:
`
File.open('languages.json', 'w') { |f| f.write(JSON.parse(File.read("languages_orig.json")).select { |lang| lang.has_key?('iso_639_2b')}.collect {|l| {l['iso_639_2b'] => l['name']} }.reduce(Hash.new, :merge).to_json)}
`
File.open('languages.json', 'w') { |f| f.write(JSON.parse(File.read("languages_orig.json")).select { |lang| lang.has_key?('iso_639_2b') && lang['type'] == "living"}.collect {|l| {l['iso_639_2b'] => l['name']} }.reduce(Hash.new, :merge).to_json)}
```
8 changes: 8 additions & 0 deletions public/modules/core/languages/convert.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'json'

langs = File.read("languages_orig.json")
langs = JSON.parse(langs)
langs = langs.select { |lang| lang.has_key?('iso_639_2b') && lang['type'] == "living"}
langs = langs.collect {|lang| { lang['iso_639_2b'] => lang['name'] } }
langs = langs.reduce(Hash.new, :merge)
File.open('languages.json', 'w') { |f| f.write(langs.to_json)}
2 changes: 1 addition & 1 deletion public/modules/core/languages/languages.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"aar":"Afar","abk":"Abkhazian","ace":"Achinese","ach":"Acoli","ada":"Adangme","ady":"Adyghe","afh":"Afrihili","afr":"Afrikaans","ain":"Ainu (Japan)","aka":"Akan","akk":"Akkadian","ale":"Aleut","alt":"Southern Altai","amh":"Amharic","ang":"Old English (ca. 450-1100)","anp":"Angika","ara":"Arabic","arc":"Official Aramaic (700-300 BCE)","arg":"Aragonese","arn":"Mapudungun","arp":"Arapaho","arw":"Arawak","asm":"Assamese","ast":"Asturian","ava":"Avaric","ave":"Avestan","awa":"Awadhi","aym":"Aymara","aze":"Azerbaijani","bak":"Bashkir","bal":"Baluchi","bam":"Bambara","ban":"Balinese","bas":"Basa (Cameroon)","bej":"Beja","bel":"Belarusian","bem":"Bemba (Zambia)","ben":"Bengali","bho":"Bhojpuri","bik":"Bikol","bin":"Bini","bis":"Bislama","bla":"Siksika","tib":"Tibetan","bos":"Bosnian","bra":"Braj","bre":"Breton","bua":"Buriat","bug":"Buginese","bul":"Bulgarian","byn":"Bilin","cad":"Caddo","car":"Galibi Carib","cat":"Catalan","ceb":"Cebuano","cze":"Czech","cha":"Chamorro","chb":"Chibcha","che":"Chechen","chg":"Chagatai","chk":"Chuukese","chm":"Mari (Russia)","chn":"Chinook jargon","cho":"Choctaw","chp":"Chipewyan","chr":"Cherokee","chu":"Church Slavic","chv":"Chuvash","chy":"Cheyenne","cop":"Coptic","cor":"Cornish","cos":"Corsican","cre":"Cree","crh":"Crimean Tatar","csb":"Kashubian","wel":"Welsh","dak":"Dakota","dan":"Danish","dar":"Dargwa","del":"Delaware","den":"Slave (Athapascan)","ger":"German","dgr":"Dogrib","din":"Dinka","div":"Dhivehi","doi":"Dogri","dsb":"Lower Sorbian","dua":"Duala","dum":"Middle Dutch (ca. 1050-1350)","dyu":"Dyula","dzo":"Dzongkha","efi":"Efik","egy":"Egyptian (Ancient)","eka":"Ekajuk","gre":"Modern Greek (1453-)","elx":"Elamite","eng":"English","enm":"Middle English (1100-1500)","epo":"Esperanto","est":"Estonian","baq":"Basque","ewe":"Ewe","ewo":"Ewondo","fan":"Fang (Equatorial Guinea)","fao":"Faroese","per":"Persian","fat":"Fanti","fij":"Fijian","fil":"Filipino","fin":"Finnish","fon":"Fon","fre":"French","frm":"Middle French (ca. 1400-1600)","fro":"Old French (842-ca. 1400)","frr":"Northern Frisian","frs":"Eastern Frisian","fry":"Western Frisian","ful":"Fulah","fur":"Friulian","gaa":"Ga","gay":"Gayo","gba":"Gbaya (Central African Republic)","gez":"Geez","gil":"Gilbertese","gla":"Scottish Gaelic","gle":"Irish","glg":"Galician","glv":"Manx","gmh":"Middle High German (ca. 1050-1500)","goh":"Old High German (ca. 750-1050)","gon":"Gondi","gor":"Gorontalo","got":"Gothic","grb":"Grebo","grc":"Ancient Greek (to 1453)","grn":"Guarani","gsw":"Swiss German","guj":"Gujarati","gwi":"Gwichʼin","hai":"Haida","hat":"Haitian","hau":"Hausa","haw":"Hawaiian","heb":"Hebrew","her":"Herero","hil":"Hiligaynon","hin":"Hindi","hit":"Hittite","hmn":"Hmong","hmo":"Hiri Motu","hrv":"Croatian","hsb":"Upper Sorbian","hun":"Hungarian","hup":"Hupa","arm":"Armenian","iba":"Iban","ibo":"Igbo","ido":"Ido","iii":"Sichuan Yi","iku":"Inuktitut","ile":"Interlingue","ilo":"Iloko","ina":"Interlingua (International Auxiliary Language Association)","ind":"Indonesian","inh":"Ingush","ipk":"Inupiaq","ice":"Icelandic","ita":"Italian","jav":"Javanese","jbo":"Lojban","jpn":"Japanese","jpr":"Judeo-Persian","jrb":"Judeo-Arabic","kaa":"Kara-Kalpak","kab":"Kabyle","kac":"Kachin","kal":"Kalaallisut","kam":"Kamba (Kenya)","kan":"Kannada","kas":"Kashmiri","geo":"Georgian","kau":"Kanuri","kaw":"Kawi","kaz":"Kazakh","kbd":"Kabardian","kha":"Khasi","khm":"Central Khmer","kho":"Khotanese","kik":"Kikuyu","kin":"Kinyarwanda","kir":"Kirghiz","kmb":"Kimbundu","kok":"Konkani","kom":"Komi","kon":"Kongo","kor":"Korean","kos":"Kosraean","kpe":"Kpelle","krc":"Karachay-Balkar","krl":"Karelian","kru":"Kurukh","kua":"Kuanyama","kum":"Kumyk","kur":"Kurdish","kut":"Kutenai","lad":"Ladino","lah":"Lahnda","lam":"Lamba","lao":"Lao","lat":"Latin","lav":"Latvian","lez":"Lezghian","lim":"Limburgan","lin":"Lingala","lit":"Lithuanian","lol":"Mongo","loz":"Lozi","ltz":"Luxembourgish","lua":"Luba-Lulua","lub":"Luba-Katanga","lug":"Ganda","lui":"Luiseno","lun":"Lunda","luo":"Luo (Kenya and Tanzania)","lus":"Lushai","mad":"Madurese","mag":"Magahi","mah":"Marshallese","mai":"Maithili","mak":"Makasar","mal":"Malayalam","man":"Mandingo","mar":"Marathi","mas":"Masai","mdf":"Moksha","mdr":"Mandar","men":"Mende (Sierra Leone)","mga":"Middle Irish (900-1200)","mic":"Mi'kmaq","min":"Minangkabau","mis":"Uncoded languages","mac":"Macedonian","mlg":"Malagasy","mlt":"Maltese","mnc":"Manchu","mni":"Manipuri","moh":"Mohawk","mon":"Mongolian","mos":"Mossi","mao":"Maori","may":"Malay","mul":"Multiple languages","mus":"Creek","mwl":"Mirandese","mwr":"Marwari","bur":"Burmese","myv":"Erzya","nap":"Neapolitan","nau":"Nauru","nav":"Navajo","nbl":"South Ndebele","nde":"North Ndebele","ndo":"Ndonga","nds":"Low German","nep":"Nepali","new":"Newari","nia":"Nias","niu":"Niuean","dut":"Dutch","nno":"Norwegian Nynorsk","nob":"Norwegian Bokmål","nog":"Nogai","non":"Old Norse","nor":"Norwegian","nqo":"N'Ko","nso":"Pedi","nwc":"Classical Newari","nya":"Nyanja","nym":"Nyamwezi","nyn":"Nyankole","nyo":"Nyoro","nzi":"Nzima","oci":"Occitan (post 1500)","oji":"Ojibwa","ori":"Oriya","orm":"Oromo","osa":"Osage","oss":"Ossetian","ota":"Ottoman Turkish (1500-1928)","pag":"Pangasinan","pal":"Pahlavi","pam":"Pampanga","pan":"Panjabi","pap":"Papiamento","pau":"Palauan","peo":"Old Persian (ca. 600-400 B.C.)","phn":"Phoenician","pli":"Pali","pol":"Polish","pon":"Pohnpeian","por":"Portuguese","pro":"Old Provençal (to 1500)","pus":"Pushto","que":"Quechua","raj":"Rajasthani","rap":"Rapanui","rar":"Rarotongan","roh":"Romansh","rom":"Romany","rum":"Romanian","run":"Rundi","rup":"Macedo-Romanian","rus":"Russian","sad":"Sandawe","sag":"Sango","sah":"Yakut","sam":"Samaritan Aramaic","san":"Sanskrit","sas":"Sasak","sat":"Santali","scn":"Sicilian","sco":"Scots","sel":"Selkup","sga":"Old Irish (to 900)","shn":"Shan","sid":"Sidamo","sin":"Sinhala","slo":"Slovak","slv":"Slovenian","sma":"Southern Sami","sme":"Northern Sami","smj":"Lule Sami","smn":"Inari Sami","smo":"Samoan","sms":"Skolt Sami","sna":"Shona","snd":"Sindhi","snk":"Soninke","sog":"Sogdian","som":"Somali","sot":"Southern Sotho","spa":"Spanish","alb":"Albanian","srd":"Sardinian","srn":"Sranan Tongo","srp":"Serbian","srr":"Serer","ssw":"Swati","suk":"Sukuma","sun":"Sundanese","sus":"Susu","sux":"Sumerian","swa":"Swahili","swe":"Swedish","syc":"Classical Syriac","syr":"Syriac","tah":"Tahitian","tam":"Tamil","tat":"Tatar","tel":"Telugu","tem":"Timne","ter":"Tereno","tet":"Tetum","tgk":"Tajik","tgl":"Tagalog","tha":"Thai","tig":"Tigre","tir":"Tigrinya","tiv":"Tiv","tkl":"Tokelau","tlh":"Klingon","tli":"Tlingit","tmh":"Tamashek","tog":"Tonga (Nyasa)","ton":"Tonga (Tonga Islands)","tpi":"Tok Pisin","tsi":"Tsimshian","tsn":"Tswana","tso":"Tsonga","tuk":"Turkmen","tum":"Tumbuka","tur":"Turkish","tvl":"Tuvalu","twi":"Twi","tyv":"Tuvinian","udm":"Udmurt","uga":"Ugaritic","uig":"Uighur","ukr":"Ukrainian","umb":"Umbundu","und":"Undetermined","urd":"Urdu","uzb":"Uzbek","vai":"Vai","ven":"Venda","vie":"Vietnamese","vol":"Volapük","vot":"Votic","wal":"Wolaytta","war":"Waray (Philippines)","was":"Washo","wln":"Walloon","wol":"Wolof","xal":"Kalmyk","xho":"Xhosa","yao":"Yao","yap":"Yapese","yid":"Yiddish","yor":"Yoruba","zap":"Zapotec","zbl":"Blissymbols","zen":"Zenaga","zha":"Zhuang","chi":"Chinese","zul":"Zulu","zun":"Zuni","zxx":"No linguistic content","zza":"Zaza"}
{"aar":"Afar","abk":"Abkhazian","ace":"Achinese","ach":"Acoli","ada":"Adangme","ady":"Adyghe","afr":"Afrikaans","ain":"Ainu (Japan)","aka":"Akan","ale":"Aleut","alt":"Southern Altai","amh":"Amharic","anp":"Angika","ara":"Arabic","arg":"Aragonese","arn":"Mapudungun","arp":"Arapaho","arw":"Arawak","asm":"Assamese","ast":"Asturian","ava":"Avaric","awa":"Awadhi","aym":"Aymara","aze":"Azerbaijani","bak":"Bashkir","bal":"Baluchi","bam":"Bambara","ban":"Balinese","bas":"Basa (Cameroon)","bej":"Beja","bel":"Belarusian","bem":"Bemba (Zambia)","ben":"Bengali","bho":"Bhojpuri","bik":"Bikol","bin":"Bini","bis":"Bislama","bla":"Siksika","tib":"Tibetan","bos":"Bosnian","bra":"Braj","bre":"Breton","bua":"Buriat","bug":"Buginese","bul":"Bulgarian","byn":"Bilin","cad":"Caddo","car":"Galibi Carib","cat":"Catalan","ceb":"Cebuano","cze":"Czech","cha":"Chamorro","che":"Chechen","chk":"Chuukese","chm":"Mari (Russia)","chn":"Chinook jargon","cho":"Choctaw","chp":"Chipewyan","chr":"Cherokee","chv":"Chuvash","chy":"Cheyenne","cor":"Cornish","cos":"Corsican","cre":"Cree","crh":"Crimean Tatar","csb":"Kashubian","wel":"Welsh","dak":"Dakota","dan":"Danish","dar":"Dargwa","del":"Delaware","den":"Slave (Athapascan)","ger":"German","dgr":"Dogrib","din":"Dinka","div":"Dhivehi","doi":"Dogri","dsb":"Lower Sorbian","dua":"Duala","dyu":"Dyula","dzo":"Dzongkha","efi":"Efik","eka":"Ekajuk","gre":"Modern Greek (1453-)","eng":"English","est":"Estonian","baq":"Basque","ewe":"Ewe","ewo":"Ewondo","fan":"Fang (Equatorial Guinea)","fao":"Faroese","per":"Persian","fat":"Fanti","fij":"Fijian","fil":"Filipino","fin":"Finnish","fon":"Fon","fre":"French","frr":"Northern Frisian","frs":"Eastern Frisian","fry":"Western Frisian","ful":"Fulah","fur":"Friulian","gaa":"Ga","gay":"Gayo","gba":"Gbaya (Central African Republic)","gil":"Gilbertese","gla":"Scottish Gaelic","gle":"Irish","glg":"Galician","glv":"Manx","gon":"Gondi","gor":"Gorontalo","grb":"Grebo","grn":"Guarani","gsw":"Swiss German","guj":"Gujarati","gwi":"Gwichʼin","hai":"Haida","hat":"Haitian","hau":"Hausa","haw":"Hawaiian","heb":"Hebrew","her":"Herero","hil":"Hiligaynon","hin":"Hindi","hmn":"Hmong","hmo":"Hiri Motu","hrv":"Croatian","hsb":"Upper Sorbian","hun":"Hungarian","hup":"Hupa","arm":"Armenian","iba":"Iban","ibo":"Igbo","iii":"Sichuan Yi","iku":"Inuktitut","ilo":"Iloko","ind":"Indonesian","inh":"Ingush","ipk":"Inupiaq","ice":"Icelandic","ita":"Italian","jav":"Javanese","jpn":"Japanese","jpr":"Judeo-Persian","jrb":"Judeo-Arabic","kaa":"Kara-Kalpak","kab":"Kabyle","kac":"Kachin","kal":"Kalaallisut","kam":"Kamba (Kenya)","kan":"Kannada","kas":"Kashmiri","geo":"Georgian","kau":"Kanuri","kaz":"Kazakh","kbd":"Kabardian","kha":"Khasi","khm":"Central Khmer","kik":"Kikuyu","kin":"Kinyarwanda","kir":"Kirghiz","kmb":"Kimbundu","kok":"Konkani","kom":"Komi","kon":"Kongo","kor":"Korean","kos":"Kosraean","kpe":"Kpelle","krc":"Karachay-Balkar","krl":"Karelian","kru":"Kurukh","kua":"Kuanyama","kum":"Kumyk","kur":"Kurdish","kut":"Kutenai","lad":"Ladino","lah":"Lahnda","lam":"Lamba","lao":"Lao","lav":"Latvian","lez":"Lezghian","lim":"Limburgan","lin":"Lingala","lit":"Lithuanian","lol":"Mongo","loz":"Lozi","ltz":"Luxembourgish","lua":"Luba-Lulua","lub":"Luba-Katanga","lug":"Ganda","lui":"Luiseno","lun":"Lunda","luo":"Luo (Kenya and Tanzania)","lus":"Lushai","mad":"Madurese","mag":"Magahi","mah":"Marshallese","mai":"Maithili","mak":"Makasar","mal":"Malayalam","man":"Mandingo","mar":"Marathi","mas":"Masai","mdf":"Moksha","mdr":"Mandar","men":"Mende (Sierra Leone)","mic":"Mi'kmaq","min":"Minangkabau","mac":"Macedonian","mlg":"Malagasy","mlt":"Maltese","mnc":"Manchu","mni":"Manipuri","moh":"Mohawk","mon":"Mongolian","mos":"Mossi","mao":"Maori","may":"Malay","mus":"Creek","mwl":"Mirandese","mwr":"Marwari","bur":"Burmese","myv":"Erzya","nap":"Neapolitan","nau":"Nauru","nav":"Navajo","nbl":"South Ndebele","nde":"North Ndebele","ndo":"Ndonga","nds":"Low German","nep":"Nepali","new":"Newari","nia":"Nias","niu":"Niuean","dut":"Dutch","nno":"Norwegian Nynorsk","nob":"Norwegian Bokmål","nog":"Nogai","nor":"Norwegian","nqo":"N'Ko","nso":"Pedi","nya":"Nyanja","nym":"Nyamwezi","nyn":"Nyankole","nyo":"Nyoro","nzi":"Nzima","oci":"Occitan (post 1500)","oji":"Ojibwa","ori":"Oriya","orm":"Oromo","osa":"Osage","oss":"Ossetian","pag":"Pangasinan","pam":"Pampanga","pan":"Panjabi","pap":"Papiamento","pau":"Palauan","pol":"Polish","pon":"Pohnpeian","por":"Portuguese","pus":"Pushto","que":"Quechua","raj":"Rajasthani","rap":"Rapanui","rar":"Rarotongan","roh":"Romansh","rom":"Romany","rum":"Romanian","run":"Rundi","rup":"Macedo-Romanian","rus":"Russian","sad":"Sandawe","sag":"Sango","sah":"Yakut","sas":"Sasak","sat":"Santali","scn":"Sicilian","sco":"Scots","sel":"Selkup","shn":"Shan","sid":"Sidamo","sin":"Sinhala","slo":"Slovak","slv":"Slovenian","sma":"Southern Sami","sme":"Northern Sami","smj":"Lule Sami","smn":"Inari Sami","smo":"Samoan","sms":"Skolt Sami","sna":"Shona","snd":"Sindhi","snk":"Soninke","som":"Somali","sot":"Southern Sotho","spa":"Spanish","alb":"Albanian","srd":"Sardinian","srn":"Sranan Tongo","srp":"Serbian","srr":"Serer","ssw":"Swati","suk":"Sukuma","sun":"Sundanese","sus":"Susu","swa":"Swahili","swe":"Swedish","syr":"Syriac","tah":"Tahitian","tam":"Tamil","tat":"Tatar","tel":"Telugu","tem":"Timne","ter":"Tereno","tet":"Tetum","tgk":"Tajik","tgl":"Tagalog","tha":"Thai","tig":"Tigre","tir":"Tigrinya","tiv":"Tiv","tkl":"Tokelau","tli":"Tlingit","tmh":"Tamashek","tog":"Tonga (Nyasa)","ton":"Tonga (Tonga Islands)","tpi":"Tok Pisin","tsi":"Tsimshian","tsn":"Tswana","tso":"Tsonga","tuk":"Turkmen","tum":"Tumbuka","tur":"Turkish","tvl":"Tuvalu","twi":"Twi","tyv":"Tuvinian","udm":"Udmurt","uig":"Uighur","ukr":"Ukrainian","umb":"Umbundu","urd":"Urdu","uzb":"Uzbek","vai":"Vai","ven":"Venda","vie":"Vietnamese","vot":"Votic","wal":"Wolaytta","war":"Waray (Philippines)","was":"Washo","wln":"Walloon","wol":"Wolof","xal":"Kalmyk","xho":"Xhosa","yao":"Yao","yap":"Yapese","yid":"Yiddish","yor":"Yoruba","zap":"Zapotec","zen":"Zenaga","zha":"Zhuang","chi":"Chinese","zul":"Zulu","zun":"Zuni","zza":"Zaza"}
27 changes: 14 additions & 13 deletions public/modules/users/views/profile/view-profile.client.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,37 @@
<div tr-avatar data-watch="true" data-user="profile" data-size="261" data-link="false"></div>
<div class="panel-body">

<p>Member since <span data-ng-bind="profile.created | date:'mediumDate'"></span></p>
<div>Member since <span data-ng-bind="profile.created | date:'mediumDate'"></span></div>

<p>
<div>
Lives in <a href="#">City, Country</a>
</p>
</div>

<p>
<div>
From <a href="#">City, Country</a>
</p>
</div>

<!--
<p>
<div>
<h4>Last seen</h4>
<time>time</time>
</p>
</div>
-->

<p>
<div ng-show="profile.languages.length">
<h4>Languages</h4>
<div ng-repeat="code in user.languages">{{languages[code]}}</div>
</p>
<ul class="list-unstyled">
<li ng-repeat="code in profile.languages">{{languages[code]}}</li>
</ul>
</div>

<p data-ng-show="hasConnectedAdditionalSocialAccounts()">
<div data-ng-show="hasConnectedAdditionalSocialAccounts()">
<h4>Other networks</h4>
<ul class="fa-ul authentication-social">
<li data-ng-repeat="(providerName, providerData) in user.additionalProvidersData">
<i class="fa fa-li fa-lg" ng-class="fa-{{providerName}}-square"></i> {{providerName}}
</li>
</ul>
</p>
</div>

</div>
</div>
Expand Down

0 comments on commit 1985ed7

Please sign in to comment.