Page MenuHomePhabricator

Simplify the PageGateway's getPageLanguages function
Closed, ResolvedPublic

Description

The getPageLanguages function pulls all languages from the API using the languages site info property. This is the data:

"languages":[{"code":"aa","name":"Qafár af"},{"code":"ab","name":"Аҧсшәа"},{"code":"ace","name":"Acèh"},{"code":"ady","name":"адыгабзэ"},{"code":"ady-cyrl","name":"адыгабзэ"},{"code":"aeb","name":"تونسي/Tûnsî"},{"code":"aeb-arab","name":"تونسي"},{"code":"aeb-latn","name":"Tûnsî"},{"code":"af","name":"Afrikaans"},{"code":"ak","name":"Akan"},{"code":"aln","name":"Gegë"},{"code":"als","name":"Alemannisch"},{"code":"am","name":"አማርኛ"},{"code":"an","name":"aragonés"},{"code":"ang","name":"Ænglisc"},{"code":"anp","name":"अङ्गिका"},{"code":"ar","name":"العربية"},{"code":"arc","name":"ܐܪܡܝܐ"},{"code":"arn","name":"mapudungun"},{"code":"arq","name":"جازايرية"},{"code":"ary","name":"Maġribi"},{"code":"arz","name":"مصرى"},{"code":"as","name":"অসমীয়া"},{"code":"ase","name":"American sign language"},{"code":"ast","name":"asturianu"},{"code":"av","name":"авар"},{"code":"avk","name":"Kotava"},{"code":"awa","name":"अवधी"},{"code":"ay","name":"Aymar aru"},{"code":"az","name":"azərbaycanca"},{"code":"azb","name":"تۆرکجه"},{"code":"ba","name":"башҡортса"},{"code":"bar","name":"Boarisch"},{"code":"bat-smg","name":"žemaitėška"},{"code":"bbc","name":"Batak Toba"},{"code":"bbc-latn","name":"Batak Toba"},{"code":"bcc","name":"جهلسری بلوچی"},{"code":"bcl","name":"Bikol Central"},{"code":"be","name":"беларуская"},{"code":"be-tarask","name":"беларуская (тарашкевіца)‎"},{"code":"be-x-old","name":"беларуская (тарашкевіца)‎"},{"code":"bg","name":"български"},{"code":"bgn","name":"روچ کپتین بلوچی"},{"code":"bh","name":"भोजपुरी"},{"code":"bho","name":"भोजपुरी"},{"code":"bi","name":"Bislama"},{"code":"bjn","name":"Bahasa Banjar"},{"code":"bm","name":"bamanankan"},{"code":"bn","name":"বাংলা"},{"code":"bo","name":"བོད་ཡིག"},{"code":"bpy","name":"বিষ্ণুপ্রিয়া মণিপুরী"},{"code":"bqi","name":"بختیاری"},{"code":"br","name":"brezhoneg"},{"code":"brh","name":"Bráhuí"},{"code":"bs","name":"bosanski"},{"code":"bto","name":"Iriga Bicolano"},{"code":"bug","name":"ᨅᨔ ᨕᨘᨁᨗ"},{"code":"bxr","name":"буряад"},{"code":"ca","name":"català"},{"code":"cbk-zam","name":"Chavacano de Zamboanga"},{"code":"cdo","name":"Mìng-dĕ̤ng-ngṳ̄"},{"code":"ce","name":"нохчийн"},{"code":"ceb","name":"Cebuano"},{"code":"ch","name":"Chamoru"},{"code":"cho","name":"Choctaw"},{"code":"chr","name":"ᏣᎳᎩ"},{"code":"chy","name":"Tsetsêhestâhese"},{"code":"ckb","name":"کوردیی ناوەندی"},{"code":"co","name":"corsu"},{"code":"cps","name":"Capiceño"},{"code":"cr","name":"Nēhiyawēwin / ᓀᐦᐃᔭᐍᐏᐣ"},{"code":"crh","name":"qırımtatarca"},{"code":"crh-cyrl","name":"къырымтатарджа (Кирилл)‎"},{"code":"crh-latn","name":"qırımtatarca (Latin)‎"},{"code":"cs","name":"čeština"},{"code":"csb","name":"kaszëbsczi"},{"code":"cu","name":"словѣньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ"},{"code":"cv","name":"Чӑвашла"},{"code":"cy","name":"Cymraeg"},{"code":"da","name":"dansk"},{"code":"de","name":"Deutsch"},{"code":"de-at","name":"Österreichisches Deutsch"},{"code":"de-ch","name":"Schweizer Hochdeutsch"},{"code":"de-formal","name":"Deutsch (Sie-Form)‎"},{"code":"diq","name":"Zazaki"},{"code":"dsb","name":"dolnoserbski"},{"code":"dtp","name":"Dusun Bundu-liwan"},{"code":"dty","name":"डोटेली"},{"code":"dv","name":"ދިވެހިބަސް"},{"code":"dz","name":"ཇོང་ཁ"},{"code":"ee","name":"eʋegbe"},{"code":"egl","name":"Emiliàn"},{"code":"el","name":"Ελληνικά"},{"code":"eml","name":"emiliàn e rumagnòl"},{"code":"en","name":"English"},{"code":"en-ca","name":"Canadian English"},{"code":"en-gb","name":"British English"},{"code":"eo","name":"Esperanto"},{"code":"es","name":"español"},{"code":"et","name":"eesti"},{"code":"eu","name":"euskara"},{"code":"ext","name":"estremeñu"},{"code":"fa","name":"فارسی"},{"code":"ff","name":"Fulfulde"},{"code":"fi","name":"suomi"},{"code":"fit","name":"meänkieli"},{"code":"fiu-vro","name":"Võro"},{"code":"fj","name":"Na Vosa Vakaviti"},{"code":"fo","name":"føroyskt"},{"code":"fr","name":"français"},{"code":"frc","name":"français cadien"},{"code":"frp","name":"arpetan"},{"code":"frr","name":"Nordfriisk"},{"code":"fur","name":"furlan"},{"code":"fy","name":"Frysk"},{"code":"ga","name":"Gaeilge"},{"code":"gag","name":"Gagauz"},{"code":"gan","name":"贛語"},{"code":"gan-hans","name":"赣语(简体)‎"},{"code":"gan-hant","name":"贛語(繁體)‎"},{"code":"gd","name":"Gàidhlig"},{"code":"gl","name":"galego"},{"code":"glk","name":"گیلکی"},{"code":"gn","name":"Avañe'ẽ"},{"code":"gom","name":"गोंयची कोंकणी / Gõychi Konknni"},{"code":"gom-deva","name":"गोंयची कोंकणी"},{"code":"gom-latn","name":"Gõychi Konknni"},{"code":"got","name":"𐌲𐌿𐍄𐌹𐍃𐌺"},{"code":"grc","name":"Ἀρχαία ἑλληνικὴ"},{"code":"gsw","name":"Alemannisch"},{"code":"gu","name":"ગુજરાતી"},{"code":"gv","name":"Gaelg"},{"code":"ha","name":"Hausa"},{"code":"hak","name":"客家語/Hak-kâ-ngî"},{"code":"haw","name":"Hawai`i"},{"code":"he","name":"עברית"},{"code":"hi","name":"हिन्दी"},{"code":"hif","name":"Fiji Hindi"},{"code":"hif-latn","name":"Fiji Hindi"},{"code":"hil","name":"Ilonggo"},{"code":"ho","name":"Hiri Motu"},{"code":"hr","name":"hrvatski"},{"code":"hrx","name":"Hunsrik"},{"code":"hsb","name":"hornjoserbsce"},{"code":"ht","name":"Kreyòl ayisyen"},{"code":"hu","name":"magyar"},{"code":"hy","name":"Հայերեն"},{"code":"hz","name":"Otsiherero"},{"code":"ia","name":"interlingua"},{"code":"id","name":"Bahasa Indonesia"},{"code":"ie","name":"Interlingue"},{"code":"ig","name":"Igbo"},{"code":"ii","name":"ꆇꉙ"},{"code":"ik","name":"Iñupiak"},{"code":"ike-cans","name":"ᐃᓄᒃᑎᑐᑦ"},{"code":"ike-latn","name":"inuktitut"},{"code":"ilo","name":"Ilokano"},{"code":"inh","name":"ГӀалгӀай"},{"code":"io","name":"Ido"},{"code":"is","name":"íslenska"},{"code":"it","name":"italiano"},{"code":"iu","name":"ᐃᓄᒃᑎᑐᑦ/inuktitut"},{"code":"ja","name":"日本語"},{"code":"jam","name":"Patois"},{"code":"jbo","name":"la .lojban."},{"code":"jut","name":"jysk"},{"code":"jv","name":"Basa Jawa"},{"code":"ka","name":"ქართული"},{"code":"kaa","name":"Qaraqalpaqsha"},{"code":"kab","name":"Taqbaylit"},{"code":"kbd","name":"Адыгэбзэ"},{"code":"kbd-cyrl","name":"Адыгэбзэ"},{"code":"kg","name":"Kongo"},{"code":"khw","name":"کھوار"},{"code":"ki","name":"Gĩkũyũ"},{"code":"kiu","name":"Kırmancki"},{"code":"kj","name":"Kwanyama"},{"code":"kk","name":"қазақша"},{"code":"kk-arab","name":"قازاقشا (تٴوتە)‏"},{"code":"kk-cn","name":"قازاقشا (جۇنگو)‏"},{"code":"kk-cyrl","name":"қазақша (кирил)‎"},{"code":"kk-kz","name":"қазақша (Қазақстан)‎"},{"code":"kk-latn","name":"qazaqşa (latın)‎"},{"code":"kk-tr","name":"qazaqşa (Türkïya)‎"},{"code":"kl","name":"kalaallisut"},{"code":"km","name":"ភាសាខ្មែរ"},{"code":"kn","name":"ಕನ್ನಡ"},{"code":"ko","name":"한국어"},{"code":"ko-kp","name":"한국어 (조선)"},{"code":"koi","name":"Перем Коми"},{"code":"kr","name":"Kanuri"},{"code":"krc","name":"къарачай-малкъар"},{"code":"kri","name":"Krio"},{"code":"krj","name":"Kinaray-a"},{"code":"ks","name":"कॉशुर / کٲشُر"},{"code":"ks-arab","name":"کٲشُر"},{"code":"ks-deva","name":"कॉशुर"},{"code":"ksh","name":"Ripoarisch"},{"code":"ku","name":"Kurdî"},{"code":"ku-arab","name":"كوردي (عەرەبی)‏"},{"code":"ku-latn","name":"Kurdî (latînî)‎"},{"code":"kv","name":"коми"},{"code":"kw","name":"kernowek"},{"code":"ky","name":"Кыргызча"},{"code":"la","name":"Latina"},{"code":"lad","name":"Ladino"},{"code":"lb","name":"Lëtzebuergesch"},{"code":"lbe","name":"лакку"},{"code":"lez","name":"лезги"},{"code":"lfn","name":"Lingua Franca Nova"},{"code":"lg","name":"Luganda"},{"code":"li","name":"Limburgs"},{"code":"lij","name":"Ligure"},{"code":"liv","name":"Līvõ kēļ"},{"code":"lki","name":"لەکی‎"},{"code":"lmo","name":"lumbaart"},{"code":"ln","name":"lingála"},{"code":"lo","name":"ລາວ"},{"code":"loz","name":"Silozi"},{"code":"lrc","name":"لۊری شومالی"},{"code":"lt","name":"lietuvių"},{"code":"ltg","name":"latgaļu"},{"code":"lus","name":"Mizo ţawng"},{"code":"luz","name":"لئری دوٙمینی"},{"code":"lv","name":"latviešu"},{"code":"lzh","name":"文言"},{"code":"lzz","name":"Lazuri"},{"code":"mai","name":"मैथिली"},{"code":"map-bms","name":"Basa Banyumasan"},{"code":"mdf","name":"мокшень"},{"code":"mg","name":"Malagasy"},{"code":"mh","name":"Ebon"},{"code":"mhr","name":"олык марий"},{"code":"mi","name":"Māori"},{"code":"min","name":"Baso Minangkabau"},{"code":"mk","name":"македонски"},{"code":"ml","name":"മലയാളം"},{"code":"mn","name":"монгол"},{"code":"mo","name":"молдовеняскэ"},{"code":"mr","name":"मराठी"},{"code":"mrj","name":"кырык мары"},{"code":"ms","name":"Bahasa Melayu"},{"code":"mt","name":"Malti"},{"code":"mus","name":"Mvskoke"},{"code":"mwl","name":"Mirandés"},{"code":"my","name":"မြန်မာဘာသာ"},{"code":"myv","name":"эрзянь"},{"code":"mzn","name":"مازِرونی"},{"code":"na","name":"Dorerin Naoero"},{"code":"nah","name":"Nāhuatl"},{"code":"nan","name":"Bân-lâm-gú"},{"code":"nap","name":"Napulitano"},{"code":"nb","name":"norsk bokmål"},{"code":"nds","name":"Plattdüütsch"},{"code":"nds-nl","name":"Nedersaksies"},{"code":"ne","name":"नेपाली"},{"code":"new","name":"नेपाल भाषा"},{"code":"ng","name":"Oshiwambo"},{"code":"niu","name":"Niuē"},{"code":"nl","name":"Nederlands"},{"code":"nl-informal","name":"Nederlands (informeel)‎"},{"code":"nn","name":"norsk nynorsk"},{"code":"no","name":"norsk bokmål"},{"code":"nov","name":"Novial"},{"code":"nrm","name":"Nouormand"},{"code":"nso","name":"Sesotho sa Leboa"},{"code":"nv","name":"Diné bizaad"},{"code":"ny","name":"Chi-Chewa"},{"code":"oc","name":"occitan"},{"code":"olo","name":"Livvinкarjala"},{"code":"om","name":"Oromoo"},{"code":"or","name":"ଓଡ଼ିଆ"},{"code":"os","name":"Ирон"},{"code":"pa","name":"ਪੰਜਾਬੀ"},{"code":"pag","name":"Pangasinan"},{"code":"pam","name":"Kapampangan"},{"code":"pap","name":"Papiamentu"},{"code":"pcd","name":"Picard"},{"code":"pdc","name":"Deitsch"},{"code":"pdt","name":"Plautdietsch"},{"code":"pfl","name":"Pälzisch"},{"code":"pi","name":"पालि"},{"code":"pih","name":"Norfuk / Pitkern"},{"code":"pl","name":"polski"},{"code":"pms","name":"Piemontèis"},{"code":"pnb","name":"پنجابی"},{"code":"pnt","name":"Ποντιακά"},{"code":"prg","name":"Prūsiskan"},{"code":"ps","name":"پښتو"},{"code":"pt","name":"português"},{"code":"pt-br","name":"português do Brasil"},{"code":"qu","name":"Runa Simi"},{"code":"qug","name":"Runa shimi"},{"code":"rgn","name":"Rumagnôl"},{"code":"rif","name":"Tarifit"},{"code":"rm","name":"rumantsch"},{"code":"rmy","name":"Romani"},{"code":"rn","name":"Kirundi"},{"code":"ro","name":"română"},{"code":"roa-rup","name":"armãneashti"},{"code":"roa-tara","name":"tarandíne"},{"code":"ru","name":"русский"},{"code":"rue","name":"русиньскый"},{"code":"rup","name":"armãneashti"},{"code":"ruq","name":"Vlăheşte"},{"code":"ruq-cyrl","name":"Влахесте"},{"code":"ruq-latn","name":"Vlăheşte"},{"code":"rw","name":"Kinyarwanda"},{"code":"sa","name":"संस्कृतम्"},{"code":"sah","name":"саха тыла"},{"code":"sat","name":"Santali"},{"code":"sc","name":"sardu"},{"code":"scn","name":"sicilianu"},{"code":"sco","name":"Scots"},{"code":"sd","name":"سنڌي"},{"code":"sdc","name":"Sassaresu"},{"code":"sdh","name":"کوردی خوارگ"},{"code":"se","name":"sámegiella"},{"code":"sei","name":"Cmique Itom"},{"code":"ses","name":"Koyraboro Senni"},{"code":"sg","name":"Sängö"},{"code":"sgs","name":"žemaitėška"},{"code":"sh","name":"srpskohrvatski / српскохрватски"},{"code":"shi","name":"Tašlḥiyt/ⵜⴰⵛⵍⵃⵉⵜ"},{"code":"shi-latn","name":"Tašlḥiyt"},{"code":"shi-tfng","name":"ⵜⴰⵛⵍⵃⵉⵜ"},{"code":"si","name":"සිංහල"},{"code":"simple","name":"Simple English"},{"code":"sk","name":"slovenčina"},{"code":"sl","name":"slovenščina"},{"code":"sli","name":"Schläsch"},{"code":"sm","name":"Gagana Samoa"},{"code":"sma","name":"Åarjelsaemien"},{"code":"sn","name":"chiShona"},{"code":"so","name":"Soomaaliga"},{"code":"sq","name":"shqip"},{"code":"sr","name":"српски / srpski"},{"code":"sr-ec","name":"српски (ћирилица)‎"},{"code":"sr-el","name":"srpski (latinica)‎"},{"code":"srn","name":"Sranantongo"},{"code":"ss","name":"SiSwati"},{"code":"st","name":"Sesotho"},{"code":"stq","name":"Seeltersk"},{"code":"su","name":"Basa Sunda"},{"code":"sv","name":"svenska"},{"code":"sw","name":"Kiswahili"},{"code":"szl","name":"ślůnski"},{"code":"ta","name":"தமிழ்"},{"code":"tcy","name":"ತುಳು"},{"code":"te","name":"తెలుగు"},{"code":"tet","name":"tetun"},{"code":"tg","name":"тоҷикӣ"},{"code":"tg-cyrl","name":"тоҷикӣ"},{"code":"tg-latn","name":"tojikī"},{"code":"th","name":"ไทย"},{"code":"ti","name":"ትግርኛ"},{"code":"tk","name":"Türkmençe"},{"code":"tl","name":"Tagalog"},{"code":"tly","name":"толышә зывон"},{"code":"tn","name":"Setswana"},{"code":"to","name":"lea faka-Tonga"},{"code":"tokipona","name":"Toki Pona"},{"code":"tpi","name":"Tok Pisin"},{"code":"tr","name":"Türkçe"},{"code":"tru","name":"Ṫuroyo"},{"code":"ts","name":"Xitsonga"},{"code":"tt","name":"татарча/tatarça"},{"code":"tt-cyrl","name":"татарча"},{"code":"tt-latn","name":"tatarça"},{"code":"tum","name":"chiTumbuka"},{"code":"tw","name":"Twi"},{"code":"ty","name":"reo tahiti"},{"code":"tyv","name":"тыва дыл"},{"code":"tzm","name":"ⵜⴰⵎⴰⵣⵉⵖⵜ"},{"code":"udm","name":"удмурт"},{"code":"ug","name":"ئۇيغۇرچە / Uyghurche"},{"code":"ug-arab","name":"ئۇيغۇرچە"},{"code":"ug-latn","name":"Uyghurche"},{"code":"uk","name":"українська"},{"code":"ur","name":"اردو"},{"code":"uz","name":"oʻzbekcha/ўзбекча"},{"code":"uz-cyrl","name":"ўзбекча"},{"code":"uz-latn","name":"oʻzbekcha"},{"code":"ve","name":"Tshivenda"},{"code":"vec","name":"vèneto"},{"code":"vep","name":"vepsän kel’"},{"code":"vi","name":"Tiếng Việt"},{"code":"vls","name":"West-Vlams"},{"code":"vmf","name":"Mainfränkisch"},{"code":"vo","name":"Volapük"},{"code":"vot","name":"Vaďďa"},{"code":"vro","name":"Võro"},{"code":"wa","name":"walon"},{"code":"war","name":"Winaray"},{"code":"wo","name":"Wolof"},{"code":"wuu","name":"吴语"},{"code":"xal","name":"хальмг"},{"code":"xh","name":"isiXhosa"},{"code":"xmf","name":"მარგალური"},{"code":"yi","name":"ייִדיש"},{"code":"yo","name":"Yorùbá"},{"code":"yue","name":"粵語"},{"code":"za","name":"Vahcuengh"},{"code":"zea","name":"Zeêuws"},{"code":"zh","name":"中文"},{"code":"zh-classical","name":"文言"},{"code":"zh-cn","name":"中文(中国大陆)‎"},{"code":"zh-hans","name":"中文(简体)‎"},{"code":"zh-hant","name":"中文(繁體)‎"},{"code":"zh-hk","name":"中文(香港)‎"},{"code":"zh-min-nan","name":"Bân-lâm-gú"},{"code":"zh-mo","name":"中文(澳門)‎"},{"code":"zh-my","name":"中文(马来西亚)‎"},{"code":"zh-sg","name":"中文(新加坡)‎"},{"code":"zh-tw","name":"中文(台灣)‎"},{"code":"zh-yue","name":"粵語"},{"code":"zu","name":"isiZulu"}]

which is not small. And this data is used to get the language names to display language links. We can already do so by passing autonym to llprop. So I suggest we do so without pulling all languages.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 24 2016, 6:49 PM
Jdlrobson triaged this task as Normal priority.Mar 29 2016, 5:13 PM
Jdlrobson added a subscriber: Jdlrobson.

Please investigate if this is indeed possible as it will save our end users some bytes.

I investigated.
For the Hokkaido page:
this would reduce the API response from 28,684 to 15,240 so definitely significant.

Looking at it we'd need to

  • keep request for general to allow variants to continue to work
  • Rename langname to autonym

(this would remove the need for _getLanguagesFromApiResponse) which would reduce the startup module.

Seems like a no brainer to me so putting in to do

Change 280659 had a related patch set uploaded (by Bmansurov):
Simplify the API request to retrieve page languages

https://gerrit.wikimedia.org/r/280659

phuedx added a subscriber: phuedx.Apr 1 2016, 11:00 AM

Out of curiosity, why does Page#getLanguageLinks request the general site info (meta=siteinfo&siprop=general).

I think mainly to retrieve page variants.

Change 280659 merged by jenkins-bot:
Simplify the API request to retrieve page languages

https://gerrit.wikimedia.org/r/280659

bmansurov removed bmansurov as the assignee of this task.Apr 1 2016, 12:36 PM
Jdlrobson closed this task as Resolved.Apr 6 2016, 4:32 PM
Jdlrobson claimed this task.

signed off