[MediaWiki-commits] [Gerrit] mediawiki/core[master]: mw.widgets.DateInputWidget: Fix unexpected MMMMM or ddddd da...
Liangent has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/386305 ) Change subject: mw.widgets.DateInputWidget: Fix unexpected M or d date format .. mw.widgets.DateInputWidget: Fix unexpected M or d date format In some locale data in moment.js such as zh, date format already uses and . The original attempt to expand MMM to and ddd to inadvertently expands to M and to d, which is then interpreted as or followed by an unexpected single M or d. Change-Id: I2634dfbaaf9615a13dce7b8f4ba3c3bea6863a91 --- M resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/05/386305/1 diff --git a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js index f10c93d..0e7fc30 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js @@ -465,7 +465,8 @@ format = .replace( lll.replace( ll, '' ), '' ); if ( this.longDisplayFormat ) { - format = format.replace( 'MMM', '' ).replace( 'ddd', '' ); + format = format.replace( '', 'MMM' ).replace( 'MMM', '' ); + format = format.replace( '', 'ddd' ).replace( 'ddd', '' ); } return format; -- To view, visit https://gerrit.wikimedia.org/r/386305 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2634dfbaaf9615a13dce7b8f4ba3c3bea6863a91 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Chinese Conversion Table Update 2015-9 - change (mediawiki/core)
Liangent has submitted this change and it was merged. Change subject: Chinese Conversion Table Update 2015-9 .. Chinese Conversion Table Update 2015-9 Update the Chinese conversion table routinely to fix bugs reported from https://zh.wikipedia.org/wiki/Wikipedia:%E5%AD%97%E8%AF%8D%E8%BD%AC%E6%8D%A2/%E4%BF%AE%E5%A4%8D%E8%AF%B7%E6%B1%82 . It is only data changes and only works for Chinese WikiProjects. Change-Id: Icb47cf7d30a9bf09d55af9e96e34b9b5c6d6c9cf --- M includes/ZhConversion.php M maintenance/language/zhtable/simp2trad.manual M maintenance/language/zhtable/toCN.manual M maintenance/language/zhtable/toHK.manual M maintenance/language/zhtable/toTW.manual M maintenance/language/zhtable/toTrad.manual M maintenance/language/zhtable/tradphrases.manual M maintenance/language/zhtable/tradphrases_exclude.manual 8 files changed, 101 insertions(+), 28 deletions(-) Approvals: Liuxinyu970226: Looks good to me, but someone else must approve Liangent: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/ZhConversion.php b/includes/ZhConversion.php index 9e7d12c..6c768ff 100644 --- a/includes/ZhConversion.php +++ b/includes/ZhConversion.php @@ -294,6 +294,7 @@ '卖' => '賣', '卢' => '盧', '卤' => '鹵', +'卧' => '臥', '卫' => '衛', '却' => '卻', '厂' => '廠', @@ -3424,6 +3425,7 @@ '干股' => '乾股', '干肥' => '乾肥', '干脆' => '乾脆', +'干脆面' => '乾脆麵', '干花' => '乾花', '干刍' => '乾芻', '干苔' => '乾苔', @@ -3564,6 +3566,7 @@ '于慧' => '于慧', '于成龍' => '于成龍', '于成龙' => '于成龍', +'于承惠' => '于承惠', '于振' => '于振', '于振武' => '于振武', '于敏' => '于敏', @@ -3644,6 +3647,7 @@ '于赠' => '于贈', '于越' => '于越', '于軍' => '于軍', +'于逸堯' => '于逸堯', '于道泉' => '于道泉', '于远伟' => '于遠偉', '于遠偉' => '于遠偉', @@ -3829,6 +3833,8 @@ '信托' => '信託', '修杰楷' => '修杰楷', '修杰麟' => '修杰麟', +'修筑前' => '修築前', +'修筑后' => '修築後', '修胡刀' => '修鬍刀', '俯冲' => '俯衝', '个月里' => '個月裡', @@ -4112,7 +4118,6 @@ '削面' => '削麵', '克剥' => '剋剝', '克扣' => '剋扣', -'克星' => '剋星', '克期' => '剋期', '克死' => '剋死', '克薄' => '剋薄', @@ -4235,6 +4240,7 @@ '去山里' => '去山裡', '参数只' => '參數只', '参数里' => '參數裡', +'反反复复' => '反反覆覆', '反应制得' => '反應製得', '反朴' => '反樸', '反冲' => '反衝', @@ -4736,14 +4742,10 @@ '委托书' => '委託書', '奸夫' => '姦夫', '奸妇' => '姦婦', -'奸宄' => '姦宄', '奸情' => '姦情', '奸杀' => '姦殺', '奸污' => '姦污', '奸淫' => '姦淫', -'奸猾' => '姦猾', -'奸细' => '姦細', -'奸邪' => '姦邪', '威棱' => '威稜', '婢仆' => '婢僕', '嫁祸于' => '嫁禍於', @@ -4758,6 +4760,7 @@ '子里' => '子裡', '子里甲' => '子里甲', '字汇' => '字彙', +'字母后' => '字母後', '字码表' => '字碼表', '字里行间' => '字裡行間', '存折' => '存摺', @@ -5056,8 +5059,11 @@ '廢后' => '廢后', '广征' => '廣徵', '广舍' => '廣捨', +'广播里' => '廣播裡', '延历' => '延曆', '建于' => '建於', +'建筑前' => '建築前', +'建筑后' => '建築後', '弄干' => '弄乾', '弄丑' => '弄醜', '弄脏胸' => '弄髒胸', @@ -5131,6 +5137,7 @@ '影后' => '影后', '影相吊' => '影相弔', '役于' => '役於', +'往复式' => '往復式', '往日无仇' => '往日無讎', '往里' => '往裡', '待复' => '待覆', @@ -5405,7 +5412,6 @@ '欲令智昏' => '慾令智昏', '欲壑难填' => '慾壑難填', '欲念' => '慾念', -'欲望' => '慾望', '欲海' => '慾海', '欲火' => '慾火', '欲障' => '慾障', @@ -5472,6 +5478,7 @@ '手表面' => '手表面', '手里剑' => '手裏劍', '手里' => '手裡', +'手游' => '手遊', '手表' => '手錶', '手链' => '手鍊', '手松' => '手鬆', @@ -6227,6 +6234,7 @@ '水来汤里去' => '水來湯裡去', '水准' => '水準', '水无怜奈' => '水無怜奈', +'水表示' => '水表示', '水表面' => '水表面', '水里' => '水裡', '水里商工' => '水里商工', @@ -6499,6 +6507,7 @@ '沈丹客运' => '瀋丹客運', '沈丹线' => '瀋丹線', '沈丹铁路' => '瀋丹鐵路', +'沈丹高' => '瀋丹高', '沈北' => '瀋北', '沈吉' => '瀋吉', '沈大线' => '瀋大線', @@ -6714,7 +6723,6 @@ '发松' => '發鬆', '发面' => '發麵', '白干儿' => '白乾兒', -'白子里' => '白子里', '白术' => '白朮', '白朴' => '白樸', '白净面皮' => '白淨面皮', @@ -6735,6 +6743,7 @@ '百只足夠' => '百只足夠', '百周后' => '百周後', '百天后' => '百天後', +'百子里' => '百子里', '百年' => '百年', '百拙千丑' => '百拙千醜', '百科里' => '百科裡', @@ -6970,6 +6979,7 @@ '窗明几净' => '窗明几淨', '窗帘' => '窗簾', '窝里' => '窩裡', +'窝里斗' => '窩裡鬥', '穷于' => '窮於', '穷追不舍' => '窮追不捨', '穷发' => '窮髮', @@ -7280,6 +7290,7 @@ '聚药雄蕊' => '聚葯雄蕊', '闻风后' => '聞風後', '联系' => '聯繫', +'声母后' => '聲母後', '听于' => '聽於', '肉干' => '肉乾', '肉欲' => '肉慾', @@ -7970,11 +7981,13 @@ '警报钟' => '警報鐘', '警示钟' => '警示鐘', '警钟' => '警鐘', +'译制' => '譯製', '译注' => '譯註', '护发' => '護髮', '变征' => '變徵', '变丑' => '變醜', '仇隙' => '讎隙', +'赞一个' => '讚一個', '赞不绝口' => '讚不絕口', '赞佩' => '讚佩', '赞呗' => '讚唄', @@ -8593,7 +8606,6 @@ '防御' => '防禦', '防范' => '防範', '防锈' => '防鏽', -'防台' => '防颱', '阻于' => '阻於', '阿里' => '阿里', '附于' => '附於', @@ -8683,6 +8695,7 @@ '电码表' => '電碼表', '电冲' => '電衝', '电视台风' => '電視台風', +'电视里' => '電視裡', '电表' => '電錶', '电钟' => '電鐘', '震栗' => '震慄', @@ -9345,7 +9358,6 @@ '齿危发秀' => '齒危髮秀', '齿落发白' => '齒落髮白', '齿发' => '齒髮', -'出儿' => '齣兒', '龙岩' => '龍巖', '龙卷' => '龍捲', '龙眼干' => '龍眼乾', @@ -9354,6 +9366,10 @@ '龙斗虎伤' => '龍鬥虎傷', '龜山庄' => '龜山庄', '龟鉴' => '龜鑑', +',并力' => ',並力', +',并力攻' => ',并力攻', +',并力討' => ',并力討', +',并力讨' => ',并力討', ',个中' => ',箇中', ); @@ -13874,6 +13890,8 @@ '傅里叶' => '傅立葉', '光盘' => '光碟', '光驱' => '光碟機', +'开普勒' => '克卜勒', +'開普勒' => '克卜勒', '克罗地亚' => '克羅埃西亞', '克羅地亞' => '克羅埃西亞', '克里斯托弗' => '克里斯多福', @@ -13896,6 +13914,7 @@ '包豪斯' => '包浩斯',
[MediaWiki-commits] [Gerrit] zhtable makefile: Remove unused variables, fix almost all pe... - change (mediawiki/core)
Liangent has submitted this change and it was merged. Change subject: zhtable makefile: Remove unused variables, fix almost all pep8 errors .. zhtable makefile: Remove unused variables, fix almost all pep8 errors Change-Id: I7ab1ffeeb2a5592fbe143f27801c11248c167093 --- M maintenance/language/zhtable/Makefile.py 1 file changed, 235 insertions(+), 207 deletions(-) Approvals: Hashar: Looks good to me, but someone else must approve Liangent: Looks good to me, approved diff --git a/maintenance/language/zhtable/Makefile.py b/maintenance/language/zhtable/Makefile.py index 4ab57d4..5924c66 100755 --- a/maintenance/language/zhtable/Makefile.py +++ b/maintenance/language/zhtable/Makefile.py @@ -1,9 +1,13 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # @author Philip -import tarfile as tf -import zipfile as zf -import os, re, shutil, sys, platform +import os +import platform +import re +import shutil +import sys +import tarfile +import zipfile pyversion = platform.python_version() islinux = platform.system().lower() == 'linux' @@ -18,16 +22,18 @@ if i < 0x1: return _unichr(i) else: -return _unichr( 0xD7C0 + ( i>>10 ) ) + _unichr( 0xDC00 + ( i & 0x3FF ) ) +return _unichr(0xD7C0 + (i >> 10)) + _unichr(0xDC00 + (i & 0x3FF)) elif pyversion[:2] == '3.': import urllib.request as urllib_request unichr = chr -def unichr2( *args ): -return [unichr( int( i.split('<')[0][2:], 16 ) ) for i in args] -def unichr3( *args ): -return [unichr( int( i[2:7], 16 ) ) for i in args if i[2:7]] +def unichr2(*args): +return [unichr(int(i.split('<')[0][2:], 16)) for i in args] + + +def unichr3(*args): +return [unichr(int(i[2:7], 16)) for i in args if i[2:7]] # DEFINE UNIHAN_VER = '6.3.0' @@ -37,189 +43,201 @@ LIBTABE_VER = '0.2.3' # END OF DEFINE -def download( url, dest ): -if os.path.isfile( dest ): -print( 'File %s is up to date.' % dest ) + +def download(url, dest): +if os.path.isfile(dest): +print('File %s is up to date.' % dest) return global islinux if islinux: -# we use wget instead urlretrieve under Linux, +# we use wget instead urlretrieve under Linux, # because wget could display details like download progress -os.system( 'wget %s -O %s' % ( url, dest ) ) +os.system('wget %s -O %s' % (url, dest)) else: -print( 'Downloading from [%s] ...' % url ) -urllib_request.urlretrieve( url, dest ) -print( 'Download complete.\n' ) +print('Downloading from [%s] ...' % url) +urllib_request.urlretrieve(url, dest) +print('Download complete.\n') return -def uncompress( fp, member, encoding = 'U8' ): -name = member.rsplit( '/', 1 )[-1] -print( 'Extracting %s ...' % name ) -fp.extract( member ) -shutil.move( member, name ) + +def uncompress(fp, member, encoding='U8'): +name = member.rsplit('/', 1)[-1] +print('Extracting %s ...' % name) +fp.extract(member) +shutil.move(member, name) if '/' in member: -shutil.rmtree( member.split( '/', 1 )[0] ) +shutil.rmtree(member.split('/', 1)[0]) if pyversion[:1] in ['2']: -fc = open( name, 'rb', encoding, 'ignore' ) +fc = open(name, 'rb', encoding, 'ignore') else: -fc = open( name, 'r', encoding = encoding, errors = 'ignore' ) +fc = open(name, 'r', encoding=encoding, errors='ignore') return fc unzip = lambda path, member, encoding = 'U8': \ -uncompress( zf.ZipFile( path ), member, encoding ) +uncompress(zipfile.ZipFile(path), member, encoding) untargz = lambda path, member, encoding = 'U8': \ -uncompress( tf.open( path, 'r:gz' ), member, encoding ) +uncompress(tarfile.open(path, 'r:gz'), member, encoding) -def parserCore( fp, pos, beginmark = None, endmark = None ): + +def parserCore(fp, pos, beginmark=None, endmark=None): if beginmark and endmark: start = False -else: start = True +else: +start = True mlist = set() for line in fp: -if beginmark and line.startswith( beginmark ): +if beginmark and line.startswith(beginmark): start = True continue -elif endmark and line.startswith( endmark ): +elif endmark and line.startswith(endmark): break -if start and not line.startswith( '#' ): +if start and not line.startswith('#'): elems = line.split() -if len( elems ) < 2: +if len(elems) < 2: continue -elif len( elems[0] ) > 1 and \ -len( elems[pos] ) > 1: # words only -mlist.add( elems[pos] ) +elif len(elems[0]) > 1 and len(elems[pos]) > 1: # words only +mlist.add(elems[pos]) return m
[MediaWiki-commits] [Gerrit] Fix wrong translation of special page name in zh-hans - change (mediawiki...ApiFeatureUsage)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/245201 Change subject: Fix wrong translation of special page name in zh-hans .. Fix wrong translation of special page name in zh-hans Change-Id: I1cf7e86dbfd437c03a93a001dc525b52d57b24d2 --- M ApiFeatureUsage.alias.php 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ApiFeatureUsage refs/changes/01/245201/1 diff --git a/ApiFeatureUsage.alias.php b/ApiFeatureUsage.alias.php index d912cc8..47a49a0 100644 --- a/ApiFeatureUsage.alias.php +++ b/ApiFeatureUsage.alias.php @@ -56,5 +56,5 @@ /** Simplified Chinese (中文(简体)) */ $specialPageAliases['zh-hans'] = array( - 'ApiFeatureUsage' => array( 'Api功能用法' ), -); \ No newline at end of file + 'ApiFeatureUsage' => array( 'Api功能使用率' ), +); -- To view, visit https://gerrit.wikimedia.org/r/245201 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1cf7e86dbfd437c03a93a001dc525b52d57b24d2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ApiFeatureUsage Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Clean up zh-tw.json - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/244892 Change subject: Clean up zh-tw.json .. Clean up zh-tw.json Change-Id: I8930136a2feabdd5ce229e31927678f01bc53fab --- M languages/i18n/zh-tw.json 1 file changed, 4 insertions(+), 542 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/92/244892/1 diff --git a/languages/i18n/zh-tw.json b/languages/i18n/zh-tw.json index bb5e9ab..3e25eec 100644 --- a/languages/i18n/zh-tw.json +++ b/languages/i18n/zh-tw.json @@ -14,552 +14,14 @@ "Urhixidur", "Wong128hk", "Zerng07", -"לערי ריינהארט" +"לערי ריינהארט", +"LNDDYL", +"Carrotkit" ] }, -"tog-underline": "連結標注底線", -"tog-justify": "段落對齊", -"tog-hideminor": "近期變動中隱藏細微修改", -"tog-usenewrc": "使用強化的近期變動 (需要JavaScript)", -"tog-numberheadings": "自動編號標題", -"tog-showtoolbar": "顯示編輯工具欄 (需要JavaScript)", -"tog-watchcreations": "將我建立的頁面加進我的監視列表", -"tog-watchdefault": "將我更改的頁面添加到我的監視列表中", -"tog-minordefault": "預設將編輯設定為細微修改", -"tog-enotifwatchlistpages": "當我監視的頁面改變時發電子郵件給我", -"tog-enotifusertalkpages": "當我的對話頁有更動時發電子郵件通知我", -"tog-shownumberswatching": "顯示監視數目", -"tog-uselivepreview": "使用即時預覽 (JavaScript) (試驗中)", -"tog-watchlisthideminor": "監視列表中隱藏細微修改", -"tog-ccmeonemails": "當我寄電子郵件給其他使用者時,也寄一份複本到我的信箱。", -"saturday": "星期六", -"sun": "日", -"mon": "一", -"tue": "二", -"wed": "三", -"thu": "四", -"fri": "五", -"january": "一月", -"february": "二月", -"march": "三月", -"april": "四月", -"may_long": "五月", -"june": "六月", -"july": "七月", -"august": "八月", -"september": "九月", -"october": "十月", -"november": "十一月", -"december": "十二月", -"january-gen": "一月", -"february-gen": "二月", -"march-gen": "三月", -"april-gen": "四月", -"may-gen": "五月", -"june-gen": "六月", -"july-gen": "七月", -"august-gen": "八月", -"september-gen": "九月", -"october-gen": "十月", -"november-gen": "十一月", -"december-gen": "十二月", -"jan": "1月", -"feb": "2月", -"mar": "3月", -"apr": "4月", -"may": "5月", -"jun": "6月", -"jul": "7月", -"aug": "8月", -"sep": "9月", -"oct": "10月", -"nov": "11月", -"dec": "12月", -"subcategories": "子分類", -"qbfind": "尋找", -"vector-action-protect": "保護", -"vector-view-create": "建立", -"vector-view-view": "閱讀", -"help": "使用說明", -"search": "搜尋", -"searchbutton": "搜尋", -"history": "修訂記錄", -"history_short": "歷史", -"edit": "編輯", -"create": "建立", -"delete": "刪除", -"protect_change": "更改", -"postcomment": "新段落", -"toolbox": "工具箱", -"userpage": "檢視使用者頁面", "projectpage": "檢視計畫頁面", -"lastmodifiedat": "本頁最後更動時間在 $1 $2。", -"jumptosearch": "搜尋", -"aboutsite": "關於 {{SITENAME}}", "copyright": "本站的文字內容除另有聲明外,全部以 $1 條款授權使用。", -"disclaimers": "免責聲明", -"edithelp": "編輯說明", -"mainpage": "首頁", -"portal": "社群入口", -"portal-url": "Project:社群入口", -"badaccess-groups": "您剛才的請求只有{{PLURAL:$2|這個|這些}}使用者組的使用者才能使用: $1", -"editold": "編輯", -"editsectionhint": "编辑段落:$1", -"showtoc": "顯示", -"hidetoc": "隱藏", -"thisisdeleted": "檢視或復原$1?", -"site-rss-feed": "訂閱 $1 的 RSS 資料來源", -"site-atom-feed": "訂閱 $1 的 Atom 資料來源", -"page-rss-feed": "訂閱「$1」的 RSS 資料來源", -"page-atom-feed": "訂閱「$1」的 Atom 資料來源", -"red-link-title": "$1 (頁面不存在)", -"nstab-main": "頁面", -"nstab-user": "使用者頁面", -"nstab-special": "特殊頁面", "nstab-project": "計畫頁面", "nstab-mediawiki": "介面", -"nstab-help": "說明頁面", -"nosuchactiontext": "該URL所指定的動作無效。\n您可能打錯URL,或點了錯誤連結。\n這也可能是{{SITENAME}}所使用的軟件出現了錯誤。", -"readonlytext": "資料庫目前禁止輸入新內容及更改,\n這很可能是由於資料庫正在維修,之後即可復原。\n管理員有如下解釋:\n$1", -"cannotdelete": "無法刪除選定的頁面或圖片(它可能已經被其他人刪除了)。", -"actionthrottledtext": "系統因為反垃圾編輯的考量,禁止如此頻繁地修改資料,請數分鐘後再嘗試。", -"viewsourcetext": "你可以檢視並複製本頁面的原始碼。", -"editinginterface": "'''警告:''' 您正在編輯的頁面是正用在軟體上的介面文字。改變此頁將影響其他用戶的介面外觀。如要翻譯,請考慮使用 [//translatewiki.net/wiki/Main_Page?setlang=zh-hant translatewiki.net],一個用來為MediaWiki軟體本地化的計畫。", -"ns-specialprotected": "在{{ns:special}}名字空間中的頁面是不可以編輯的。", -"logouttext": "您現在已經登出。\n\n您可以以匿名方式繼續使用{{SITENAME}},或者以相同或不同用戶身份[[Special:UserLogin|登入]]。\n請注意,如果你再次登入,此頁或會繼續顯示,直到您清除瀏覽器快取。", -"welcomecreation": "== 歡迎,$1! ==\n您的帳號已經建立。\n請不要忘記設定[[Special:Preferences|{{SITENAME}}的個人參數]]。", -"yourname": "您的使用者名:", -"yourpassword": "密碼:", -"login": "登入", -"nav-login-createaccount": "登入/建立新帳號", -"userlogin": "登入/建立新帳號", -"logout": "登出", -"userlogout": "登出", -"nologin": "您還沒有帳號嗎?$1。", -"nologinlink": "建立新帳號", -"createaccount": "建立新帳號", -"gotaccount": "已經擁有帳號?$1。", -"badretype": "你所輸入的密碼並不相同。", -"userexists": "您所輸入的使用者名稱已經存在,請另選一個名稱。", -"nocookiesnew": "已成功建
[MediaWiki-commits] [Gerrit] Fix accidential variable overriding in manualWordsTable - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/242584 Change subject: Fix accidential variable overriding in manualWordsTable .. Fix accidential variable overriding in manualWordsTable It doesn't make sense to get a table passed in then ignore that one completely so it doesn't look like the intentional behavior, and regardless of this, the edited code is still more logical. Change-Id: I98bc841e982d328e268309c06fefd3d3ca9f6cd7 --- M maintenance/language/zhtable/Makefile.py 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/84/242584/1 diff --git a/maintenance/language/zhtable/Makefile.py b/maintenance/language/zhtable/Makefile.py index 4ab57d4..9d64a89 100755 --- a/maintenance/language/zhtable/Makefile.py +++ b/maintenance/language/zhtable/Makefile.py @@ -229,7 +229,7 @@ def manualWordsTable( path, conv_table, reconv_table ): fp = open( path, 'r', encoding = 'U8' ) -reconv_table = {} +out_table = {} wordlist = [line.split( '#' )[0].strip() for line in fp] wordlist = list( set( wordlist ) ) wordlist.sort( key = lambda w: ( len(w), w ), reverse = True ) @@ -238,9 +238,9 @@ new_word = translate( word, conv_table ) rcv_word = translate( word, reconv_table ) if word != rcv_word: -reconv_table[word] = word -reconv_table[new_word] = word -return reconv_table +out_table[word] = word +out_table[new_word] = word +return out_table def defaultWordsTable( src_wordlist, src_tomany, char_conv_table, char_reconv_table ): wordlist = list( src_wordlist ) -- To view, visit https://gerrit.wikimedia.org/r/242584 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I98bc841e982d328e268309c06fefd3d3ca9f6cd7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Drop zh-tw message "saveprefs" - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/239003 Change subject: Drop zh-tw message "saveprefs" .. Drop zh-tw message "saveprefs" Change-Id: I4b0da9f17e77a9a0d7af7522d7cb59d8891246f7 --- M languages/i18n/zh-tw.json 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/03/239003/1 diff --git a/languages/i18n/zh-tw.json b/languages/i18n/zh-tw.json index 81e0605..06b358b 100644 --- a/languages/i18n/zh-tw.json +++ b/languages/i18n/zh-tw.json @@ -245,7 +245,6 @@ "prefs-personal": "使用者資料", "prefs-rc": "近期變動", "prefs-watchlist-days": "監視列表中顯示記錄的最長天數:", -"saveprefs": "保存偏好設定", "resetprefs": "重設參數", "searchresultshead": "搜尋結果設定", "recentchangesdays": "近期變動中的顯示日數:", -- To view, visit https://gerrit.wikimedia.org/r/239003 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4b0da9f17e77a9a0d7af7522d7cb59d8891246f7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Drop message whatlinkshere-title/zh-tw - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/235737 Change subject: Drop message whatlinkshere-title/zh-tw .. Drop message whatlinkshere-title/zh-tw This message contains incorrect wording as reported by user. Remove it to let it fall back to zh-hant message. Change-Id: Ieefb3a0649d5907eb29c91bf021550f573b5bf4f --- M languages/i18n/zh-tw.json 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/37/235737/1 diff --git a/languages/i18n/zh-tw.json b/languages/i18n/zh-tw.json index 81e0605..8e5704e 100644 --- a/languages/i18n/zh-tw.json +++ b/languages/i18n/zh-tw.json @@ -414,7 +414,6 @@ "sp-contributions-blocklog": "封鎖記錄", "sp-contributions-userrights": "使用者權限管理", "sp-contributions-username": "IP位址或使用者名稱:", -"whatlinkshere-title": "鏈接到$1的頁面", "blockip": "封鎖使用者", "ipadressorusername": "IP地址或使用者名:", "ipbreason-dropdown": "*一般的封鎖理由\n** 屢次增加不實資料\n** 刪除頁面內容\n** 外部連結廣告\n** 在頁面中增加無意義文字\n** 無禮的行為、攻擊/騷擾別人\n** 濫用多個帳號\n** 不能接受的使用者名", -- To view, visit https://gerrit.wikimedia.org/r/235737 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieefb3a0649d5907eb29c91bf021550f573b5bf4f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Prevent unexpected }- in converter output - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/206079 Change subject: Prevent unexpected }- in converter output .. Prevent unexpected }- in converter output Previously for input -{X}-, the converter sees -{A}-, so A}- with this change. In further processing, the span tag may be parsed and have its title attrib converted. For cases where the content is not processed further (eg. "R" = raw flag), "-{X}-" is left as is in the attrib, which is not so ideal, but at least it's better than the original extra }- outside the whole tag. Change-Id: Idbaaf53f914f362e5b8cc9fad02a524f8d591bb7 --- M includes/Sanitizer.php M tests/parser/parserTests.txt 2 files changed, 23 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/79/206079/1 diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index 96193a7..713cfd4 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -1051,6 +1051,7 @@ '>'=> '>', // we've received invalid input '"'=> '"', // which should have been escaped. '{'=> '{', + '}'=> '}', // prevent unpaired language conversion syntax '['=> '[', "''" => , 'ISBN' => 'ISBN', diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index e965352..43097e9 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -18305,6 +18305,28 @@ !! end !! test +HTML markups with conversion syntax in attribs, nested in other conversion blocks +!! options +language=zh variant=zh-cn +!! wikitext +-{zh;zh-hans;zh-hant|A}- +!! html +A + +!! end + +!! test +HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet) +!! options +language=zh variant=zh-cn disabled +!! wikitext +-{A}- +!! html +A + +!! end + +!! test Proper conversion of text in external links !! options language=sr variant=sr-ec -- To view, visit https://gerrit.wikimedia.org/r/206079 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idbaaf53f914f362e5b8cc9fad02a524f8d591bb7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove zh-tw message "editing" - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/203786 Change subject: Remove zh-tw message "editing" .. Remove zh-tw message "editing" The current string is incorrect (written in zh-hans); removing it to let it fall back to zh-hant. Since zh-tw exporting has been disabled on translatewiki.net, it's not possible to fix it there. Change-Id: I3cc7bbb2065ecae535986525367d26dfc82c49b1 --- M languages/i18n/zh-tw.json 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/86/203786/1 diff --git a/languages/i18n/zh-tw.json b/languages/i18n/zh-tw.json index 9abb137..74a4542 100644 --- a/languages/i18n/zh-tw.json +++ b/languages/i18n/zh-tw.json @@ -190,7 +190,6 @@ "session_fail_preview": "'''很抱歉!由於部份資料遺失,我們無法處理您的編輯。'''\n請再試一次。\n如果仍然失敗,請[[Special:UserLogout|登出]]後重新登入。", "session_fail_preview_html": "'''很抱歉!部份資料已遺失,我們無法處理您的編輯。''如果這個編輯過程沒有問題,請再試一次。如果仍然有問題,請登出後再重新登入一次。'''", "token_suffix_mismatch": "'''由於您使用者端中的編輯信符毀損了一些標點符號字元,為防止編輯的文字損壞,您的編輯已經被拒絕。\n這種情況通常出現於使用含有很多臭蟲、以網路為主的匿名代理服務的時候。'''", -"editing": "正在编辑 $1", "editingcomment": "正在編輯$1(新段落)", "storedversion": "已保存版本", "nonunicodebrowser": "'''警告: 您的瀏覽器不相容Unicode編碼。這裡有一個工作區將使您能安全地編輯頁面: 非ASCII字元將以十六進製編碼模式出現在編輯框中。'''", -- To view, visit https://gerrit.wikimedia.org/r/203786 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3cc7bbb2065ecae535986525367d26dfc82c49b1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Output converted namespace name in nstab when nstab-* is not... - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/201887 Change subject: Output converted namespace name in nstab when nstab-* is not defined .. Output converted namespace name in nstab when nstab-* is not defined In languages without converter implemented, FakeConverter just invokes Language::getFormattedNsText(), which is the function used originally. Change-Id: Ieb34a65776cf69bcd67f1ed8402eb3d38ece0f0c --- M includes/skins/SkinTemplate.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/87/201887/1 diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index b0390e9..61aad92 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -717,7 +717,7 @@ $text = $msg->text(); } else { global $wgContLang; - $text = $wgContLang->getFormattedNsText( + $text = $wgContLang->getConverter()->convertNamespace( MWNamespace::getSubject( $title->getNamespace() ) ); } -- To view, visit https://gerrit.wikimedia.org/r/201887 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieb34a65776cf69bcd67f1ed8402eb3d38ece0f0c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix I1bb0315d: only use tab as separator in *.manual - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/197863 Change subject: Fix I1bb0315d: only use tab as separator in *.manual .. Fix I1bb0315d: only use tab as separator in *.manual This fixes incorrect parsing of phrases with spaces in them. Change-Id: Ifb6b33b937a7b82218172e3fdd937bda4ea4cc6c --- M includes/ZhConversion.php M maintenance/language/zhtable/Makefile.py M maintenance/language/zhtable/toCN.manual M maintenance/language/zhtable/toHK.manual M maintenance/language/zhtable/toTW.manual M maintenance/language/zhtable/toTrad.manual M maintenance/language/zhtable/trad2simp.manual 7 files changed, 397 insertions(+), 397 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/63/197863/1 diff --git a/includes/ZhConversion.php b/includes/ZhConversion.php index 4be2751..833e8a7 100644 --- a/includes/ZhConversion.php +++ b/includes/ZhConversion.php @@ -3002,10 +3002,10 @@ '𫛢' => '鸋', '𫛶' => '鶒', '𫛸' => '鶗', -'0出現' => '0出現', '0出现' => '0出現', -'0出線' => '0出線', +'0出現' => '0出現', '0出线' => '0出線', +'0出線' => '0出線', '0只支持' => '0只支持', '0只支援' => '0只支援', '0周后' => '0周後', @@ -3213,8 +3213,8 @@ '不干涉' => '不干涉', '不干牠' => '不干牠', '不干犯' => '不干犯', -'不干預' => '不干預', '不干预' => '不干預', +'不干預' => '不干預', '不干' => '不幹', '不吊' => '不弔', '不卷' => '不捲', @@ -3228,12 +3228,13 @@ '不负所托' => '不負所托', '不通吊庆' => '不通弔慶', '不丑' => '不醜', -'不采聲' => '不采聲', '不采声' => '不采聲', +'不采聲' => '不采聲', '不锈钢' => '不鏽鋼', '不食干腊' => '不食乾腊', '不斗' => '不鬥', '丑三' => '丑三', +'丑婆子' => '丑婆子', '丑年' => '丑年', '丑日' => '丑日', '丑旦' => '丑旦', @@ -3288,8 +3289,8 @@ '丰神' => '丰神', '丰茸' => '丰茸', '丰采' => '丰采', -'丰韻' => '丰韻', '丰韵' => '丰韻', +'丰韻' => '丰韻', '主仆' => '主僕', '主干' => '主幹', '主钟差' => '主鐘差', @@ -3322,11 +3323,9 @@ '九只' => '九隻', '九余' => '九餘', '也斗了胆' => '也斗了膽', -'干上' => '乾上', '干干' => '乾乾', '干干儿的' => '乾乾兒的', '干干净净' => '乾乾淨淨', -'干了' => '乾了', '干井' => '乾井', '干个够' => '乾個夠', '干儿' => '乾兒', @@ -3364,7 +3363,6 @@ '干巴' => '乾巴', '干式' => '乾式', '干弟' => '乾弟', -'干得' => '乾得', '干急' => '乾急', '干性' => '乾性', '干打雷' => '乾打雷', @@ -3507,8 +3505,8 @@ '于仲文' => '于仲文', '于佳卉' => '于佳卉', '于来山' => '于來山', -'于偉國' => '于偉國', '于伟国' => '于偉國', +'于偉國' => '于偉國', '于光新' => '于光新', '于光遠' => '于光遠', '于光远' => '于光遠', @@ -3524,20 +3522,20 @@ '于化虎' => '于化虎', '于占元' => '于占元', '于友泽' => '于友澤', -'于台烟' => '于台煙', '于台煙' => '于台煙', +'于台烟' => '于台煙', '于右任' => '于右任', '于吉' => '于吉', '于和伟' => '于和偉', '于品海' => '于品海', -'于國楨' => '于國楨', '于国桢' => '于國楨', +'于國楨' => '于國楨', '于国治' => '于國治', '于國治' => '于國治', -'于堅' => '于堅', '于坚' => '于堅', -'于大宝' => '于大寶', +'于堅' => '于堅', '于大寶' => '于大寶', +'于大宝' => '于大寶', '于天仁' => '于天仁', '于天龙' => '于天龍', '于奇库杜克' => '于奇庫杜克', @@ -3547,32 +3545,32 @@ '于娟' => '于娟', '于子千' => '于子千', '于孔兼' => '于孔兼', -'于学忠' => '于學忠', '于學忠' => '于學忠', +'于学忠' => '于學忠', '于家堡' => '于家堡', '于寘' => '于寘', '于宝轩' => '于寶軒', -'于小伟' => '于小偉', '于小偉' => '于小偉', +'于小伟' => '于小偉', '于小彤' => '于小彤', '于小惠' => '于小惠', '于少保' => '于少保', '于山' => '于山', -'于山國' => '于山國', '于山国' => '于山國', -'于帅' => '于帥', +'于山國' => '于山國', '于帥' => '于帥', +'于帅' => '于帥', '于幼軍' => '于幼軍', '于幼军' => '于幼軍', '于康震' => '于康震', -'于广洲' => '于廣洲', '于廣洲' => '于廣洲', +'于广洲' => '于廣洲', '于式枚' => '于式枚', -'于从濂' => '于從濂', '于從濂' => '于從濂', +'于从濂' => '于從濂', '于德海' => '于德海', -'于志寧' => '于志寧', '于志宁' => '于志寧', +'于志寧' => '于志寧', '于忠肃集' => '于忠肅集', '于思' => '于思', '于慎行' => '于慎行', @@ -3585,26 +3583,26 @@ '于敏中' => '于敏中', '于斌' => '于斌', '于斯塔德' => '于斯塔德', -'于斯納爾斯貝里' => '于斯納爾斯貝里', '于斯纳尔斯贝里' => '于斯納爾斯貝里', -'于斯達爾' => '于斯達爾', +'于斯納爾斯貝里' => '于斯納爾斯貝里', '于斯达尔' => '于斯達爾', -'于明濤' => '于明濤', +'于斯達爾' => '于斯達爾', '于明涛' => '于明濤', +'于明濤' => '于明濤', '于是之' => '于是之', '于晨楠' => '于晨楠', '于晴' => '于晴', -'于会泳' => '于會泳', '于會泳' => '于會泳', -'于根偉' => '于根偉', +'于会泳' => '于會泳', '于根伟' => '于根偉', +'于根偉' => '于根偉', '于格' => '于格', -'于枫' => '于楓', '于楓' => '于楓', +'于枫' => '于楓', '于荣光' => '于榮光', '于樂' => '于樂', -'于樹潔' => '于樹潔', '于树洁' => '于樹潔', +'于樹潔' => '于樹潔', '于欣' => '于欣', '于欣源' => '于欣源', '于正昇' => '于正昇', @@ -3615,25 +3613,25 @@ '于江震' => '于江震', '于波' => '于波', '于洋' => '于洋', -'于洪區' => '于洪區', '于洪区' => '于洪區', +'于洪區' => '于洪區', '于浩威' => '于浩威', '于海' => '于海', '于海洋' => '于海洋', -'于湘蘭' => '于湘蘭', '于湘兰' => '于湘蘭', +'于湘蘭' => '于湘蘭', '于漢超' => '于漢超', '于汉超' => '于漢超', '于澄' => '于澄', -'于澤爾' => '于澤爾', '于泽尔' => '于澤爾', -'于涛' => '于濤', +'于澤爾' => '于澤爾', '于濤' => '于濤', +'于涛' => '于濤', '于熙珍' => '于熙珍', -'于尔岑' => '于爾岑', '于爾岑' => '于爾岑', -'于尔根' => '于爾根', +'于尔岑' => '于爾岑', '于爾根' => '于爾根', +'于尔根' => '于爾根', '于尔里克' => '于爾里克', '于爾里克' => '于爾里克', '于特森' => '于特森', @@ -3646,8 +3644,8 @@ '于美人' => '于美人', '于耘婕' => '于耘婕', '于若木' => '于若木', -'于荫霖' => '于蔭霖', '于蔭霖' => '于蔭霖', +'于荫霖' => '于蔭霖', '于衡' => '于衡', '于西翰' => '于西翰', '于謙' => '于謙', @@ -3663,36 +3661,36 @@ '于道泉' => '于道泉', '于远伟' => '于遠偉', '于遠偉' => '于遠偉', -'于都县' => '于都縣', '于都縣' => '于都縣', +'于都县' => '于都縣', '于里察' => '于里察', '于阗' => '于闐', -'于双戈' => '于雙戈', '于雙戈' => '于雙戈', +'于双戈' => '于雙戈', '于云鹤' => '于雲鶴', '于震' => '于震', '于震寰' => '于震寰', '于震环' => '于震環',
[MediaWiki-commits] [Gerrit] Change loading order of Chinese conversion tables - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/158366 Change subject: Change loading order of Chinese conversion tables .. Change loading order of Chinese conversion tables Previously, the zh-cn table was composed by: (1) Load zh2Hans as zh-hans table (2) Load zh2CN + zh2Hans as zh-cn table (3) Load Conversiontable/zh-hans + zh-hans as zh-hans table (4) Load Conversiontable/zh-cn + zh-cn as zh-cn table (5) Load zh-hans + zh-cn as the final zh-cn table The new loading order is: (1) Load zh2Hans as zh-hans table (2) Load zh2CN as zh-cn table (3) Load Conversiontable/zh-hans + zh-hans as zh-hans table (4) Load Conversiontable/zh-cn + zh-cn as zh-cn table (5) Load zh-cn + zh-hans as the final zh-cn table Change-Id: Ie9d08b85d4911618946fa7efd23eb898412449e5 --- M languages/classes/LanguageZh.php 1 file changed, 12 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/66/158366/1 diff --git a/languages/classes/LanguageZh.php b/languages/classes/LanguageZh.php index dfdc6b1..90d538d 100644 --- a/languages/classes/LanguageZh.php +++ b/languages/classes/LanguageZh.php @@ -67,23 +67,23 @@ $this->mTables = array( 'zh-hans' => new ReplacementArray( $zh2Hans ), 'zh-hant' => new ReplacementArray( $zh2Hant ), - 'zh-cn' => new ReplacementArray( array_merge( $zh2Hans, $zh2CN ) ), - 'zh-hk' => new ReplacementArray( array_merge( $zh2Hant, $zh2HK ) ), - 'zh-mo' => new ReplacementArray( array_merge( $zh2Hant, $zh2HK ) ), - 'zh-my' => new ReplacementArray( array_merge( $zh2Hans, $zh2SG ) ), - 'zh-sg' => new ReplacementArray( array_merge( $zh2Hans, $zh2SG ) ), - 'zh-tw' => new ReplacementArray( array_merge( $zh2Hant, $zh2TW ) ), + 'zh-cn' => new ReplacementArray( $zh2CN ), + 'zh-hk' => new ReplacementArray( $zh2HK ), + 'zh-mo' => new ReplacementArray( $zh2HK ), + 'zh-my' => new ReplacementArray( $zh2SG ), + 'zh-sg' => new ReplacementArray( $zh2SG ), + 'zh-tw' => new ReplacementArray( $zh2TW ), 'zh' => new ReplacementArray ); } function postLoadTables() { - $this->mTables['zh-cn']->merge( $this->mTables['zh-hans'] ); - $this->mTables['zh-hk']->merge( $this->mTables['zh-hant'] ); - $this->mTables['zh-mo']->merge( $this->mTables['zh-hant'] ); - $this->mTables['zh-my']->merge( $this->mTables['zh-hans'] ); - $this->mTables['zh-sg']->merge( $this->mTables['zh-hans'] ); - $this->mTables['zh-tw']->merge( $this->mTables['zh-hant'] ); + $this->mTables['zh-cn']->setArray( $this->mTables['zh-cn']->getArray() + $this->mTables['zh-hans']->getArray() ); + $this->mTables['zh-hk']->setArray( $this->mTables['zh-hk']->getArray() + $this->mTables['zh-hant']->getArray() ); + $this->mTables['zh-mo']->setArray( $this->mTables['zh-mo']->getArray() + $this->mTables['zh-hant']->getArray() ); + $this->mTables['zh-my']->setArray( $this->mTables['zh-my']->getArray() + $this->mTables['zh-hans']->getArray() ); + $this->mTables['zh-sg']->setArray( $this->mTables['zh-sg']->getArray() + $this->mTables['zh-hans']->getArray() ); + $this->mTables['zh-tw']->setArray( $this->mTables['zh-tw']->getArray() + $this->mTables['zh-hant']->getArray() ); } /** -- To view, visit https://gerrit.wikimedia.org/r/158366 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie9d08b85d4911618946fa7efd23eb898412449e5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Send 404 in various special pages when there're no results - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/148965 Change subject: Send 404 in various special pages when there're no results .. Send 404 in various special pages when there're no results Bug: 67182 Change-Id: I442645d8b98731282768e6cc19a8f426b1d0b519 --- M includes/specialpage/ChangesListSpecialPage.php M includes/specials/SpecialContributions.php M includes/specials/SpecialRecentchanges.php M includes/specials/SpecialWhatlinkshere.php 4 files changed, 8 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/65/148965/1 diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 008200d..80c612f 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -54,6 +54,7 @@ if ( $rows === false ) { if ( !$this->including() ) { $this->doHeader( $opts ); + $this->getOutput()->setStatusCode( 404 ); } return; diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 251ac51..a884a39 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -255,6 +255,9 @@ wfEscapeWikiText( $userObj->getName() ), ) ); + if ( !$this->including() ) { + $this->getOutput()->setStatusCode( 404 ); + } } $user = htmlspecialchars( $userObj->getName() ); } else { diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index aa8ed82..c3d9d3e 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -344,6 +344,9 @@ $this->msg( 'recentchanges-noresult' )->parse() . '' ); + if ( !$this->including() ) { + $this->getOutput()->setStatusCode( 404 ); + } } else { $this->getOutput()->addHTML( $rclistOutput ); } diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index 694bc83..a3f71d1 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -208,6 +208,7 @@ } $errMsg = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere'; $out->addWikiMsg( $errMsg, $this->target->getPrefixedText() ); + $out->setStatusCode( 404 ); } } -- To view, visit https://gerrit.wikimedia.org/r/148965 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I442645d8b98731282768e6cc19a8f426b1d0b519 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add new variable article_first_contributor - change (mediawiki...AbuseFilter)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/145014 Change subject: Add new variable article_first_contributor .. Add new variable article_first_contributor Change-Id: I725b7150de52bdc6518f73a6302f850e8d596824 --- M AbuseFilter.class.php M AbuseFilterVariableHolder.php M i18n/en.json M i18n/qqq.json 4 files changed, 31 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter refs/changes/14/145014/1 diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php index a742959..3c3cc63 100644 --- a/AbuseFilter.class.php +++ b/AbuseFilter.class.php @@ -123,6 +123,7 @@ 'article_restrictions_create' => 'restrictions-create', 'article_restrictions_upload' => 'restrictions-upload', 'article_recent_contributors' => 'recent-contributors', + 'article_first_contributor' => 'first-contributor', # 'old_text' => 'old-text-stripped', # Disabled, performance # 'old_html' => 'old-html', # Disabled, performance 'old_links' => 'old-links', @@ -342,6 +343,12 @@ 'namespace' => $title->getNamespace() ) ); + $vars->setLazyLoadVar( "{$prefix}_first_contributor", 'load-first-author', + array( + 'title' => $title->getText(), + 'namespace' => $title->getNamespace() + ) ); + wfRunHooks( 'AbuseFilter-generateTitleVars', array( $vars, $title, $prefix ) ); return $vars; diff --git a/AbuseFilterVariableHolder.php b/AbuseFilterVariableHolder.php index fcc2c00..8f09b3c 100644 --- a/AbuseFilterVariableHolder.php +++ b/AbuseFilterVariableHolder.php @@ -504,6 +504,27 @@ } $result = $users; break; + case 'load-first-author': + $title = Title::makeTitle( $parameters['namespace'], $parameters['title'] ); + $result = ''; + + if ( !$title->exists() ) { + break; + } + + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->selectField( + 'revision', + 'rev_user_text', + array( 'rev_page' => $title->getArticleID() ), + __METHOD__, + array( 'ORDER BY' => 'rev_timestamp' ) + ); + + if ( $res !== false ) { + $result = $res; + } + break; case 'get-page-restrictions': $action = $parameters['action']; $title = Title::makeTitle( $parameters['namespace'], $parameters['title'] ); diff --git a/i18n/en.json b/i18n/en.json index ee959f1..cd6a187 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -264,6 +264,7 @@ "abusefilter-edit-builder-vars-user-blocked": "Whether user is blocked", "abusefilter-edit-builder-vars-user-emailconfirm": "Time email address was confirmed", "abusefilter-edit-builder-vars-recent-contributors": "Last ten users to contribute to the page", +"abusefilter-edit-builder-vars-first-contributor": "First user to contribute to the page", "abusefilter-edit-builder-vars-all-links": "All external links in the new text", "abusefilter-edit-builder-vars-added-links": "All external links added in the edit", "abusefilter-edit-builder-vars-removed-links": "All external links removed in the edit", @@ -393,4 +394,4 @@ "abusefilter-import-intro": "You can use this interface to import filters from other wikis.\nOn the source wiki, click \"{{int:abusefilter-edit-export}}\" under \"{{int:abusefilter-edit-tools}}\" on the editing interface.\nCopy from the textbox that appears, and paste it into this textbox, then click \"{{int:abusefilter-import-submit}}\".", "abusefilter-import-submit": "Import data", "abusefilter-group-default": "Default" -} \ No newline at end of file +} diff --git a/i18n/qqq.json b/i18n/qqq.json index fb92995..63ed93c 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -284,6 +284,7 @@ "abusefilter-edit-builder-vars-user-groups": "See also:\n* {{msg-mw|Abusefilter-edit-builder-vars-global-user-groups}}", "abusefilter-edit-builder-vars-user-rights": "Par
[MediaWiki-commits] [Gerrit] Remove $dbr from ChangeTags::addTags() - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/137847 Change subject: Remove $dbr from ChangeTags::addTags() .. Remove $dbr from ChangeTags::addTags() $dbr (DB_SLAVE) is completely unused now. Change-Id: I02bbde8366480b841d8028403e9a0efe88fa46fd --- M includes/ChangeTags.php 1 file changed, 5 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/47/137847/1 diff --git a/includes/ChangeTags.php b/includes/ChangeTags.php index 7e19164..28db8a1 100644 --- a/includes/ChangeTags.php +++ b/includes/ChangeTags.php @@ -101,21 +101,20 @@ 'specified when adding a tag to a change!' ); } - $dbr = wfGetDB( DB_SLAVE ); + $dbw = wfGetDB( DB_MASTER ); // Might as well look for rcids and so on. if ( !$rc_id ) { // Info might be out of date, somewhat fractionally, on slave. - $dbr = wfGetDB( DB_MASTER ); if ( $log_id ) { - $rc_id = $dbr->selectField( + $rc_id = $dbw->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ ); } elseif ( $rev_id ) { - $rc_id = $dbr->selectField( + $rc_id = $dbw->selectField( 'recentchanges', 'rc_id', array( 'rc_this_oldid' => $rev_id ), @@ -124,14 +123,13 @@ } } elseif ( !$log_id && !$rev_id ) { // Info might be out of date, somewhat fractionally, on slave. - $dbr = wfGetDB( DB_MASTER ); - $log_id = $dbr->selectField( + $log_id = $dbw->selectField( 'recentchanges', 'rc_logid', array( 'rc_id' => $rc_id ), __METHOD__ ); - $rev_id = $dbr->selectField( + $rev_id = $dbw->selectField( 'recentchanges', 'rc_this_oldid', array( 'rc_id' => $rc_id ), @@ -146,7 +144,6 @@ ); ## Update the summary row. - $dbw = wfGetDB( DB_MASTER ); // $prevTags can be out of date on slaves, especially when addTags is called consecutively, // causing loss of tags added recently in tag_summary table. $prevTags = $dbw->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ ); -- To view, visit https://gerrit.wikimedia.org/r/137847 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I02bbde8366480b841d8028403e9a0efe88fa46fd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use master to load previous tags in ChangeTags::addTags() - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/137563 Change subject: Use master to load previous tags in ChangeTags::addTags() .. Use master to load previous tags in ChangeTags::addTags() Change-Id: Ie47649ef45f9eebdfeae73a0698ea5d21b150b56 --- M includes/ChangeTags.php 1 file changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/63/137563/1 diff --git a/includes/ChangeTags.php b/includes/ChangeTags.php index d3dd51a..9cc5a0c 100644 --- a/includes/ChangeTags.php +++ b/includes/ChangeTags.php @@ -146,7 +146,10 @@ ); ## Update the summary row. - $prevTags = $dbr->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ ); + // $prevTags can be out of date on slaves, especially when addTags is called consecutively, + // causing loss of tags added recently in tag_summary table. + $dbw = wfGetDB( DB_MASTER ); + $prevTags = $dbw->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ ); $prevTags = $prevTags ? $prevTags : ''; $prevTags = array_filter( explode( ',', $prevTags ) ); $newTags = array_unique( array_merge( $prevTags, $tags ) ); @@ -158,7 +161,6 @@ return false; } - $dbw = wfGetDB( DB_MASTER ); $dbw->replace( 'tag_summary', array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ), -- To view, visit https://gerrit.wikimedia.org/r/137563 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie47649ef45f9eebdfeae73a0698ea5d21b150b56 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Set unifont-5.1.20080907.ttf for timeline on ZH projects - change (operations/mediawiki-config)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/133228 Change subject: Set unifont-5.1.20080907.ttf for timeline on ZH projects .. Set unifont-5.1.20080907.ttf for timeline on ZH projects The original one, wqy-zenhei.ttc, doesn't actually exist in GDFONTPATH, and EasyTimeline is not smart enough to make use of other system fonts. Bug: 20825 Change-Id: I9dd358872265ff753226b9c8f3b7cd374e3bf609 --- M wmf-config/CommonSettings.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config refs/changes/28/133228/1 diff --git a/wmf-config/CommonSettings.php b/wmf-config/CommonSettings.php index 8b1a4ea..659c0db 100644 --- a/wmf-config/CommonSettings.php +++ b/wmf-config/CommonSettings.php @@ -533,7 +533,7 @@ // Generate("FreeSansWMF.ttf", "", 4 ); $wgTimelineSettings->fontFile = 'FreeSansWMF.ttf'; } elseif ( $lang == 'zh' ) { - $wgTimelineSettings->fontFile = 'wqy-zenhei.ttc'; + $wgTimelineSettings->fontFile = 'unifont-5.1.20080907.ttf'; } $wgTimelineSettings->fileBackend = 'local-multiwrite'; -- To view, visit https://gerrit.wikimedia.org/r/133228 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9dd358872265ff753226b9c8f3b7cd374e3bf609 Gerrit-PatchSet: 1 Gerrit-Project: operations/mediawiki-config Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Correct README - change (mediawiki...FastStringSearch)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/131835 Change subject: Correct README .. Correct README Change-Id: I8a59f9e82fc6dfec6b35a5694a6ed84ed548cc44 --- M README 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/php/FastStringSearch refs/changes/35/131835/1 diff --git a/README b/README index a29c1a4..fb05ef8 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ This is a PHP extension for fast string search and replace. It is used by -LanguageConverter.php. It supports multiple search terms. We use it as a +StringUtils.php. It supports multiple search terms. We use it as a replacement for PHP's strtr, which is extremely slow in certain cases. Chinese script conversion is one of those cases. This extension uses a Commentz-Walter style algorithm for multiple search terms, or a Boyer-Moore -- To view, visit https://gerrit.wikimedia.org/r/131835 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8a59f9e82fc6dfec6b35a5694a6ed84ed548cc44 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/php/FastStringSearch Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] LanguageConverter fix of empty and numeric strings - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/131717 Change subject: LanguageConverter fix of empty and numeric strings .. LanguageConverter fix of empty and numeric strings Bug: 49072 Bug: 46634 Bug: 51551 Change-Id: I2c88f1cf7c0014bebf5c798916b660b334a0b78b --- M languages/LanguageConverter.php M tests/parser/parserTests.txt 2 files changed, 44 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/17/131717/1 diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 57e73da..4ab4e3f 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -1004,7 +1004,7 @@ if ( $recursive ) { foreach ( $sublinks as $link ) { $s = $this->parseCachedTable( $code, $link, $recursive ); - $ret = array_merge( $ret, $s ); + $ret = $s + $ret; } } @@ -1260,18 +1260,20 @@ $to = trim( $v[1] ); $v = trim( $v[0] ); $u = explode( '=>', $v, 2 ); - // if $to is empty, strtr() could return a wrong result - if ( count( $u ) == 1 && $to && in_array( $v, $variants ) ) { + // if $to is empty (which is also used as $from in bidtable), + // strtr() could return a wrong result. + if ( count( $u ) == 1 && $to !== '' && in_array( $v, $variants ) ) { $bidtable[$v] = $to; } elseif ( count( $u ) == 2 ) { $from = trim( $u[0] ); $v = trim( $u[1] ); + // if $from is empty, strtr() could return a wrong result. if ( array_key_exists( $v, $unidtable ) && !is_array( $unidtable[$v] ) - && $to + && $from !== '' && in_array( $v, $variants ) ) { $unidtable[$v] = array( $from => $to ); - } elseif ( $to && in_array( $v, $variants ) ) { + } elseif ( $from !== '' && in_array( $v, $variants ) ) { $unidtable[$v][$from] = $to; } } @@ -1325,17 +1327,17 @@ // display current variant in bidirectional array $disp = $this->getTextInBidtable( $variant ); // or display current variant in fallbacks - if ( !$disp ) { + if ( $disp === false ) { $disp = $this->getTextInBidtable( $this->mConverter->getVariantFallbacks( $variant ) ); } // or display current variant in unidirectional array - if ( !$disp && array_key_exists( $variant, $unidtable ) ) { + if ( $disp === false && array_key_exists( $variant, $unidtable ) ) { $disp = array_values( $unidtable[$variant] ); $disp = $disp[0]; } // or display frist text under disable manual convert - if ( !$disp && $this->mConverter->mManualLevel[$variant] == 'disable' ) { + if ( $disp === false && $this->mConverter->mManualLevel[$variant] == 'disable' ) { if ( count( $bidtable ) > 0 ) { $disp = array_values( $bidtable ); $disp = $disp[0]; @@ -1430,7 +1432,7 @@ && isset( $unidtable[$v] ) ) { if ( isset( $this->mConvTable[$v] ) ) { - $this->mConvTable[$v] = array_merge( $this->mConvTable[$v], $unidtable[$v] ); + $this->mConvTable[$v] = $unidtable[$v] + $this->mConvTable[$v]; } else { $this->mConvTable[$v] = $unidtable[$v]; } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index e8e71b8..4dc16b0 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -15653,6 +15653,39 @@ !! end !! test +Strings evaluating false shouldn't be ignored by Language converter (bug 49072) +!! options +language
[MediaWiki-commits] [Gerrit] Add special page alias for the example special page - change (mediawiki...examples)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/129426 Change subject: Add special page alias for the example special page .. Add special page alias for the example special page Change-Id: I9b6c6e37fdd5f2fb3fceec4aa99fe51a7f4eb506 --- M BoilerPlate/BoilerPlate.i18n.alias.php 1 file changed, 6 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/examples refs/changes/26/129426/1 diff --git a/BoilerPlate/BoilerPlate.i18n.alias.php b/BoilerPlate/BoilerPlate.i18n.alias.php index e187c4a..9a0511a 100644 --- a/BoilerPlate/BoilerPlate.i18n.alias.php +++ b/BoilerPlate/BoilerPlate.i18n.alias.php @@ -6,4 +6,9 @@ * @ingroup Extensions */ -$specialPageAliases = array(); \ No newline at end of file +$specialPageAliases = array(); + +/** English (English) */ +$specialPageAliases['en'] = array( + 'HelloWorld' => array( 'HelloWorld' ), +); -- To view, visit https://gerrit.wikimedia.org/r/129426 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9b6c6e37fdd5f2fb3fceec4aa99fe51a7f4eb506 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/examples Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add release note for removal of preference "noconvertlink" - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/118066 Change subject: Add release note for removal of preference "noconvertlink" .. Add release note for removal of preference "noconvertlink" Follow up 333bf3ae5b412fae1e4f57a62a220c941ef50536. Change-Id: I7a3e391f56d2e2839b3210d79a9f5b630f0f6fed --- M RELEASE-NOTES-1.23 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/66/118066/1 diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index 344c967..fb12acd 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -278,6 +278,7 @@ table.mw-prefixindex-list-table to avoid duplicate ids when the special page is transcluded. * (bug 62198) window.$j has been deprecated. +* Preference "Disable link title conversion" was removed. Removed classes * FakeMemCachedClient (deprecated in 1.18) -- To view, visit https://gerrit.wikimedia.org/r/118066 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7a3e391f56d2e2839b3210d79a9f5b630f0f6fed Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Create plural rules for variants of zh (Chinese) - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/116278 Change subject: Create plural rules for variants of zh (Chinese) .. Create plural rules for variants of zh (Chinese) Change-Id: I50e28f601944955ac85e0a847941d7b4824e51e3 --- M languages/data/plurals-mediawiki.xml 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/78/116278/1 diff --git a/languages/data/plurals-mediawiki.xml b/languages/data/plurals-mediawiki.xml index aafc393..6f711ca 100644 --- a/languages/data/plurals-mediawiki.xml +++ b/languages/data/plurals-mediawiki.xml @@ -41,5 +41,9 @@ v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.2~0.4, 1.2~1.4, 2.2~2.4, 3.2~3.4, 4.2~4.4, 5.2, 10.2, 100.2, 1000.2, … @integer 0, 5~19, 100, 1000, 1, 10, 100, … @decimal 0.0, 0.5~1.0, 1.5~2.0, 2.5~2.7, 10.0, 100.0, 1000.0, 1.0, 10.0, 100.0, … + + +@integer 0~15, 100, 1000, 1, 10, 100, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 1.0, 10.0, 100.0, … + -- To view, visit https://gerrit.wikimedia.org/r/116278 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I50e28f601944955ac85e0a847941d7b4824e51e3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove user preference "noconvertlink" - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/111968 Change subject: Remove user preference "noconvertlink" .. Remove user preference "noconvertlink" This toggle was introduced in 8d06ad6e, but the most useful feature there (disabling conversion on a per-user basis) has been dropped due to cache fragmentation. The only remaining part is not quite useful and can be covered by the URL parameter &linkconvert=no. Change-Id: I12f2cdc9b0d44d6e47487b14fa8ef010de5c94a7 --- M includes/DefaultSettings.php M includes/Preferences.php M languages/LanguageConverter.php M languages/messages/MessagesEn.php 4 files changed, 1 insertion(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/68/111968/1 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 9264947..38cf735 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3994,7 +3994,6 @@ 'minordefault' => 0, 'newpageshidepatrolled' => 0, 'nickname' => '', - 'noconvertlink' => 0, 'norollbackdiff' => 0, 'numberheadings' => 0, 'previewonfirst' => 0, diff --git a/includes/Preferences.php b/includes/Preferences.php index 04e9114..9ced6bc 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -374,14 +374,6 @@ 'section' => 'personal/i18n', 'help-message' => 'prefs-help-variant', ); - - if ( !$wgDisableTitleConversion ) { - $defaultPreferences['noconvertlink'] = array( - 'type' => 'toggle', - 'section' => 'personal/i18n', - 'label-message' => 'tog-noconvertlink', - ); - } } else { $defaultPreferences["variant-$langCode"] = array( 'type' => 'api', diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index bb5b49f..7231477 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -768,8 +768,7 @@ ( $isredir == 'no' || $action == 'edit' || $action == 'submit' - || $linkconvert == 'no' - || $wgUser->getOption( 'noconvertlink' ) == 1 ) ) ) { + || $linkconvert == 'no' ) ) ) { return; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 300792a..b9d368c 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -694,7 +694,6 @@ 'tog-ccmeonemails'=> 'Send me copies of emails I send to other users', 'tog-diffonly'=> 'Do not show page content below diffs', 'tog-showhiddencats' => 'Show hidden categories', -'tog-noconvertlink' => 'Disable link title conversion', # only translate this message to other languages if you have to change it 'tog-norollbackdiff' => 'Omit diff after performing a rollback', 'tog-useeditwarning' => 'Warn me when I leave an edit page with unsaved changes', 'tog-prefershttps'=> 'Always use a secure connection when logged in', -- To view, visit https://gerrit.wikimedia.org/r/111968 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I12f2cdc9b0d44d6e47487b14fa8ef010de5c94a7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (bug 57401) Fix padding values of div#content - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/111454 Change subject: (bug 57401) Fix padding values of div#content .. (bug 57401) Fix padding values of div#content Bug: 57401 Change-Id: I9633a6f5f8b77fe7ac98eba2afd3488219946bdd --- M skins/vector/screen-hd.less M skins/vector/variables.less 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/54/111454/1 diff --git a/skins/vector/screen-hd.less b/skins/vector/screen-hd.less index 2683a21..5a1fc05 100644 --- a/skins/vector/screen-hd.less +++ b/skins/vector/screen-hd.less @@ -2,7 +2,7 @@ div#content { margin-left: 11em; - padding: 1.5em 1.5em 1.5em 1.75em; + padding: 1.25em 1.5em 1.5em 1.5em; } #p-logo { left: @menu-main-logo-left; diff --git a/skins/vector/variables.less b/skins/vector/variables.less index c2d0b92..542ffe7 100644 --- a/skins/vector/variables.less +++ b/skins/vector/variables.less @@ -9,7 +9,7 @@ @content-font-color: black; @content-font-size: 0.8em; @content-line-height: 1.5em; -@content-padding: 1.25em 1.5em 1.5em 1.5em; +@content-padding: 1em; @content-heading-font-size: 1.6em; @content-heading-font-family: sans-serif; @body-background-color: #fff; -- To view, visit https://gerrit.wikimedia.org/r/111454 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9633a6f5f8b77fe7ac98eba2afd3488219946bdd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix various comments from 84a2f570. - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/109459 Change subject: Fix various comments from 84a2f570. .. Fix various comments from 84a2f570. Change-Id: I03f7778bc93a255475aa132a09c6da15decd1549 --- M includes/Collation.php M includes/utils/ArrayUtils.php 2 files changed, 14 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/59/109459/1 diff --git a/includes/Collation.php b/includes/Collation.php index b51256b..d2a5797 100644 --- a/includes/Collation.php +++ b/includes/Collation.php @@ -514,7 +514,7 @@ * Do a binary search, and return the index of the largest item that sorts * less than or equal to the target value. * -* @deprecated in 1.22; use ArrayUtils::findLowerBound() instead +* @deprecated in 1.23; use ArrayUtils::findLowerBound() instead * * @param array $valueCallback A function to call to get the value with * a given array index. @@ -528,7 +528,7 @@ * sorts before all items. */ function findLowerBound( $valueCallback, $valueCount, $comparisonCallback, $target ) { - wfDeprecated( __METHOD__, '1.22' ); + wfDeprecated( __METHOD__, '1.23' ); return ArrayUtils::findLowerBound( $valueCallback, $valueCount, $comparisonCallback, $target ); } diff --git a/includes/utils/ArrayUtils.php b/includes/utils/ArrayUtils.php index 802cdbc..037663c 100644 --- a/includes/utils/ArrayUtils.php +++ b/includes/utils/ArrayUtils.php @@ -22,6 +22,8 @@ /** * A collection of static methods to play with arrays. + * + * @since 1.21 */ class ArrayUtils { /** @@ -94,13 +96,15 @@ * Do a binary search, and return the index of the largest item that sorts * less than or equal to the target value. * +* @since 1.23 +* * @param array $valueCallback A function to call to get the value with * a given array index. -* @param $valueCount int The number of items accessible via $valueCallback, +* @param int $valueCount The number of items accessible via $valueCallback, * indexed from 0 to $valueCount - 1 -* @param $comparisonCallback array A callback to compare two values, returning +* @param array $comparisonCallback A callback to compare two values, returning * -1, 0 or 1 in the style of strcmp(). -* @param $target string The target value to find. +* @param string $target The target value to find. * * @return int|bool The item index of the lower bound, or false if the target value * sorts before all items. @@ -142,9 +146,11 @@ * * Note: empty arrays are removed. * -* @param $array1 array The array to compare from -* @param $array2 array An array to compare against -* @param ... array More arrays to compare against +* @since 1.23 +* +* @param array $array1 The array to compare from +* @param array $array2 An array to compare against +* @param array ... More arrays to compare against * @return array An array containing all the values from array1 * that are not present in any of the other arrays. */ -- To view, visit https://gerrit.wikimedia.org/r/109459 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I03f7778bc93a255475aa132a09c6da15decd1549 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Updated location of zhtable in comment - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/103655 Change subject: Updated location of zhtable in comment .. Updated location of zhtable in comment Follow up I239483e6cdf7d412be01ae8bd45978481c5dd518. Change-Id: Ia909b36ed8b996057ba4e7966cac4d29ee3836f4 --- M maintenance/language/zhtable/Makefile.py 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/55/103655/1 diff --git a/maintenance/language/zhtable/Makefile.py b/maintenance/language/zhtable/Makefile.py index 7e19794..ac09246 100755 --- a/maintenance/language/zhtable/Makefile.py +++ b/maintenance/language/zhtable/Makefile.py @@ -352,7 +352,7 @@ /** * Simplified / Traditional Chinese conversion tables * - * Automatically generated using code and data in includes/zhtable/ + * Automatically generated using code and data in maintenance/language/zhtable/ * Do not modify directly! * * @file -- To view, visit https://gerrit.wikimedia.org/r/103655 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia909b36ed8b996057ba4e7966cac4d29ee3836f4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Do title conversion on &action=edit if &redlink=1 exists - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/99335 Change subject: Do title conversion on &action=edit if &redlink=1 exists .. Do title conversion on &action=edit if &redlink=1 exists Bug: 33231 Change-Id: I33c3c9df4ff2215710bacb696b64bb4291dda24e --- M languages/LanguageConverter.php 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/35/99335/1 diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index cdaab2c..9c64801 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -769,6 +769,9 @@ $wgUser; $isredir = $wgRequest->getText( 'redirect', 'yes' ); $action = $wgRequest->getText( 'action' ); + if ( $action == 'edit' && $wgRequest->getBool( 'redlink' ) ) { + $action = 'view'; + } $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' ); $disableLinkConversion = $wgDisableLangConversion || $wgDisableTitleConversion; -- To view, visit https://gerrit.wikimedia.org/r/99335 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I33c3c9df4ff2215710bacb696b64bb4291dda24e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add fallback languages for cdo, hak and nan - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/98496 Change subject: Add fallback languages for cdo, hak and nan .. Add fallback languages for cdo, hak and nan Change-Id: I2d22bfa82e94c86f19758e5c6bb2706e274d44a0 --- M languages/messages/MessagesCdo.php M languages/messages/MessagesHak.php M languages/messages/MessagesNan.php 3 files changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/96/98496/1 diff --git a/languages/messages/MessagesCdo.php b/languages/messages/MessagesCdo.php index f91ca5d..bd27279 100644 --- a/languages/messages/MessagesCdo.php +++ b/languages/messages/MessagesCdo.php @@ -11,6 +11,8 @@ * @author Yejianfei */ +$fallback = 'nan, zh-hant'; + $namespaceNames = array( NS_MEDIA=> '媒體', NS_SPECIAL => '特殊', diff --git a/languages/messages/MessagesHak.php b/languages/messages/MessagesHak.php index a2411b4..34097c7 100644 --- a/languages/messages/MessagesHak.php +++ b/languages/messages/MessagesHak.php @@ -16,6 +16,8 @@ * @author Xiaomingyan */ +$fallback = 'zh-hant'; + $messages = array( # User preference toggles 'tog-underline' => '鏈接加底線:', diff --git a/languages/messages/MessagesNan.php b/languages/messages/MessagesNan.php index 432caf8..bbb922c 100644 --- a/languages/messages/MessagesNan.php +++ b/languages/messages/MessagesNan.php @@ -12,6 +12,8 @@ * @author Kaihsu */ +$fallback = 'cdo, zh-hant'; + $datePreferences = array( 'default', 'ISO 8601', -- To view, visit https://gerrit.wikimedia.org/r/98496 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2d22bfa82e94c86f19758e5c6bb2706e274d44a0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] DO NOT MERGE - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/91943 Change subject: DO NOT MERGE .. DO NOT MERGE Change-Id: Iaceecb26062266ccd9a1c63c126ff0d5471f7d97 --- M includes/EditPage.php 1 file changed, 0 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/43/91943/1 diff --git a/includes/EditPage.php b/includes/EditPage.php index d7b2b5e..23bc7c1 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -912,10 +912,6 @@ $undo = $wgRequest->getInt( 'undo' ); if ( $undo > 0 && $undoafter > 0 ) { - if ( $undo < $undoafter ) { - # If they got undoafter and undo round the wrong way, switch them - list( $undo, $undoafter ) = array( $undoafter, $undo ); - } $undorev = Revision::newFromId( $undo ); $oldrev = Revision::newFromId( $undoafter ); @@ -924,8 +920,6 @@ # the revisions exist and they were not deleted. # Otherwise, $content will be left as-is. if ( !is_null( $undorev ) && !is_null( $oldrev ) && - $undorev->getPage() == $oldrev->getPage() && - $undorev->getPage() == $this->mTitle->getArticleID() && !$undorev->isDeleted( Revision::DELETED_TEXT ) && !$oldrev->isDeleted( Revision::DELETED_TEXT ) ) { -- To view, visit https://gerrit.wikimedia.org/r/91943 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaceecb26062266ccd9a1c63c126ff0d5471f7d97 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove one hard-coded constant - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/90643 Change subject: Remove one hard-coded constant .. Remove one hard-coded constant Change-Id: Iea8f8fb9c9ec2f2bf41879edaead36deb460e0ff --- M lib/includes/ClaimGuidGenerator.php 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/43/90643/1 diff --git a/lib/includes/ClaimGuidGenerator.php b/lib/includes/ClaimGuidGenerator.php index 4ef3ad3..1231309 100644 --- a/lib/includes/ClaimGuidGenerator.php +++ b/lib/includes/ClaimGuidGenerator.php @@ -2,6 +2,7 @@ namespace Wikibase\Lib; +use Wikibase\DataModel\Claim\ClaimGuid; use Wikibase\DataModel\Entity\EntityId; /** @@ -42,7 +43,7 @@ * @return string */ public function newGuid() { - return $this->entityId->getSerialization() . '$' . $this->baseGenerator->newGuid(); + return $this->entityId->getSerialization() . ClaimGuid::SEPARATOR . $this->baseGenerator->newGuid(); } } -- To view, visit https://gerrit.wikimedia.org/r/90643 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iea8f8fb9c9ec2f2bf41879edaead36deb460e0ff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix {{#property: }} calls for missing property on wikis with... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/90636 Change subject: Fix {{#property: }} calls for missing property on wikis with LanguageConverter .. Fix {{#property: }} calls for missing property on wikis with LanguageConverter Change-Id: Iada5fbd8736753622af734e3494d0b3fa0109f68 --- M client/includes/parserhooks/PropertyParserFunction.php M client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php 2 files changed, 14 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/36/90636/1 diff --git a/client/includes/parserhooks/PropertyParserFunction.php b/client/includes/parserhooks/PropertyParserFunction.php index bc9a53d..a143ad9 100644 --- a/client/includes/parserhooks/PropertyParserFunction.php +++ b/client/includes/parserhooks/PropertyParserFunction.php @@ -80,11 +80,13 @@ */ public function processRenderedArray( $textArray ) { // We got arrays, so they must have already checked that variants are being used. - $text = '-{'; + $text = ''; foreach ( $textArray as $variantCode => $variantText ) { $text .= "$variantCode:$variantText;"; } - $text .= '}-'; + if ( $text !== '' ) { + $text = '-{' . $text . '}-'; + } return $text; } @@ -161,7 +163,13 @@ foreach ( $variants as $variantCode ) { $variantLanguage = \Language::factory( $variantCode ); - $textArray[$variantCode] = $this->renderInLanguage( $propertyLabel, $variantLanguage ); + $variantText = $this->renderInLanguage( $propertyLabel, $variantLanguage ); + // LanguageConverter doesn't handle empty strings correctly, and it's more difficult + // to fix the issue there, as it's using empty string as a special value. + // Also keeping the ability to check a missing property with {{#if: }} is another reason. + if ( $variantText !== '' ) { + $textArray[$variantCode] = $variantText; + } } return $textArray; diff --git a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php index 6b49bbd..655e203 100644 --- a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php +++ b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php @@ -95,6 +95,9 @@ 'zh-cn' => 'foar', 'zh-tw' => 'FO AR', ), '-{zh-cn:fo ar;zh-tw:FO AR;}-' ), + // Don't create "-{}-" for empty input, + // to keep the ability to check a missing property with {{#if: }}. + array( \Parser::OT_HTML, array(), '' ), ); } -- To view, visit https://gerrit.wikimedia.org/r/90636 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iada5fbd8736753622af734e3494d0b3fa0109f68 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Initial version of the extension - change (mediawiki...PageLanguage)
Liangent has submitted this change and it was merged. Change subject: Initial version of the extension .. Initial version of the extension Bug: 49588 Change-Id: Ib754e512b6923a043d93c565ea3af9c936409ca3 --- A PageLanguage.body.php A PageLanguage.i18n.php A PageLanguage.magic.php A PageLanguage.php 4 files changed, 135 insertions(+), 0 deletions(-) Approvals: Liangent: Verified; Looks good to me, approved diff --git a/PageLanguage.body.php b/PageLanguage.body.php new file mode 100644 index 000..f3f4583 --- /dev/null +++ b/PageLanguage.body.php @@ -0,0 +1,69 @@ +getPrefixedDBKey()] ) ) { + $pageLang = self::$cache[$title->getPrefixedDBKey()]; + } elseif ( $title->getArticleID() > 0 ) { + $dbr = wfGetDB( DB_SLAVE ); + $langCode = $dbr->selectField( + 'page_props', 'pp_value', array( + 'pp_page' => $title->getArticleID(), + 'pp_propname' => 'pagelanguage', + ), __METHOD__ + ); + + if ( $langCode !== false && Language::isValidCode( $langCode ) ) { + $pageLang = Language::factory( $langCode ); + } + } + + return true; + } + + public static function onParserFirstCallInit( Parser $parser ) { + $parser->setFunctionHook( 'pagelanguage', 'PageLanguage::funcPageLanguage', SFH_NO_HASH ); + + return true; + } + + public static function funcPageLanguage( Parser $parser, $langCode, $uarg = '' ) { + static $magicWords = null; + if ( is_null( $magicWords ) ) { + $magicWords = new MagicWordArray( array( 'pagelanguage_noerror', 'pagelanguage_noreplace' ) ); + } + $arg = $magicWords->matchStartToEnd( $uarg ); + + $langCode = trim( $langCode ); + if ( strlen( $langCode ) === 0 ) { + return ''; + } + + if ( Language::isValidCode( $langCode ) ) { + $lang = Language::factory( $langCode ); + } else { + return '' . + wfMessage( 'pagelanguage-invalid' )->inContentLanguage() + ->params( wfEscapeWikiText( $langCode ) )->text() . + ''; + } + + $old = $parser->getOutput()->getProperty( 'pagelanguage' ); + if ( $old === false || $arg !== 'pagelanguage_noreplace' ) { + $parser->getOutput()->setProperty( 'pagelanguage', $lang->getCode() ); + self::$cache[$parser->getTitle()->getPrefixedDBKey()] = $lang; + } + + if ( $old === false || $old === $lang->getCode() || $arg ) { + return ''; + } else { + return '' . + wfMessage( 'pagelanguage-duplicate' )->inContentLanguage()->params( + wfEscapeWikiText( $old ), wfEscapeWikiText( $lang->getCode() ) )->text() . + ''; + } + } +} diff --git a/PageLanguage.i18n.php b/PageLanguage.i18n.php new file mode 100644 index 000..615e1bc --- /dev/null +++ b/PageLanguage.i18n.php @@ -0,0 +1,27 @@ + "Define page language per page", + 'pagelanguage-invalid' => "'''Warning:''' Ignoring invalid language code \"$1\" for page language.", + 'pagelanguage-duplicate' => "'''Warning:''' Page language \"$2\" overrides earlier page language \"$1\".", +); + +/** Message documentation (Message documentation) */ +$messages['qqq'] = array( + 'pagelanguage-desc' => '{{desc|name=Page Language|url=http://www.mediawiki.org/wiki/Extension:PageLanguage}}', + 'pagelanguage-invalid' => 'Error message when an invalid language is used. $1 for the language code used.', + 'pagelanguage-duplicate' => 'Error message when a different language is set overriding a previous one. + +Parameters: +* $1: the language code set previously +* $2: the language code being set now', +); diff --git a/PageLanguage.magic.php b/PageLanguage.magic.php new file mode 100644 index 000..825bfc2 --- /dev/null +++ b/PageLanguage.magic.php @@ -0,0 +1,16 @@ + array( 1, 'PAGELANGUAGE' ), + 'pagelanguage_noerror' => array( 0, 'noerror' ), + 'pagelanguage_noreplace' => array( 0, 'noreplace' ), +); diff --git a/PageLanguage.php b/PageLanguage.php new file mode 100644 index 000..0b7d09c --- /dev/null +++ b/PageLanguage.php @@ -0,0 +1,23 @@ + __FILE__, + 'name' => 'Page Language', + 'author' => array( 'Liangent' ), + 'url' => 'https:/
[MediaWiki-commits] [Gerrit] Remove one $wgContLang usage. - change (mediawiki...Math)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/87519 Change subject: Remove one $wgContLang usage. .. Remove one $wgContLang usage. Change-Id: Ic988d17c2e7026a17bde9d53bcc4d10c42d22118 --- M Math.hooks.php 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math refs/changes/19/87519/1 diff --git a/Math.hooks.php b/Math.hooks.php index 3489da5..b029f38 100644 --- a/Math.hooks.php +++ b/Math.hooks.php @@ -42,7 +42,7 @@ * @return string */ static function mathTagHook( $content, $attributes, $parser ) { - global $wgContLang, $wgUseMathJax; + global $wgUseMathJax; if ( trim( $content ) === "" ) { // bug 8372 return ""; } @@ -55,7 +55,7 @@ $parser->getOutput()->addModules( array( 'ext.math.mathjax.enabler' ) ); } $renderer->writeCache(); - return $wgContLang->armourMath( $renderedMath ); + return $parser->getConverterLanguage()->armourMath( $renderedMath ); } /** -- To view, visit https://gerrit.wikimedia.org/r/87519 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic988d17c2e7026a17bde9d53bcc4d10c42d22118 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Math Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Create and move some functions for class ArrayUtils - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/87290 Change subject: Create and move some functions for class ArrayUtils .. Create and move some functions for class ArrayUtils Change-Id: Id9ca20925f49e314918810fb54b3819ba9cf9c39 --- M includes/ArrayUtils.php M includes/Collation.php A tests/phpunit/includes/ArrayUtilsTest.php 3 files changed, 427 insertions(+), 30 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/90/87290/1 diff --git a/includes/ArrayUtils.php b/includes/ArrayUtils.php index 985271f..7867b93 100644 --- a/includes/ArrayUtils.php +++ b/includes/ArrayUtils.php @@ -1,5 +1,28 @@ http://www.gnu.org/copyleft/gpl.html + * + * @file + */ +/** + * A collection of static methods to play with arrays. + */ class ArrayUtils { /** * Sort the given array in a pseudo-random order which depends only on the @@ -66,4 +89,92 @@ } return $i; } + + /** +* Do a binary search, and return the index of the largest item that sorts +* less than or equal to the target value. +* +* @param array $valueCallback A function to call to get the value with +* a given array index. +* @param $valueCount int The number of items accessible via $valueCallback, +* indexed from 0 to $valueCount - 1 +* @param $comparisonCallback array A callback to compare two values, returning +* -1, 0 or 1 in the style of strcmp(). +* @param $target string The target value to find. +* +* @return int|bool The item index of the lower bound, or false if the target value +* sorts before all items. +*/ + public static function findLowerBound( $valueCallback, $valueCount, $comparisonCallback, $target ) { + if ( $valueCount === 0 ) { + return false; + } + + $min = 0; + $max = $valueCount; + do { + $mid = $min + ( ( $max - $min ) >> 1 ); + $item = call_user_func( $valueCallback, $mid ); + $comparison = call_user_func( $comparisonCallback, $target, $item ); + if ( $comparison > 0 ) { + $min = $mid; + } elseif ( $comparison == 0 ) { + $min = $mid; + break; + } else { + $max = $mid; + } + } while ( $min < $max - 1 ); + + if ( $min == 0 ) { + $item = call_user_func( $valueCallback, $min ); + $comparison = call_user_func( $comparisonCallback, $target, $item ); + if ( $comparison < 0 ) { + // Before the first item + return false; + } + } + return $min; + } + + /** +* Do array_diff_assoc() on multi-dimensional arrays. +* +* Note: empty arrays are removed. +* +* @param $array1 array The array to compare from +* @param $array2 array An array to compare against +* @param ... array More arrays to compare against +* @return array An array containing all the values from array1 +* that are not present in any of the other arrays. +*/ + public static function arrayDiffAssocRecursive( $array1 ) { + $arrays = func_get_args(); + array_shift( $arrays ); + $ret = array(); + + foreach ( $array1 as $key => $value ) { + if ( is_array( $value ) ) { + $args = array( $value ); + foreach ( $arrays as $array ) { + if ( isset( $array[$key] ) ) { + $args[] = $array[$key]; + } + } + $valueret = call_user_func_array( __METHOD__, $args ); + if ( count( $valueret ) ) { + $ret[$key] = $valueret; + } + } else { + foreach ( $arrays as $array ) { + if ( isset( $array[$key] ) && $array[$key] === $value ) { + continue 2; + } + } + $ret[$key] = $value; + } + } + + return $ret; + } } di
[MediaWiki-commits] [Gerrit] (bug 35378) Support multiple collations at the same time - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/87288 Change subject: (bug 35378) Support multiple collations at the same time .. (bug 35378) Support multiple collations at the same time Change-Id: I84248ac208065de23127f6a5268bca316f2f4147 --- M RELEASE-NOTES-1.22 M docs/hooks.txt M includes/CategoryViewer.php M includes/Collation.php M includes/DefaultSettings.php M includes/LinksUpdate.php M includes/Preferences.php M includes/Setup.php M includes/Title.php M includes/api/ApiQueryCategoryMembers.php M includes/installer/DatabaseUpdater.php M includes/installer/MysqlUpdater.php M languages/messages/MessagesEn.php M languages/messages/MessagesQqq.php A maintenance/archives/patch-categorylinks-multiple-collations.sql M maintenance/language/messages.inc M maintenance/tables.sql 17 files changed, 198 insertions(+), 47 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/88/87288/1 diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 0e3e222..10e4a65 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -234,6 +234,7 @@ referenced in LESS '@import' statements are looked up here first. * Added meta=filerepoinfo API module for getting information about foreign image repositories, and related ForeignAPIRepo methods getInfo and getApiUrl. +* (bug 35378) Support multiple collations at the same time === Bug fixes in 1.22 === * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one diff --git a/docs/hooks.txt b/docs/hooks.txt index 2d1001b..0c3afdd 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -800,7 +800,7 @@ $unpatrolled: Whether or not we are showing unpatrolled changes. $watched: Whether or not the change is watched by the user. -'Collation::factory': Called if $wgCategoryCollation is an unknown collation. +'Collation::factory': Called if $wgCategoryCollations contains an unknown collation. $collationName: Name of the collation in question &$collationObject: Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index 55d9c1e..183552a 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -49,6 +49,11 @@ var $collation; /** +* @var Collation name +*/ + var $collationName; + + /** * @var ImageGallery */ var $gallery; @@ -77,7 +82,7 @@ * @param $query Array */ function __construct( $title, IContextSource $context, $from = array(), $until = array(), $query = array() ) { - global $wgCategoryPagingLimit; + global $wgCategoryPagingLimit, $wgCategoryCollations; $this->title = $title; $this->setContext( $context ); $this->from = $from; @@ -85,7 +90,8 @@ $this->limit = $wgCategoryPagingLimit; $this->cat = Category::newFromTitle( $title ); $this->query = $query; - $this->collation = Collation::singleton(); + list( $this->collationName, $this->collation ) = Collation::getInstanceByContext( + isset( $query['collation'] ) ? $query['collation'] : null, $title, $context ); unset( $this->query['title'] ); } @@ -295,13 +301,17 @@ foreach ( array( 'page', 'subcat', 'file' ) as $type ) { # Get the sortkeys for start/end, if applicable. Note that if # the collation in the database differs from the one - # set in $wgCategoryCollation, pagination might go totally haywire. - $extraConds = array( 'cl_type' => $type ); + # set in $wgCategoryCollations, pagination might go totally haywire. + $conds = array( + 'cl_type' => $type, + 'cl_to' => $this->title->getDBkey(), + 'cl_collation' => array( '', $this->collationName ), + ); if ( isset( $this->from[$type] ) && $this->from[$type] !== null ) { - $extraConds[] = 'cl_sortkey >= ' + $conds[] = 'cl_sortkey >= ' . $dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) ); } elseif ( isset( $this->until[$type] ) && $this->until[$type] !== null ) { - $extraConds[] = 'cl_sortkey < ' + $conds[] = 'cl_sortkey < ' . $dbr->addQuotes( $this->collation->getSortKey( $this->until[$type] ) ); $this->flip[$type] = tr
[MediaWiki-commits] [Gerrit] New collations: zh-pinyin and zh-stroke - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/87273 Change subject: New collations: zh-pinyin and zh-stroke .. New collations: zh-pinyin and zh-stroke Change-Id: I763f60f86a6b000d6f8187bff3d598d784c92d94 (cherry picked from commit bc5f9afd297ccfcc174abb5011c5c4daa02fcf4f) --- M RELEASE-NOTES-1.22 M includes/Collation.php A maintenance/language/generateCollationDataZh.php A serialized/first-letters-zh@collation=pinyin.ser A serialized/first-letters-zh@collation=stroke.ser 5 files changed, 144 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/73/87273/1 diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index d0c9d1d..37f8803 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -213,6 +213,7 @@ against allowed proxy lists. * Add deferrable update support for callback/closure * Add TitleMove hook before page renames +* New category collations: zh-pinyin and zh-stroke (require ICU above 4.8rc1). === Bug fixes in 1.22 === * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one diff --git a/includes/Collation.php b/includes/Collation.php index b0252c7..61f47ee 100644 --- a/includes/Collation.php +++ b/includes/Collation.php @@ -47,6 +47,10 @@ return new IdentityCollation; case 'uca-default': return new IcuCollation( 'root' ); + case 'zh-pinyin': + return new IcuCollation( 'zh@collation=pinyin' ); + case 'zh-stroke': + return new IcuCollation( 'zh@collation=stroke' ); default: $match = array(); if ( preg_match( '/^uca-([a-z@=-]+)$/', $collationName, $match ) ) { @@ -318,8 +322,13 @@ } // Check for CJK + // Always sort Chinese if this is using a Chinese locale. + // self::isCjk() checks Chinese only though it's called 'CJK'. $firstChar = mb_substr( $string, 0, 1, 'UTF-8' ); + $localePieces = explode( '@', $this->locale ); + $localePieces = explode( '-', $localePieces[0] ); if ( ord( $firstChar ) > 0x7f + && $localePieces[0] !== 'zh' && self::isCjk( utf8ToCodepoint( $firstChar ) ) ) { return $firstChar; @@ -385,11 +394,16 @@ // We also take this opportunity to remove primary collisions. $letterMap = array(); foreach ( $letters as $letter ) { - $key = $this->getPrimarySortKey( $letter ); + // Chinese collations don't display real first letters. + if ( !is_array( $letter ) ) { + // array( $letterSort, $letterDisplay ) + $letter = array( $letter, $letter ); + } + $key = $this->getPrimarySortKey( $letter[0] ); if ( isset( $letterMap[$key] ) ) { // Primary collision // Keep whichever one sorts first in the main collator - if ( $this->mainCollator->compare( $letter, $letterMap[$key] ) < 0 ) { + if ( $this->mainCollator->compare( $letter[0], $letterMap[$key][0] ) < 0 ) { $letterMap[$key] = $letter; } } else { @@ -464,7 +478,9 @@ // This code assumes that unsetting does not change sort order. } $data = array( - 'chars' => array_values( $letterMap ), + 'chars' => array_map( function( $letter ) { + return $letter[1]; + }, array_values( $letterMap ) ), 'keys' => array_keys( $letterMap ), 'version' => self::FIRST_LETTER_VERSION, ); diff --git a/maintenance/language/generateCollationDataZh.php b/maintenance/language/generateCollationDataZh.php new file mode 100644 index 000..1b7990a --- /dev/null +++ b/maintenance/language/generateCollationDataZh.php @@ -0,0 +1,122 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup MaintenanceLanguage + */ + +require_once( __DIR__ .'/../Maintenance.php' ); + +/** + * Generate first letter data files of Chinese for Collation.php + * + * @ingroup MaintenanceLanguage + */ +class GenerateCollationDataZh extends Maintenance { + + public function __construct() { + parent::__construct(); + } + + publ
[MediaWiki-commits] [Gerrit] New diff variables regarding pre-save transformed wikitext - change (mediawiki...AbuseFilter)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/86815 Change subject: New diff variables regarding pre-save transformed wikitext .. New diff variables regarding pre-save transformed wikitext Change-Id: Ie21041d96f1c4cf37d697fffcaffa1ff8242f886 --- M AbuseFilter.class.php M AbuseFilter.i18n.php 2 files changed, 15 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter refs/changes/15/86815/1 diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php index f41cbc7..fe5d602 100644 --- a/AbuseFilter.class.php +++ b/AbuseFilter.class.php @@ -108,6 +108,9 @@ 'removed_links' => 'removed-links', 'all_links' => 'all-links', 'new_pst' => 'new-pst', + 'edit_diff_pst' => 'diff-pst', + 'added_lines_pst' => 'addedlines-pst', + 'removed_lines_pst' => 'removedlines-pst', 'new_text' => 'new-text-stripped', 'new_html' => 'new-html', 'article_restrictions_edit' => 'restrictions-edit', @@ -1990,6 +1993,8 @@ $vars->setLazyLoadVar( 'edit_diff', 'diff', array( 'oldtext-var' => 'old_wikitext', 'newtext-var' => 'new_wikitext' ) ); + $vars->setLazyLoadVar( 'edit_diff_pst', 'diff', + array( 'oldtext-var' => 'old_wikitext', 'newtext-var' => 'new_pst' ) ); $vars->setLazyLoadVar( 'new_size', 'length', array( 'length-var' => 'new_wikitext' ) ); $vars->setLazyLoadVar( 'old_size', 'length', array( 'length-var' => 'old_wikitext' ) ); $vars->setLazyLoadVar( 'edit_delta', 'subtract', @@ -2000,6 +2005,10 @@ array( 'diff-var' => 'edit_diff', 'line-prefix' => '+' ) ); $vars->setLazyLoadVar( 'removed_lines', 'diff-split', array( 'diff-var' => 'edit_diff', 'line-prefix' => '-' ) ); + $vars->setLazyLoadVar( 'added_lines_pst', 'diff-split', + array( 'diff-var' => 'edit_diff_pst', 'line-prefix' => '+' ) ); + $vars->setLazyLoadVar( 'removed_lines_pst', 'diff-split', + array( 'diff-var' => 'edit_diff_pst', 'line-prefix' => '-' ) ); // Links $vars->setLazyLoadVar( 'added_links', 'link-diff-added', diff --git a/AbuseFilter.i18n.php b/AbuseFilter.i18n.php index 1d1fe55..30f232d 100644 --- a/AbuseFilter.i18n.php +++ b/AbuseFilter.i18n.php @@ -337,6 +337,9 @@ 'abusefilter-edit-builder-vars-old-text' => 'Old page wikitext, before the edit', 'abusefilter-edit-builder-vars-new-text' => 'New page wikitext, after the edit', 'abusefilter-edit-builder-vars-new-pst' => 'New page wikitext, pre-save transformed', + 'abusefilter-edit-builder-vars-diff-pst' => 'Unified diff of changes made by edit, pre-save transformed', + 'abusefilter-edit-builder-vars-addedlines-pst' => 'Lines added in edit, pre-save transformed', + 'abusefilter-edit-builder-vars-removedlines-pst' => 'Lines removed in edit, pre-save transformed', 'abusefilter-edit-builder-vars-new-text-stripped' => 'New page text, stripped of any markup', 'abusefilter-edit-builder-vars-new-html' => 'Parsed HTML source of the new revision', 'abusefilter-edit-builder-vars-recent-contributors' => 'Last ten users to contribute to the page', @@ -922,6 +925,9 @@ * {{msg-mw|Abusefilter-edit-builder-vars-global-user-groups}}', 'abusefilter-edit-builder-vars-user-blocked' => 'Paraphrased: Boolean value on whether the user is blocked. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.', 'abusefilter-edit-builder-vars-new-pst' => 'Paraphrased: The output wikitext after pre-save transform is applied to new_wikitext. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.', + 'abusefilter-edit-builder-vars-diff-pst' => 'Paraphrased: Edit diff of new_pst against old_wikitext. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.', + 'abusefilter-edit-builder-vars-addedlines-pst' => 'Paraphrased: Added lines in edit_diff_pst. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.', + 'abusefilter-edit-builder-vars-removedlines-pst' => 'Paraphrased: Removed lines in edit_diff_pst. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.', 'abusefilter-edit-builder-vars-restrictions-edit' => 'This variable contains the level of protection required to edit the page. ("Edit" here is not a verb, but an
[MediaWiki-commits] [Gerrit] bug 54264 - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/84741 Change subject: bug 54264 .. bug 54264 Change-Id: I1849e1ccaefaf171fcd601a76521a0e677314b0c --- M repo/tests/phpunit/includes/ItemViewTest.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/41/84741/1 diff --git a/repo/tests/phpunit/includes/ItemViewTest.php b/repo/tests/phpunit/includes/ItemViewTest.php index d65a49c..166f802 100644 --- a/repo/tests/phpunit/includes/ItemViewTest.php +++ b/repo/tests/phpunit/includes/ItemViewTest.php @@ -59,7 +59,7 @@ $dataTypeLookup = new InMemoryDataTypeLookup(); // test whether we get the right EntityView from an EntityContent - $view = ItemView::newForEntityContent( $entityContent, $valueFormatters, $dataTypeLookup, $entityLoader ); + $view = ItemView::newForEntityContent(); $this->assertType( ItemView::$typeMap[ $entityContent->getEntity()->getType() ], -- To view, visit https://gerrit.wikimedia.org/r/84741 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1849e1ccaefaf171fcd601a76521a0e677314b0c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] bug 54264 - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/84740 Change subject: bug 54264 .. bug 54264 Change-Id: I8175174d6baf3c03f327775b9db54ef559c3e8b4 --- A tests/phpunit/includes/GlobalFunctions/wfFailingTest.php 1 file changed, 10 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/40/84740/1 diff --git a/tests/phpunit/includes/GlobalFunctions/wfFailingTest.php b/tests/phpunit/includes/GlobalFunctions/wfFailingTest.php new file mode 100644 index 000..43b2fd6 --- /dev/null +++ b/tests/phpunit/includes/GlobalFunctions/wfFailingTest.php @@ -0,0 +1,10 @@ +https://gerrit.wikimedia.org/r/84740 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8175174d6baf3c03f327775b9db54ef559c3e8b4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Change SnakFormatterFactory::FORMAT_* to SnakFormatter::FORM... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/84534 Change subject: Change SnakFormatterFactory::FORMAT_* to SnakFormatter::FORMAT_* .. Change SnakFormatterFactory::FORMAT_* to SnakFormatter::FORMAT_* Change-Id: I8517feadc094b2799fb68b08d5d4188da32f2c59 --- M client/includes/WikibaseClient.php 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/34/84534/1 diff --git a/client/includes/WikibaseClient.php b/client/includes/WikibaseClient.php index 3d8d565..d106bea 100644 --- a/client/includes/WikibaseClient.php +++ b/client/includes/WikibaseClient.php @@ -181,12 +181,12 @@ /** * @since 0.4 * -* @param string $format The desired format, use SnakFormatterFactory::FORMAT_XXX +* @param string $format The desired format, use SnakFormatter::FORMAT_XXX * @param FormatterOptions $options * * @return SnakFormatter */ - public function newSnakFormatter( $format = SnakFormatterFactory::FORMAT_PLAIN, FormatterOptions $options = null ) { + public function newSnakFormatter( $format = SnakFormatter::FORMAT_PLAIN, FormatterOptions $options = null ) { return $this->getSnakFormatterFactory()->getFormatter( $format, $options ); } -- To view, visit https://gerrit.wikimedia.org/r/84534 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8517feadc094b2799fb68b08d5d4188da32f2c59 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Revert 3fab17d4 and 61dacb15 for PropertyParserFunction - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/84526 Change subject: Revert 3fab17d4 and 61dacb15 for PropertyParserFunction .. Revert 3fab17d4 and 61dacb15 for PropertyParserFunction Change-Id: Ibb94ebc4b6d14cf7a65abecbf06c8d28c9a1d544 --- M client/includes/parserhooks/PropertyParserFunction.php M client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php 2 files changed, 17 insertions(+), 33 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/26/84526/1 diff --git a/client/includes/parserhooks/PropertyParserFunction.php b/client/includes/parserhooks/PropertyParserFunction.php index 55bc65f..4941640 100644 --- a/client/includes/parserhooks/PropertyParserFunction.php +++ b/client/includes/parserhooks/PropertyParserFunction.php @@ -2,11 +2,9 @@ namespace Wikibase; -use ValueFormatters\FormatterOptions; use Wikibase\Client\WikibaseClient; use Wikibase\DataModel\SimpleSiteLink; use Wikibase\Lib\SnakFormatter; -use Wikibase\Lib\SnakFormatterFactory; /** * Handler of the {{#property}} parser function. @@ -36,7 +34,6 @@ * @licence GNU GPL v2+ * @author Katie Filbert < aude.w...@gmail.com > * @author Jeroen De Dauw < jeroended...@gmail.com > - * @author Daniel Kinzler */ class PropertyParserFunction { @@ -62,7 +59,7 @@ * @param EntityLookup$entityLookup * @param PropertyLabelResolver $propertyLabelResolver * @param ParserErrorMessageFormatter $errorFormatter -* @param SnakFormatter $snaksFormatter +* @param Lib\SnakFormatter $snaksFormatter */ public function __construct( \Language $language, EntityLookup $entityLookup, PropertyLabelResolver $propertyLabelResolver, @@ -117,18 +114,12 @@ * @return string - wikitext format */ private function formatSnakList( $snaks ) { - $formattedValues = $this->formatSnaks( $snaks ); + $languageFallbackChainFactory = WikibaseClient::getDefaultInstance()->getLanguageFallbackChainFactory(); + $languageFallbackChain = $languageFallbackChainFactory->newFromLanguage( $this->language, + LanguageFallbackChainFactory::FALLBACK_SELF | LanguageFallbackChainFactory::FALLBACK_VARIANTS + ); + $formattedValues = $this->snaksFormatter->formatSnaks( $snaks, $languageFallbackChain ); return $this->language->commaList( $formattedValues ); - } - - private function formatSnaks( $snaks ) { - $strings = array(); - - foreach ( $snaks as $snak ) { - $strings[] = $this->snaksFormatter->formatSnak( $snak ); - } - - return $strings; } /** @@ -200,18 +191,7 @@ $entityLookup = $wikibaseClient->getStore()->getEntityLookup(); $propertyLabelResolver = $wikibaseClient->getStore()->getPropertyLabelResolver(); - - $languageFallbackChainFactory = WikibaseClient::getDefaultInstance()->getLanguageFallbackChainFactory(); - $languageFallbackChain = $languageFallbackChainFactory->newFromLanguage( $targetLanguage, - LanguageFallbackChainFactory::FALLBACK_SELF | LanguageFallbackChainFactory::FALLBACK_VARIANTS - ); - - $options = new FormatterOptions( array( - 'languages' => $languageFallbackChain, - // ...more options... - ) ); - - $formatter = $wikibaseClient->newSnakFormatter( SnakFormatterFactory::FORMAT_WIKI, $options ); + $formatter = $wikibaseClient->newSnakFormatter(); $instance = new self( $targetLanguage, $entityLookup, $propertyLabelResolver, diff --git a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php index 4b24dbe..0e5d6b3 100644 --- a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php +++ b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php @@ -8,6 +8,9 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use Wikibase\Item; +use Wikibase\Lib\EntityRetrievingDataTypeLookup; +use Wikibase\Lib\SnakFormatter; +use Wikibase\Lib\TypedValueFormatter; use Wikibase\ParserErrorMessageFormatter; use Wikibase\Property; use Wikibase\PropertyParserFunction; @@ -40,10 +43,11 @@ $mockRepo = $this->newMockRepository(); $mockResolver = new MockPropertyLabelResolver( $targetLanguage->getCode(), $mockRepo ); - $formatter = $this->getMock( 'Wikibase\Lib\SnakFormatter' ); - $formatter->expects(
[MediaWiki-commits] [Gerrit] Revert "Revert 3fab17d4 and 61dacb15 for PropertyParserFunct... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/84528 Change subject: Revert "Revert 3fab17d4 and 61dacb15 for PropertyParserFunction" .. Revert "Revert 3fab17d4 and 61dacb15 for PropertyParserFunction" This reverts commit bf35e4ca9df3f959f58107185e1d7383e6baf400. Change-Id: I69eb825d7c2b6468a719bb8d3bcf56f83a6845c7 --- M client/includes/parserhooks/PropertyParserFunction.php M client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php 2 files changed, 33 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/28/84528/1 diff --git a/client/includes/parserhooks/PropertyParserFunction.php b/client/includes/parserhooks/PropertyParserFunction.php index 4941640..55bc65f 100644 --- a/client/includes/parserhooks/PropertyParserFunction.php +++ b/client/includes/parserhooks/PropertyParserFunction.php @@ -2,9 +2,11 @@ namespace Wikibase; +use ValueFormatters\FormatterOptions; use Wikibase\Client\WikibaseClient; use Wikibase\DataModel\SimpleSiteLink; use Wikibase\Lib\SnakFormatter; +use Wikibase\Lib\SnakFormatterFactory; /** * Handler of the {{#property}} parser function. @@ -34,6 +36,7 @@ * @licence GNU GPL v2+ * @author Katie Filbert < aude.w...@gmail.com > * @author Jeroen De Dauw < jeroended...@gmail.com > + * @author Daniel Kinzler */ class PropertyParserFunction { @@ -59,7 +62,7 @@ * @param EntityLookup$entityLookup * @param PropertyLabelResolver $propertyLabelResolver * @param ParserErrorMessageFormatter $errorFormatter -* @param Lib\SnakFormatter $snaksFormatter +* @param SnakFormatter $snaksFormatter */ public function __construct( \Language $language, EntityLookup $entityLookup, PropertyLabelResolver $propertyLabelResolver, @@ -114,12 +117,18 @@ * @return string - wikitext format */ private function formatSnakList( $snaks ) { - $languageFallbackChainFactory = WikibaseClient::getDefaultInstance()->getLanguageFallbackChainFactory(); - $languageFallbackChain = $languageFallbackChainFactory->newFromLanguage( $this->language, - LanguageFallbackChainFactory::FALLBACK_SELF | LanguageFallbackChainFactory::FALLBACK_VARIANTS - ); - $formattedValues = $this->snaksFormatter->formatSnaks( $snaks, $languageFallbackChain ); + $formattedValues = $this->formatSnaks( $snaks ); return $this->language->commaList( $formattedValues ); + } + + private function formatSnaks( $snaks ) { + $strings = array(); + + foreach ( $snaks as $snak ) { + $strings[] = $this->snaksFormatter->formatSnak( $snak ); + } + + return $strings; } /** @@ -191,7 +200,18 @@ $entityLookup = $wikibaseClient->getStore()->getEntityLookup(); $propertyLabelResolver = $wikibaseClient->getStore()->getPropertyLabelResolver(); - $formatter = $wikibaseClient->newSnakFormatter(); + + $languageFallbackChainFactory = WikibaseClient::getDefaultInstance()->getLanguageFallbackChainFactory(); + $languageFallbackChain = $languageFallbackChainFactory->newFromLanguage( $targetLanguage, + LanguageFallbackChainFactory::FALLBACK_SELF | LanguageFallbackChainFactory::FALLBACK_VARIANTS + ); + + $options = new FormatterOptions( array( + 'languages' => $languageFallbackChain, + // ...more options... + ) ); + + $formatter = $wikibaseClient->newSnakFormatter( SnakFormatterFactory::FORMAT_WIKI, $options ); $instance = new self( $targetLanguage, $entityLookup, $propertyLabelResolver, diff --git a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php index 0e5d6b3..4b24dbe 100644 --- a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php +++ b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php @@ -8,9 +8,6 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use Wikibase\Item; -use Wikibase\Lib\EntityRetrievingDataTypeLookup; -use Wikibase\Lib\SnakFormatter; -use Wikibase\Lib\TypedValueFormatter; use Wikibase\ParserErrorMessageFormatter; use Wikibase\Property; use Wikibase\PropertyParserFunction; @@ -43,11 +40,10 @@ $mockRepo = $this->newMockRepository(); $mockResolver = new MockPropertyLabelResolver( $targetLanguage->getCode(), $mockRepo ); - $formatter = new
[MediaWiki-commits] [Gerrit] EMPTY - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/84207 Change subject: EMPTY .. EMPTY Change-Id: I1258fbca0a5f02b9f79ed01b2b080bb4b589a2ff --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/07/84207/1 -- To view, visit https://gerrit.wikimedia.org/r/84207 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1258fbca0a5f02b9f79ed01b2b080bb4b589a2ff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Don't match HTML entities in language conversion syntax - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/83112 Change subject: Don't match HTML entities in language conversion syntax .. Don't match HTML entities in language conversion syntax RegEx provided by Gabriel Wicke Change-Id: Idca127acc6f4cdc159ee85d5f816a5d120cbe44e --- M languages/LanguageConverter.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/12/83112/1 diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 79ddb6a..806d807 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -1127,7 +1127,7 @@ //[1] => 'zh-hant:yyy' //[2] => '' // ) - $pat = '/;\s*(?='; + $pat = '/(?mVariants as $variant ) { // zh-hans:xxx;zh-hant:yyy $pat .= $variant . '\s*:|'; -- To view, visit https://gerrit.wikimedia.org/r/83112 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idca127acc6f4cdc159ee85d5f816a5d120cbe44e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add plain colon and semicolons to wfEscapeWikitext(). - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/82887 Change subject: Add plain colon and semicolons to wfEscapeWikitext(). .. Add plain colon and semicolons to wfEscapeWikitext(). It's a part of language conversion syntax, even when not used at beginning of lines. Change-Id: I848b6d13096887d51618f2694da93b6d65c0376e --- M includes/GlobalFunctions.php 1 file changed, 1 insertion(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/87/82887/1 diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 9a7f62b..2b70faa 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2016,10 +2016,9 @@ '"' => '"', '&' => '&', "'" => ''', '<' => '<', '=' => '=', '>' => '>', '[' => '[', ']' => ']', '{' => '{', '|' => '|', '}' => '}', + ':' => ':', ';' => ';', "\n#" => "\n#", "\r#" => "\r#", "\n*" => "\n*", "\r*" => "\r*", - "\n:" => "\n:", "\r:" => "\r:", - "\n;" => "\n;", "\r;" => "\r;", "\n " => "\n ", "\r " => "\r ", '__' => '__', '://' => '://', ); -- To view, visit https://gerrit.wikimedia.org/r/82887 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I848b6d13096887d51618f2694da93b6d65c0376e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] EMPTY - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/82821 Change subject: EMPTY .. EMPTY Change-Id: Ibb9a3c70609066dd2cca11fdf7be3fa553b37464 --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/21/82821/1 -- To view, visit https://gerrit.wikimedia.org/r/82821 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibb9a3c70609066dd2cca11fdf7be3fa553b37464 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add various missing htmlspecialchars() calls to EntityView. - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/81566 Change subject: Add various missing htmlspecialchars() calls to EntityView. .. Add various missing htmlspecialchars() calls to EntityView. Bug: 53472 Change-Id: I0d874df9b02e457f4691accd7d29edf6c58f0ea5 --- M repo/includes/EntityView.php 1 file changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/66/81566/1 diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php index e5a0adc..da5c3b9 100644 --- a/repo/includes/EntityView.php +++ b/repo/includes/EntityView.php @@ -336,7 +336,7 @@ $prefixedId, wfTemplate( 'wb-property', $label === false ? 'wb-value-empty' : '', - $label === false ? wfMessage( 'wikibase-label-empty' )->text() : htmlspecialchars( $label ), + htmlspecialchars( $label === false ? wfMessage( 'wikibase-label-empty' )->text() : $label ), $this->getHtmlForEditSection( $entity, $lang, $editUrl ) ) ); @@ -368,7 +368,7 @@ $html = wfTemplate( 'wb-description', wfTemplate( 'wb-property', $description === false ? 'wb-value-empty' : '', - $description === false ? wfMessage( 'wikibase-description-empty' )->text() : htmlspecialchars( $description ), + htmlspecialchars( $description === false ? wfMessage( 'wikibase-description-empty' )->text() : $description ), $this->getHtmlForEditSection( $entity, $lang, $editUrl ) ) ); @@ -506,9 +506,9 @@ $tbody .= wfTemplate( 'wb-term', $language, $alternatingClass, - Utils::fetchLanguageName( $language ), - $label !== false ? $label : wfMessage( 'wikibase-label-empty' ), - $description !== false ? $description : wfMessage( 'wikibase-description-empty' ), + htmlspecialchars( Utils::fetchLanguageName( $language ) ), + htmlspecialchars( $label !== false ? $label : wfMessage( 'wikibase-label-empty' ) ), + htmlspecialchars( $description !== false ? $description : wfMessage( 'wikibase-description-empty' ) ), $this->getHtmlForEditSection( $entity, $lang, $editLabelLink ), $this->getHtmlForEditSection( $entity, $lang, $editDescriptionLink ), $label !== false ? '' : 'wb-value-empty', -- To view, visit https://gerrit.wikimedia.org/r/81566 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0d874df9b02e457f4691accd7d29edf6c58f0ea5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove dummy language codes from Utils::getLanguageCodes() - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/81001 Change subject: Remove dummy language codes from Utils::getLanguageCodes() .. Remove dummy language codes from Utils::getLanguageCodes() See http://lists.wikimedia.org/pipermail/wikidata-l/2013-August/002595.html Bug: 51071 Change-Id: I418a880f18fbcade095e1a278ff9dc5d02b29cc6 --- M lib/includes/Utils.php M lib/tests/phpunit/UtilsTest.php 2 files changed, 26 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/01/81001/1 diff --git a/lib/includes/Utils.php b/lib/includes/Utils.php index a9e943c..d434812 100644 --- a/lib/includes/Utils.php +++ b/lib/includes/Utils.php @@ -43,10 +43,11 @@ * @return array */ public static function getLanguageCodes() { + global $wgDummyLanguageCodes; static $languageCodes = null; if ( is_null( $languageCodes ) ) { - $languageCodes = array_keys( \Language::fetchLanguageNames() ); + $languageCodes = array_diff( array_keys( \Language::fetchLanguageNames() ), array_keys( $wgDummyLanguageCodes ) ); } return $languageCodes; diff --git a/lib/tests/phpunit/UtilsTest.php b/lib/tests/phpunit/UtilsTest.php index 17b8288..474af01 100644 --- a/lib/tests/phpunit/UtilsTest.php +++ b/lib/tests/phpunit/UtilsTest.php @@ -40,11 +40,34 @@ return array( array( 'de' ), array( 'en' ), - array( 'no' ), + array( 'nb' ), array( 'nn' ), ); } + /** +* @group WikibaseUtils +* @dataProvider providerGetLanguageCodesInvalid +*/ + public function testGetLanguageCodesInvalid( $lang ) { + $result = Utils::getLanguageCodes(); + $this->assertNotContains( + $lang, + $result, + "The language code {$lang} is found in the returned result" + ); + } + + public static function providerGetLanguageCodesInvalid() { + return array( + array( 'invalid' ), + array( 'no' ), + array( 'qqq' ), + array( 'qqx' ), + array( 'zh-classical' ), + ); + } + public static function provideFetchLanguageName() { return array( array( // #0 -- To view, visit https://gerrit.wikimedia.org/r/81001 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I418a880f18fbcade095e1a278ff9dc5d02b29cc6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] EMPTY - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/80997 Change subject: EMPTY .. EMPTY Change-Id: Ifa9aaa94e00d2b4f4c4e7b8dfd3dd4c0ada0f90b --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/97/80997/1 -- To view, visit https://gerrit.wikimedia.org/r/80997 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifa9aaa94e00d2b4f4c4e7b8dfd3dd4c0ada0f90b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Make FakeConverter more realistic - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/80011 Change subject: Make FakeConverter more realistic .. Make FakeConverter more realistic Spotted by Aude in I38298ceb. Change-Id: I5c5605770077752cd189a5a5f1233949e6eec1d8 --- M languages/Language.php 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/11/80011/1 diff --git a/languages/Language.php b/languages/Language.php index 262d86f..398d941 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -49,12 +49,14 @@ */ public $mLang; function __construct( $langobj ) { $this->mLang = $langobj; } + function autoConvert( $text, $variant = false ) { return $text; } function autoConvertToAllVariants( $text ) { return array( $this->mLang->getCode() => $text ); } function convert( $t ) { return $t; } function convertTo( $text, $variant ) { return $text; } function convertTitle( $t ) { return $t->getPrefixedText(); } function convertNamespace( $ns ) { return $this->mLang->getFormattedNsText( $ns ); } function getVariants() { return array( $this->mLang->getCode() ); } + function getVariantFallbacks() { return $this->mLang->getCode(); } function getPreferredVariant() { return $this->mLang->getCode(); } function getDefaultVariant() { return $this->mLang->getCode(); } function getURLVariant() { return ''; } @@ -66,6 +68,8 @@ function convertCategoryKey( $key ) { return $key; } function convertLinkToAllVariants( $text ) { return $this->autoConvertToAllVariants( $text ); } function armourMath( $text ) { return $text; } + function validateVariant( $variant = null ) { return $variant === $this->mLang->getCode() ? $variant : null; } + function translate( $text, $variant ) { return $text; } } /** -- To view, visit https://gerrit.wikimedia.org/r/80011 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5c5605770077752cd189a5a5f1233949e6eec1d8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Reduce NPath complexity and improve readability - change (mediawiki...Wikibase)
Liangent has submitted this change and it was merged. Change subject: Reduce NPath complexity and improve readability .. Reduce NPath complexity and improve readability Change-Id: I7961b2c507da3661ce4c0a8bbaf994e80001b672 --- M lib/includes/LanguageFallbackChainFactory.php 1 file changed, 42 insertions(+), 23 deletions(-) Approvals: Liangent: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/includes/LanguageFallbackChainFactory.php b/lib/includes/LanguageFallbackChainFactory.php index 5ce24a8..b2106f6 100644 --- a/lib/includes/LanguageFallbackChainFactory.php +++ b/lib/includes/LanguageFallbackChainFactory.php @@ -216,7 +216,6 @@ * @return LanguageFallbackChain */ public function newFromUserAndLanguageCode( User $user, $languageCode ) { - global $wgBabelCategoryNames; wfProfileIn( __METHOD__ ); if ( !class_exists( 'Babel' ) || $user->isAnon() ) { @@ -233,28 +232,7 @@ return $cached; } - $babel = array(); - $contextLanguage = array( $languageCode ); - - if ( count( $wgBabelCategoryNames ) ) { - // A little redundant but it's the only way to get required information with current Babel API. - $previousLevelBabel = array(); - $babelCategoryNames = array_filter( $wgBabelCategoryNames, function( $category ) { - return $category !== false; - } ); - krsort( $babelCategoryNames ); - foreach ( $babelCategoryNames as $level => $_ ) { - // Make the current language at the top of the chain. - $levelBabel = array_unique( array_merge( - $contextLanguage, \Babel::getUserLanguages( $user, $level ) - ) ); - $babel[$level] = array_diff( $levelBabel, $previousLevelBabel ); - $previousLevelBabel = $levelBabel; - } - } else { - // Just in case - $babel['N'] = $contextLanguage; - } + $babel = $this->getBabel( $languageCode, $user ); $chain = $this->buildFromBabel( $babel ); $languageFallbackChain = new LanguageFallbackChain( $chain ); @@ -265,6 +243,47 @@ return $languageFallbackChain; } + protected function getBabel( $languageCode, $user ) { + $babel = array(); + + $babelCategoryNames = $this->getBabelCategoryNames(); + + if ( count( $babelCategoryNames ) ) { + // A little redundant but it's the only way to get required information with current Babel API. + $previousLevelBabel = array(); + + foreach ( $babelCategoryNames as $level => $_ ) { + // Make the current language at the top of the chain. + $levelBabel = array_unique( array_merge( + array( $languageCode ), + \Babel::getUserLanguages( $user, $level ) + ) ); + + $babel[$level] = array_diff( $levelBabel, $previousLevelBabel ); + $previousLevelBabel = $levelBabel; + } + } else { + $babel['N'] = array( $languageCode ); + } + + return $babel; + } + + protected function getBabelCategoryNames() { + global $wgBabelCategoryNames; + + $babelCategoryNames = array_filter( + $wgBabelCategoryNames, + function( $category ) { + return $category !== false; + } + ); + + krsort( $babelCategoryNames ); + + return $babelCategoryNames; + } + /** * Build fallback chain array for a given babel array. * -- To view, visit https://gerrit.wikimedia.org/r/79192 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7961b2c507da3661ce4c0a8bbaf994e80001b672 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Addshore Gerrit-Reviewer: Denny Vrandecic Gerrit-Reviewer: Liangent Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.w
[MediaWiki-commits] [Gerrit] Filter and sort $wgBabelCategoryNames correctly for Babel ex... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/79180 Change subject: Filter and sort $wgBabelCategoryNames correctly for Babel extraction .. Filter and sort $wgBabelCategoryNames correctly for Babel extraction Change-Id: Iaf08f4448d1a9f5141717684b6794e418f1262f6 --- M lib/includes/LanguageFallbackChainFactory.php 1 file changed, 5 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/80/79180/1 diff --git a/lib/includes/LanguageFallbackChainFactory.php b/lib/includes/LanguageFallbackChainFactory.php index fa7fb01..5ce24a8 100644 --- a/lib/includes/LanguageFallbackChainFactory.php +++ b/lib/includes/LanguageFallbackChainFactory.php @@ -239,7 +239,11 @@ if ( count( $wgBabelCategoryNames ) ) { // A little redundant but it's the only way to get required information with current Babel API. $previousLevelBabel = array(); - foreach ( $wgBabelCategoryNames as $level => $_ ) { + $babelCategoryNames = array_filter( $wgBabelCategoryNames, function( $category ) { + return $category !== false; + } ); + krsort( $babelCategoryNames ); + foreach ( $babelCategoryNames as $level => $_ ) { // Make the current language at the top of the chain. $levelBabel = array_unique( array_merge( $contextLanguage, \Babel::getUserLanguages( $user, $level ) -- To view, visit https://gerrit.wikimedia.org/r/79180 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaf08f4448d1a9f5141717684b6794e418f1262f6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Don't use $wgVariantArticlePath for variants of non-content ... - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/79066 Change subject: Don't use $wgVariantArticlePath for variants of non-content languages .. Don't use $wgVariantArticlePath for variants of non-content languages Currently PathRouter understands variants of $wgContLang only, and it wouldn't be easy to extend it to variants of the given title because at the time of preparing PathRouter for parsing, the title is unknown yet. Bug: 52852 Bug: 52850 Change-Id: I7dcf7dc73e36945e420a66d99329c09c75b17882 --- M includes/Title.php 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/66/79066/1 diff --git a/includes/Title.php b/includes/Title.php index 7818742..734e009 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1441,7 +1441,7 @@ $url = str_replace( '$1', $dbkey, $wgArticlePath ); wfRunHooks( 'GetLocalURL::Article', array( &$this, &$url ) ); } else { - global $wgVariantArticlePath, $wgActionPaths; + global $wgVariantArticlePath, $wgActionPaths, $wgContLang; $url = false; $matches = array(); @@ -1463,6 +1463,7 @@ if ( $url === false && $wgVariantArticlePath && + $wgContLang->getCode() === $this->getPageLanguage()->getCode() && $this->getPageLanguage()->hasVariants() && preg_match( '/^variant=([^&]*)$/', $query, $matches ) ) { -- To view, visit https://gerrit.wikimedia.org/r/79066 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7dcf7dc73e36945e420a66d99329c09c75b17882 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Followup Ifb005e7c: some cleanup in comments. - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/79063 Change subject: Followup Ifb005e7c: some cleanup in comments. .. Followup Ifb005e7c: some cleanup in comments. There're still various "disable" left there in messages, which are fixable on translatewiki.net: MessagesIke_cans.php:'variantname-iu' => 'disable', MessagesIke_latn.php:'variantname-iu' => 'disable', MessagesKk.php:'variantname-kk-kz' => 'disable', MessagesKk.php:'variantname-kk-tr' => 'disable', MessagesKk.php:'variantname-kk-cn' => 'disable', MessagesKk.php:'variantname-kk' => 'disable', MessagesKu_latn.php:'variantname-ku' => 'disable', MessagesShi.php:'variantname-shi' => 'disable', Change-Id: Ic8f874660f3b6f266ab791422cc5ee1749546a00 --- M languages/messages/MessagesZh_tw.php 1 file changed, 1 insertion(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/63/79063/1 diff --git a/languages/messages/MessagesZh_tw.php b/languages/messages/MessagesZh_tw.php index 7d98460..2d9b818 100644 --- a/languages/messages/MessagesZh_tw.php +++ b/languages/messages/MessagesZh_tw.php @@ -875,12 +875,7 @@ 只有列示項目(以 * 開頭的項目)會被考慮。第一個連結一定要連接去壞圖片中。 然後在同一行的連結會考慮作例外,即是幅圖片可以在哪一個頁面中同時顯示。', -/* -Short names for language variants used for language conversion links. -To disable showing a particular link, set it to 'disable', e.g. -'variantname-zh-sg' => 'disable', -Variants for Chinese language -*/ +# Variants for Chinese language 'variantname-zh-tw' => '台灣繁體', # Metadata -- To view, visit https://gerrit.wikimedia.org/r/79063 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic8f874660f3b6f266ab791422cc5ee1749546a00 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Implement LanguageConverter for yue (Cantonese) - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/78504 Change subject: Implement LanguageConverter for yue (Cantonese) .. Implement LanguageConverter for yue (Cantonese) Change-Id: Iee936baa0a42370a723b34b09a791bf0917dcdf4 --- M languages/Names.php M languages/classes/LanguageYue.php M languages/messages/MessagesYue.php A languages/messages/MessagesYue_hans.php A languages/messages/MessagesYue_hant.php 5 files changed, 3,437 insertions(+), 3,345 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/04/78504/1 -- To view, visit https://gerrit.wikimedia.org/r/78504 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iee936baa0a42370a723b34b09a791bf0917dcdf4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Failing parser tests with LanguageConverter applied - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/76341 Change subject: Failing parser tests with LanguageConverter applied .. Failing parser tests with LanguageConverter applied Found in https://gerrit.wikimedia.org/r/#/c/72053/ Change-Id: I9b099273203482ffb570a5654d8ba50c833e526d --- M tests/parser/extraParserTests.txt M tests/parser/parserTests.txt 2 files changed, 32 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/41/76341/1 diff --git a/tests/parser/extraParserTests.txt b/tests/parser/extraParserTests.txt index bef8f50..267d0ff 100644 --- a/tests/parser/extraParserTests.txt +++ b/tests/parser/extraParserTests.txt Binary files differ diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index e1f2370..bd2133f 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -8223,6 +8223,17 @@ !! end !! test +Escape HTML special chars in image alt text with LanguageConverter +!! options +language=zh +!! input +[[Image:foobar.jpg|& < > "]] +!! result +http://example.com/images/3/3a/Foobar.jpg"; width="1941" height="220" /> + +!! end + +!! test BUG 499: Alt text should have Ӓ, not &1234; !! input [[Image:foobar.jpg|♀]] @@ -14473,6 +14484,27 @@ !! end +!! test +Gallery override link with absolute external link with LanguageConverter +!! options +language=zh +!! input + +File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org + +!! result + + + http://www.example.org";>http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg"; width="120" height="14" /> + +caption + + + + + +!! end + !!test Gallery override link with malicious javascript (bug 34852) !! input -- To view, visit https://gerrit.wikimedia.org/r/76341 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9b099273203482ffb570a5654d8ba50c833e526d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WIKIBASE MASTER FAILS? - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/76062 Change subject: WIKIBASE MASTER FAILS? .. WIKIBASE MASTER FAILS? Change-Id: I5cde50b45db233100b79da1e39d19f775b270a31 --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/62/76062/1 -- To view, visit https://gerrit.wikimedia.org/r/76062 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5cde50b45db233100b79da1e39d19f775b270a31 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Make LanguageFallbackChainFactory work with $wgDisabledVariants - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/76060 Change subject: Make LanguageFallbackChainFactory work with $wgDisabledVariants .. Make LanguageFallbackChainFactory work with $wgDisabledVariants Change-Id: Ia11f744d3d1a5c4b71b590d25baa481ca7b3bd95 --- M lib/includes/LanguageFallbackChainFactory.php M lib/tests/phpunit/LanguageFallbackChainFactoryTest.php 2 files changed, 46 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/60/76060/1 diff --git a/lib/includes/LanguageFallbackChainFactory.php b/lib/includes/LanguageFallbackChainFactory.php index e077ebf..23a359d 100644 --- a/lib/includes/LanguageFallbackChainFactory.php +++ b/lib/includes/LanguageFallbackChainFactory.php @@ -152,7 +152,7 @@ } foreach ( $variants as $variant ) { - if ( isset( $fetched[$variant] ) ) { + if ( isset( $fetched[$variant] ) || !$parentLanguage->hasVariant( $variant ) ) { continue; } diff --git a/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php b/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php index d9ced64..3696a76 100644 --- a/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php +++ b/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php @@ -34,13 +34,31 @@ } } + private function setupDisabledVariants( $disabledVariants ) { + global $wgDisabledVariants, $wgLangObjCacheSize; + $originalDisabledVariants = $wgDisabledVariants; + $originalLangObjCacheSize = $wgLangObjCacheSize; + if ( $disabledVariants ) { + $wgDisabledVariants = $disabledVariants; + } + $wgLangObjCacheSize = 0; + return array( $originalDisabledVariants, $originalLangObjCacheSize ); + } + + private function clearDisabledVariants( $state ) { + global $wgDisabledVariants, $wgLangObjCacheSize; + list( $wgDisabledVariants, $wgLangObjCacheSize ) = $state; + } + /** * @group WikibaseLib * @dataProvider providerNewFromLanguage */ - public function testNewFromLanguage( $lang, $mode, $expected ) { + public function testNewFromLanguage( $lang, $mode, $expected, $disabledVariants = null ) { + $state = $this->setupDisabledVariants( $disabledVariants ); $factory = new LanguageFallbackChainFactory(); $chain = $factory->newFromLanguage( \Language::factory( $lang ), $mode )->getFallbackChain(); + $this->clearDisabledVariants( $state ); $this->assertChainEquals( $expected, $chain ); } @@ -48,9 +66,11 @@ * @group WikibaseLib * @dataProvider providerNewFromLanguage */ - public function testNewFromLanguageCode( $lang, $mode, $expected ) { + public function testNewFromLanguageCode( $lang, $mode, $expected, $disabledVariants = null ) { + $state = $this->setupDisabledVariants( $disabledVariants ); $factory = new LanguageFallbackChainFactory(); $chain = $factory->newFromLanguageCode( $lang, $mode )->getFallbackChain(); + $this->clearDisabledVariants( $state ); $this->assertChainEquals( $expected, $chain ); } @@ -80,6 +100,16 @@ array( 'zh', 'zh-my' ), 'en', ) ), + array( 'zh', LanguageFallbackChainFactory::FALLBACK_ALL, array( + 'zh', + array( 'zh', 'zh-hans' ), + array( 'zh', 'zh-hant' ), + array( 'zh', 'zh-cn' ), + array( 'zh', 'zh-tw' ), + array( 'zh', 'zh-hk' ), + array( 'zh', 'zh-sg' ), + 'en', + ), array( 'zh-mo', 'zh-my' ) ), array( 'zh', LanguageFallbackChainFactory::FALLBACK_SELF, array( 'zh' ) ), array( 'zh', LanguageFallbackChainFactory::FALLBACK_VARIANTS, array( array( 'zh', 'zh-hans' ), @@ -109,6 +139,16 @@ array( 'zh-cn', 'zh-tw' ), 'en', ) ), + array( 'zh-cn', LanguageFallbackChainFactory::FALLBACK_ALL, array( + 'zh-cn', + array( 'zh-cn', 'zh-sg' ), + arra
[MediaWiki-commits] [Gerrit] Fix API error message when titlePartToKey / keyPartToTitle a... - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/74977 Change subject: Fix API error message when titlePartToKey / keyPartToTitle are used .. Fix API error message when titlePartToKey / keyPartToTitle are used Change-Id: I0c83142b44e74cfda1cbc548eebfcfbfce8e7b19 --- M includes/api/ApiQueryBase.php 1 file changed, 14 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/77/74977/1 diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 8668e04..9fd2455 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -408,16 +408,20 @@ /** * Convert a title to a DB key * @param string $title Page title with spaces +* @param string $rawTitle Page title to display in error messages, defaults to $title * @return string Page title with underscores */ - public function titleToKey( $title ) { + public function titleToKey( $title, $rawTitle = null ) { // Don't throw an error if we got an empty string if ( trim( $title ) == '' ) { return ''; } $t = Title::newFromText( $title ); if ( !$t ) { - $this->dieUsageMsg( array( 'invalidtitle', $title ) ); + if ( $rawTitle === null ) { + $rawTitle = $title; + } + $this->dieUsageMsg( array( 'invalidtitle', $rawTitle ) ); } return $t->getPrefixedDBkey(); } @@ -425,9 +429,10 @@ /** * The inverse of titleToKey() * @param string $key Page title with underscores +* @param string $rawKey Page title to display in error messages, defaults to $key * @return string Page title with spaces */ - public function keyToTitle( $key ) { + public function keyToTitle( $key, $rawKey = null ) { // Don't throw an error if we got an empty string if ( trim( $key ) == '' ) { return ''; @@ -435,7 +440,10 @@ $t = Title::newFromDBkey( $key ); // This really shouldn't happen but we gotta check anyway if ( !$t ) { - $this->dieUsageMsg( array( 'invalidtitle', $key ) ); + if ( $rawKey === null ) { + $rawKey = $key; + } + $this->dieUsageMsg( array( 'invalidtitle', $rawKey ) ); } return $t->getPrefixedText(); } @@ -446,7 +454,7 @@ * @return string Title part with underscores */ public function titlePartToKey( $titlePart ) { - return substr( $this->titleToKey( $titlePart . 'x' ), 0, - 1 ); + return substr( $this->titleToKey( $titlePart . 'x', $titlePart ), 0, - 1 ); } /** @@ -455,7 +463,7 @@ * @return string Key part with underscores */ public function keyPartToTitle( $keyPart ) { - return substr( $this->keyToTitle( $keyPart . 'x' ), 0, - 1 ); + return substr( $this->keyToTitle( $keyPart . 'x', $keyPart ), 0, - 1 ); } /** -- To view, visit https://gerrit.wikimedia.org/r/74977 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0c83142b44e74cfda1cbc548eebfcfbfce8e7b19 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] ApiGetEntities - DO NOT MERGE - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/74954 Change subject: ApiGetEntities - DO NOT MERGE .. ApiGetEntities - DO NOT MERGE Change-Id: Icb9b4fc0f8ebfe74b7895ed5f775fc6940ac19e9 --- M repo/includes/api/GetEntities.php 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/54/74954/1 diff --git a/repo/includes/api/GetEntities.php b/repo/includes/api/GetEntities.php index 2b79bf9..7bdff95 100644 --- a/repo/includes/api/GetEntities.php +++ b/repo/includes/api/GetEntities.php @@ -231,6 +231,7 @@ ApiBase::PARAM_TYPE => Utils::getLanguageCodes(), ApiBase::PARAM_ISMULTI => true, ), + 'languagefallback' => false, 'normalize' => array( ApiBase::PARAM_TYPE => 'boolean', ApiBase::PARAM_DFLT => false -- To view, visit https://gerrit.wikimedia.org/r/74954 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icb9b4fc0f8ebfe74b7895ed5f775fc6940ac19e9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Merge commit '64f77bb54a0ea3e80a8bb9cdbaa515950b5c2b25' into... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/74953 Change subject: Merge commit '64f77bb54a0ea3e80a8bb9cdbaa515950b5c2b25' into ApiGetEntities .. Merge commit '64f77bb54a0ea3e80a8bb9cdbaa515950b5c2b25' into ApiGetEntities Change-Id: Idfef681620d835f067b842b4b83bfa1993f9c72d --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/53/74953/1 -- To view, visit https://gerrit.wikimedia.org/r/74953 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idfef681620d835f067b842b4b83bfa1993f9c72d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Merge commit '64f77bb54a0ea3e80a8bb9cdbaa515950b5c2b25' into... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/74952 Change subject: Merge commit '64f77bb54a0ea3e80a8bb9cdbaa515950b5c2b25' into ApiGetEntities .. Merge commit '64f77bb54a0ea3e80a8bb9cdbaa515950b5c2b25' into ApiGetEntities Change-Id: Ic641df2c1a5673a1de9b17f50ad9a46c86da5234 --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/52/74952/1 -- To view, visit https://gerrit.wikimedia.org/r/74952 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic641df2c1a5673a1de9b17f50ad9a46c86da5234 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] New LanguageFallbackChainFactory functions - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/74653 Change subject: New LanguageFallbackChainFactory functions .. New LanguageFallbackChainFactory functions ->newFromContextAndLanguage() and ->newFromUserAndLanguage() are added. Change-Id: I1122e1757e0f5ac3b5982e343ede62dbec3e34bf --- M lib/includes/LanguageFallbackChainFactory.php M lib/tests/phpunit/LanguageFallbackChainFactoryTest.php 2 files changed, 55 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/53/74653/1 diff --git a/lib/includes/LanguageFallbackChainFactory.php b/lib/includes/LanguageFallbackChainFactory.php index 475db4e..7b7a23c 100644 --- a/lib/includes/LanguageFallbackChainFactory.php +++ b/lib/includes/LanguageFallbackChainFactory.php @@ -1,7 +1,7 @@ newFromUserAndLanguage( $context->getUser(), $context->getLanguage() ); + } + + /** +* Construct the fallback chain based on a context, but ignore the language info in it and use a specified one instead. +* +* @param IContextSource $context +* @param Language $language +* +* @return LanguageFallbackChain +*/ + public function newFromContextAndLanguage( IContextSource $context, Language $language ) { + return $this->newFromUserAndLanguage( $context->getUser(), $language ); + } + + /** +* Construct the fallback chain based on a user and a language, currently from data provided by Extension:Babel. +* +* @param User $user +* @param Language $language +* +* @return LanguageFallbackChain +*/ + public function newFromUserAndLanguage( User $user, Language $language ) { global $wgBabelCategoryNames; wfProfileIn( __METHOD__ ); - $user = $context->getUser(); - if ( !class_exists( 'Babel' ) || $user->isAnon() ) { - $cached = $this->newFromLanguage( $context->getLanguage(), self::FALLBACK_ALL ); + $cached = $this->newFromLanguage( $language, self::FALLBACK_ALL ); wfProfileOut( __METHOD__ ); return $cached; } - if ( isset( $this->userLanguageCache[$user->getName()][$context->getLanguage()->getCode()] ) ) { - $cached = $this->userLanguageCache[$user->getName()][$context->getLanguage()->getCode()]; + if ( isset( $this->userLanguageCache[$user->getName()][$language->getCode()] ) ) { + $cached = $this->userLanguageCache[$user->getName()][$language->getCode()]; wfProfileOut( __METHOD__ ); return $cached; } $babel = array(); - $contextLanguage = array( $context->getLanguage()->getCode() ); + $contextLanguage = array( $language->getCode() ); if ( count( $wgBabelCategoryNames ) ) { // A little redundant but it's the only way to get required information with current Babel API. @@ -226,7 +248,7 @@ $chain = $this->buildFromBabel( $babel ); $languageFallbackChain = new LanguageFallbackChain( $chain ); - $this->userLanguageCache[$user->getName()][$context->getLanguage()->getCode()] = $languageFallbackChain; + $this->userLanguageCache[$user->getName()][$language->getCode()] = $languageFallbackChain; wfProfileOut( __METHOD__ ); return $languageFallbackChain; diff --git a/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php b/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php index ca40695..ed30e1b 100644 --- a/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php +++ b/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php @@ -190,6 +190,30 @@ /** * @group WikibaseLib +*/ + public function testNewFromContextAndLanguage() { + $factory = new LanguageFallbackChainFactory(); + $languageFallbackChain = $factory->newFromContext( \RequestContext::getMain(), \Language::factory( 'en' ) ); + $this->assertTrue( $languageFallbackChain instanceof LanguageFallbackChain ); + } + + /** +* @group WikibaseLib +* @dataProvider providerNewFromLanguage +*/ + public function testNewFromUserAndLanguage( $lang, $mode, $expected ) { + if ( $mode !== LanguageFallbackChainFactory::FALLBACK_ALL ) { + $this->assertTrue( true ); + return; + } + $factory = new LanguageFallbackChainFactory(); + $anon = new \User(); + $chain = $factory->newFromUserAndLanguage( $anon, \Langua
[MediaWiki-commits] [Gerrit] Change return value of LanguageFallbackChain::extractPreferr... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/74648 Change subject: Change return value of LanguageFallbackChain::extractPreferredValue() .. Change return value of LanguageFallbackChain::extractPreferredValue() per talk with Denny. Change-Id: Ie08ee3f9ebb5014541f5be671f06e635c5783e4d --- M lib/includes/LanguageFallbackChain.php M lib/tests/phpunit/LanguageFallbackChainTest.php 2 files changed, 15 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/48/74648/1 diff --git a/lib/includes/LanguageFallbackChain.php b/lib/includes/LanguageFallbackChain.php index 2bd4a57..a92c269 100644 --- a/lib/includes/LanguageFallbackChain.php +++ b/lib/includes/LanguageFallbackChain.php @@ -61,20 +61,21 @@ * @return null|array of three items: array( * 'value' => finally fetched and translated value * 'language' => language code of the language which final value is in -* 'source' => language code of the language where the value is fetched +* 'source' => language code of the language where the value is translated from * ), or null when no "acceptable" data can be found. */ public function extractPreferredValue( $data ) { foreach ( $this->chain as $languageWithConversion ) { $fetchCode = $languageWithConversion->getFetchLanguageCode(); + $sourceCode = $languageWithConversion->getSourceLanguageCode(); $languageCode = $languageWithConversion->getLanguageCode(); if ( isset( $data[$fetchCode] ) ) { return array( 'value' => $languageWithConversion->translate( $data[$fetchCode] ), 'language' => $languageCode, - 'source' => $fetchCode, + 'source' => $sourceCode, ); } } @@ -91,7 +92,7 @@ * @return null|array of three items: array( * 'value' => finally fetched and translated value * 'language' => language code of the language which final value is in -* 'source' => language code of the language where the value is fetched +* 'source' => language code of the language where the value is translated from * ), or null when no data with a valid language code can be found. */ public function extractPreferredValueOrAny( $data ) { @@ -106,7 +107,7 @@ return array( 'value' => $value, 'language' => $code, - 'source' => $code, + 'source' => null, ); } } diff --git a/lib/tests/phpunit/LanguageFallbackChainTest.php b/lib/tests/phpunit/LanguageFallbackChainTest.php index d22699e..e7e4322 100644 --- a/lib/tests/phpunit/LanguageFallbackChainTest.php +++ b/lib/tests/phpunit/LanguageFallbackChainTest.php @@ -46,23 +46,23 @@ array( 'en', LanguageFallbackChainFactory::FALLBACK_ALL, $data, array( 'value' => 'foo', 'language' => 'en', - 'source' => 'en', + 'source' => null, ) ), array( 'zh-classical', LanguageFallbackChainFactory::FALLBACK_ALL, $data, array( 'value' => '試', 'language' => 'lzh', - 'source' => 'lzh', + 'source' => null, ) ), array( 'nl', LanguageFallbackChainFactory::FALLBACK_ALL, $data, array( 'value' => 'bar', 'language' => 'nl', - 'source' => 'nl', + 'source' => null, ) ), array( 'de', LanguageFallbackChainFactory::FALLBACK_SELF, $data, null ), array( 'de', LanguageFallbackChainFactory::FALLBACK_ALL, $data, array( 'value' => 'foo', 'language' => 'en', - 'source' => 'en', + 'source' => null, ) ), array( 'zh', LanguageFallbackChainFactory::FALLBACK_ALL, $data, array( 'value' => '测试', @@ -96,7 +96,7 @@
[MediaWiki-commits] [Gerrit] LanguageWithConversion fix - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/73854 Change subject: LanguageWithConversion fix .. LanguageWithConversion fix Should have been done when lazy Language initialization was added. Change-Id: I7e90e752e1403da4bf154c05809d69fe1286a16d --- M lib/includes/LanguageWithConversion.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/54/73854/1 diff --git a/lib/includes/LanguageWithConversion.php b/lib/includes/LanguageWithConversion.php index c8de917..802d568 100644 --- a/lib/includes/LanguageWithConversion.php +++ b/lib/includes/LanguageWithConversion.php @@ -251,7 +251,7 @@ $pieces = array_keys( $this->translatePool ); $block = implode( "\0", $pieces ); $translatedBlock = $this->parentLanguage->getConverter()->translate( - $block, $this->language->getCode() + $block, $this->languageCode ); $translatedPieces = explode( "\0", $translatedBlock ); $this->translateCache += array_combine( $pieces, $translatedPieces ); -- To view, visit https://gerrit.wikimedia.org/r/73854 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7e90e752e1403da4bf154c05809d69fe1286a16d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] LanguageWithConversion translation change - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/73754 Change subject: LanguageWithConversion translation change .. LanguageWithConversion translation change * Batched translation has been removed. Wikibase is so structured and it is not so easy to use that in Wikibase. * A new reverseTranslate() function has been added, trying to work out the original string in source language. * A few more tests have been added. Change-Id: I38298ceb608edd50600b93176b2e88c75b0335e6 --- M lib/includes/LanguageWithConversion.php M lib/tests/phpunit/LanguageWithConversionTest.php 2 files changed, 33 insertions(+), 48 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/54/73754/1 diff --git a/lib/includes/LanguageWithConversion.php b/lib/includes/LanguageWithConversion.php index c8de917..95f0a79 100644 --- a/lib/includes/LanguageWithConversion.php +++ b/lib/includes/LanguageWithConversion.php @@ -38,9 +38,6 @@ protected $sourceLanguageCode; protected $parentLanguage; - protected $translateCache = array(); - protected $translatePool = array(); - /** * Constructor. * @@ -206,6 +203,20 @@ } /** +* Try to work out the original data (in source language) from a given translation output. +* +* @param $text String +* @return String +*/ + public function reverseTranslate( $text ) { + if ( $this->parentLanguage ) { + return $this->parentLanguage->getConverter()->translate( $text, $this->getSourceLanguageCode() ); + } else { + return $text; + } + } + + /** * Translate data after fetching them. * * @param $text String: Data to transform @@ -213,49 +224,10 @@ */ public function translate( $text ) { if ( $this->parentLanguage ) { - if ( isset( $this->translateCache[$text] ) ) { - return $this->translateCache[$text]; - } else { - $this->prepareForTranslate( $text ); - $this->executeTranslate(); - return $this->translateCache[$text]; - } + return $this->parentLanguage->getConverter()->translate( $text, $this->getLanguageCode() ); } else { return $text; } } - /** -* Insert a text snippet which will be translated later. -* -* Due to the implementation of language converter, massive -* calls with short text snippets may introduce big overhead. -* If it's foreseeable that some text will be translated -* later, add it here for batched translation. -* -* Does nothing if this is not a converted language. -* -* @param $text String -*/ - public function prepareForTranslate( $text ) { - if ( $this->parentLanguage ) { - $this->translatePool[$text] = true; - } - } - - /** -* Really execute translation. -*/ - protected function executeTranslate() { - if ( $this->parentLanguage && count( $this->translatePool ) ) { - $pieces = array_keys( $this->translatePool ); - $block = implode( "\0", $pieces ); - $translatedBlock = $this->parentLanguage->getConverter()->translate( - $block, $this->language->getCode() - ); - $translatedPieces = explode( "\0", $translatedBlock ); - $this->translateCache += array_combine( $pieces, $translatedPieces ); - $this->translatePool = array(); - } - } } diff --git a/lib/tests/phpunit/LanguageWithConversionTest.php b/lib/tests/phpunit/LanguageWithConversionTest.php index c13a6ac..90da79e 100644 --- a/lib/tests/phpunit/LanguageWithConversionTest.php +++ b/lib/tests/phpunit/LanguageWithConversionTest.php @@ -119,18 +119,31 @@ /** * @dataProvider provideTranslate */ - public function testTranslateBatched( $langCode, $sourceLangCode, $translations ) { - $obj = LanguageWithConversion::factory( $langCode, $sourceLangCode ); - foreach ( $translations as $text => $translatedText ) { - $obj->prepareForTranslate( $text ); + public function testReverseTranslate( $langCode, $sourceLangCode, $translations ) { + if ( $sourceLangCode === null ) { + $sourceLangCode = $langCode; + $langCode = null;
[MediaWiki-commits] [Gerrit] LanguageFallbackChain: Avoid one more unneeded Language cons... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/73413 Change subject: LanguageFallbackChain: Avoid one more unneeded Language construction .. LanguageFallbackChain: Avoid one more unneeded Language construction Change-Id: Ia766d7fde8743d42f81317e921172e23100239c5 --- M lib/includes/LanguageFallbackChainFactory.php 1 file changed, 7 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/13/73413/1 diff --git a/lib/includes/LanguageFallbackChainFactory.php b/lib/includes/LanguageFallbackChainFactory.php index 475db4e..1d154c0 100644 --- a/lib/includes/LanguageFallbackChainFactory.php +++ b/lib/includes/LanguageFallbackChainFactory.php @@ -134,10 +134,14 @@ } if ( $mode & self::FALLBACK_VARIANTS ) { - if ( is_string( $language ) ) { - $language = Language::factory( $language ); + if ( !in_array( $languageCode, LanguageConverter::$languagesWithVariants ) ) { + $parentLanguage = null; + } else { + if ( is_string( $language ) ) { + $language = Language::factory( $language ); + } + $parentLanguage = $language->getParentLanguage(); } - $parentLanguage = $language->getParentLanguage(); if ( $parentLanguage ) { // It's less likely to trigger conversion mistakes by converting // zh-tw to zh-hk first instead of converting zh-cn to zh-tw. -- To view, visit https://gerrit.wikimedia.org/r/73413 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia766d7fde8743d42f81317e921172e23100239c5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] EXPERIMENTAL VERSION OF Id62fdd16187c79549328711ded5265802bc... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72986 Change subject: EXPERIMENTAL VERSION OF Id62fdd16187c79549328711ded5265802bc9453a .. EXPERIMENTAL VERSION OF Id62fdd16187c79549328711ded5265802bc9453a Change-Id: Id62fdd16187c79549328711ded5265802bc9453b --- M repo/includes/api/GetEntities.php 1 file changed, 31 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/86/72986/1 diff --git a/repo/includes/api/GetEntities.php b/repo/includes/api/GetEntities.php index d542738..6e14d65 100644 --- a/repo/includes/api/GetEntities.php +++ b/repo/includes/api/GetEntities.php @@ -3,6 +3,8 @@ namespace Wikibase\Api; use ApiBase; +use DerivativeContext; +use Language; use MWException; use Wikibase\Lib\Serializers\EntitySerializationOptions; @@ -13,6 +15,7 @@ use Wikibase\EntityId; use Wikibase\Item; use Wikibase\EntityContentFactory; +use Wikibase\LanguageFallbackChain; /** * API module to get the data for one or more Wikibase entities. @@ -30,6 +33,11 @@ class GetEntities extends ApiWikibase { /** +* @var LanguageFallbackChainFactory +*/ + protected $languageFallbackChainFactory; + + /** * @var \Wikibase\StringNormalizer */ protected $stringNormalizer; @@ -38,6 +46,7 @@ parent::__construct( $main, $name, $prefix ); $this->stringNormalizer = WikibaseRepo::getDefaultInstance()->getStringNormalizer(); + $this->languageFallbackChainFactory = WikibaseRepo::getDefaultInstance()->getLanguageFallbackChainFactory(); } /** @@ -189,7 +198,24 @@ // TODO: inject id formatter $options = new EntitySerializationOptions( WikibaseRepo::getDefaultInstance()->getIdFormatter() ); - $options->setLanguages( $params['languages'] ); + $languagefallback = $params['languagefallback']; + if ( $languagefallback ) { + foreach ( $params['languages'] as $languageCode ) { + try { + $contextLang = Language::factory( $languageCode ); + } catch ( MWException $e ) { + wfProfileOut( __METHOD__ ); + $this->dieUsage( "Invalid language: $languageCode", 'invalid-language' ); + } + $context = new DerivativeContext( $this->getContext() ); + $context->setLanguage( $contextLang ); + $chain = $this->languageFallbackChainFactory->newFromContext( $context ); + $languages[$languageCode] = $chain; + } + } else { + $languages = $params['languages']; + } + $options->setLanguages( $languages ); $options->setSortDirection( $params['dir'] ); $options->setProps( $props ); $options->setIndexTags( $this->getResult()->getIsRawMode() ); @@ -258,6 +284,7 @@ ApiBase::PARAM_TYPE => Utils::getLanguageCodes(), ApiBase::PARAM_ISMULTI => true, ), + 'languagefallback' => false, ) ); } @@ -287,6 +314,9 @@ 'languages' => array( 'By default the internationalized values are returned in all available languages.', 'This parameter allows filtering these down to one or more languages by providing one or more language codes.' ), + 'languagefallback' => array( 'Apply language fallback?', + 'Note: the returned data might be somehow unusable in "raw modes" such as XML output.', + ), ) ); } -- To view, visit https://gerrit.wikimedia.org/r/72986 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id62fdd16187c79549328711ded5265802bc9453b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists
[MediaWiki-commits] [Gerrit] Merge commit '4f18a3b5799b9671f6efeacf99805c51768e359d' into... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72988 Change subject: Merge commit '4f18a3b5799b9671f6efeacf99805c51768e359d' into review/liangent/ApiGetEntities .. Merge commit '4f18a3b5799b9671f6efeacf99805c51768e359d' into review/liangent/ApiGetEntities Change-Id: I164be284403f464bcb62fdbc7c0db6c93e18422e --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/88/72988/1 -- To view, visit https://gerrit.wikimedia.org/r/72988 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I164be284403f464bcb62fdbc7c0db6c93e18422e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] EXPERIMENTAL: Always set languagefallback in wikibase.RepoAp... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72987 Change subject: EXPERIMENTAL: Always set languagefallback in wikibase.RepoApi.js .. EXPERIMENTAL: Always set languagefallback in wikibase.RepoApi.js Change-Id: I19b1430a4f3e9588dbf4574173d94c79163ac6ab --- M lib/resources/wikibase.RepoApi/wikibase.RepoApi.js 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/87/72987/1 diff --git a/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js b/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js index cdc979b..dad9e2e 100644 --- a/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js +++ b/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js @@ -100,6 +100,7 @@ ids: ids, props: this._normalizeParam( props ), languages: this._normalizeParam( languages ), + languagefallback: '', sort: this._normalizeParam( sort ), dir: dir || undefined }; @@ -129,6 +130,7 @@ titles: this._normalizeParam( titles ), props: this._normalizeParam( props ), languages: this._normalizeParam( languages ), + languagefallback: '', sort: this._normalizeParam( sort ), dir: dir || undefined }; -- To view, visit https://gerrit.wikimedia.org/r/72987 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I19b1430a4f3e9588dbf4574173d94c79163ac6ab Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] EXPERIMENTAL VERSION OF Ic8ad24f49ba7fafe11e3dceb5d36e18d5b9... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72982 Change subject: EXPERIMENTAL VERSION OF Ic8ad24f49ba7fafe11e3dceb5d36e18d5b9ef19f .. EXPERIMENTAL VERSION OF Ic8ad24f49ba7fafe11e3dceb5d36e18d5b9ef19f Change-Id: Ic8ad24f49ba7fafe11e3dceb5d36e18d5b9ef190 --- M repo/includes/EntityView.php 1 file changed, 32 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/82/72982/1 diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php index 628e562..69efadf 100644 --- a/repo/includes/EntityView.php +++ b/repo/includes/EntityView.php @@ -67,6 +67,11 @@ protected $idFormatter; /** +* @var LanguageFallbackChain +*/ + protected $languageFallbackChain; + + /** * Maps entity types to the corresponding entity view. * FIXME: remove this stuff, big OCP violation * @@ -94,6 +99,8 @@ * @param IContextSource|null $context */ public function __construct( ValueFormatterFactory $valueFormatters, IContextSource $context = null ) { + global $wgUseSquid; + $this->valueFormatters = $valueFormatters; if ( !$context ) { @@ -103,6 +110,15 @@ // TODO: this need to be properly injected $this->idFormatter = WikibaseRepo::getDefaultInstance()->getIdFormatter(); + + $factory = WikibaseRepo::getDefaultInstance()->getLanguageFallbackChainFactory(); + if ( $wgUseSquid && $context->getUser()->isAnon() ) { + // Anonymous users share the same Squid cache, which is splitted by URL. + // That means we can't do anything except for what completely depends by URL such as &uselang=. + $this->languageFallbackChain = $factory->newFromLanguage( $context->getLanguage() ); + } else { + $this->languageFallbackChain = $factory->newFromContext( $context ); + } } /** @@ -810,6 +826,9 @@ $out->addJsConfigVars( 'wbEntityType', $entity->getType() ); $out->addJsConfigVars( 'wbDataLangName', Utils::fetchLanguageName( $langCode ) ); + // Some constant, but to avoid hard coding it everywhere + $out->addJsConfigVars( 'wbContextLanguageCode', LanguageFallbackChain::CONTEXT_LANGUAGE_CODE ); + // entity specific data $out->addJsConfigVars( 'wbEntityId', $this->getFormattedIdForEntity( $entity ) ); @@ -818,6 +837,9 @@ // TODO: use injected id formatter $serializationOptions = new EntitySerializationOptions( WikibaseRepo::getDefaultInstance()->getIdFormatter() ); + $serializationOptions->setLanguages( Utils::getLanguageCodes() + array( + LanguageFallbackChain::CONTEXT_LANGUAGE_CODE => $this->languageFallbackChain, + ) ); $serializerFactory = new SerializerFactory(); $serializer = $serializerFactory->newSerializerForObject( $entity, $serializationOptions ); @@ -832,7 +854,7 @@ $refFinder = new ReferencedEntitiesFinder( $entityLoader ); $usedEntityIds = $refFinder->findClaimLinks( $entity->getClaims() ); - $basicEntityInfo = static::getBasicEntityInfo( $entityLoader, $usedEntityIds, $langCode ); + $basicEntityInfo = static::getBasicEntityInfo( $entityLoader, $usedEntityIds, $langCode, $this->languageFallbackChain ); $out->addJsConfigVars( 'wbUsedEntities', @@ -850,9 +872,12 @@ * @param EntityLookup $entityLoader * @param EntityId[] $entityIds * @param string $langCode For the entity labels which will be included in one language only. +* @param LanguageFallbackChain $languageFallbackChain Set it to include labels to display for the given language fallback chain too. * @return array */ - protected static function getBasicEntityInfo( EntityLookup $entityLoader, array $entityIds, $langCode ) { + protected static function getBasicEntityInfo( + EntityLookup $entityLoader, array $entityIds, $langCode, LanguageFallbackChain $languageFallbackChain = null + ) { wfProfileIn( __METHOD__ ); $entityContentFactory = EntityContentFactory::singleton(); @@ -864,7 +889,11 @@ $serializationOptions = new EntitySerializationOptions( WikibaseRepo::getDefaultInstance()->getIdFormatter() ); $serializationOptions->setProps( array( 'labels', 'descriptions', 'datatype' ) ); - $serializationOptions->setLanguages( array( $langCode ) ); + $languages = array( $langCode )
[MediaWiki-commits] [Gerrit] TEST FOR UNIT TEST FAILURES - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72758 Change subject: TEST FOR UNIT TEST FAILURES .. TEST FOR UNIT TEST FAILURES Change-Id: I8355839c923fffbf4025926dd071f873b6a0a8e0 --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/58/72758/1 -- To view, visit https://gerrit.wikimedia.org/r/72758 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8355839c923fffbf4025926dd071f873b6a0a8e0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Allow mw.wikibase.label( ) to find labels written in variants - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72751 Change subject: Allow mw.wikibase.label( ) to find labels written in variants .. Allow mw.wikibase.label( ) to find labels written in variants Some hacky way is used here... Change-Id: Ib73d9090f2db481c5c3592f0eab17fa33d6cd1bc --- M client/includes/WikibaseLibrary.php 1 file changed, 15 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/51/72751/1 diff --git a/client/includes/WikibaseLibrary.php b/client/includes/WikibaseLibrary.php index e49a876..ff1142d 100644 --- a/client/includes/WikibaseLibrary.php +++ b/client/includes/WikibaseLibrary.php @@ -28,6 +28,8 @@ use Wikibase\Client\WikibaseClient; use Wikibase\Lib\Serializers\EntitySerializationOptions; use Wikibase\Lib\Serializers\SerializerFactory; +use Wikibase\LanguageFallbackChainFactory; +use Wikibase\Utils; class Scribunto_LuaWikibaseLibrary extends Scribunto_LuaLibraryBase { @@ -76,6 +78,19 @@ $serializerFactory = new SerializerFactory(); $opt = new EntitySerializationOptions( WikibaseClient::getDefaultInstance()->getEntityIdFormatter() ); + + // This is $wgContLang, not parser target language or anything else. + // See Scribunto_LuaLanguageLibrary::getContLangCode(). + global $wgContLang; + + // See mw.wikibase.lua. This is the only way to inject values into mw.wikibase.label( ), + // so any customized Lua modules can access labels of another entity written in another variant, + // unless we give them the ability to getEntity() any entity by specifying its ID, not just self. + $chain = WikibaseClient::getDefaultInstance()->getLanguageFallbackChainFactory()->newFromLanguage( + $wgContLang, LanguageFallbackChainFactory::FALLBACK_SELF | LanguageFallbackChainFactory::FALLBACK_VARIANTS + ); + $opt->setLanguages( Utils::getLanguageCodes() + array( $wgContLang->getCode() => $chain ) ); + $serializer = $serializerFactory->newSerializerForObject( $entityObject, $opt ); try { -- To view, visit https://gerrit.wikimedia.org/r/72751 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib73d9090f2db481c5c3592f0eab17fa33d6cd1bc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Merge commit '7504cae8da95126b6c1e883621504e1b56137f79' into... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72364 Change subject: Merge commit '7504cae8da95126b6c1e883621504e1b56137f79' into EntityViewHtml .. Merge commit '7504cae8da95126b6c1e883621504e1b56137f79' into EntityViewHtml Change-Id: Id1e0b5503bb383beb743d32a872b479f46f33326 --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/64/72364/1 -- To view, visit https://gerrit.wikimedia.org/r/72364 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id1e0b5503bb383beb743d32a872b479f46f33326 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] SerializationOptions: Avoid creating Language objects - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72354 Change subject: SerializationOptions: Avoid creating Language objects .. SerializationOptions: Avoid creating Language objects Change-Id: I8884ac5c90883628282c8406a474974dd53408c8 --- M lib/includes/serializers/SerializationOptions.php 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/54/72354/1 diff --git a/lib/includes/serializers/SerializationOptions.php b/lib/includes/serializers/SerializationOptions.php index a026d76..c33a129 100644 --- a/lib/includes/serializers/SerializationOptions.php +++ b/lib/includes/serializers/SerializationOptions.php @@ -174,8 +174,8 @@ // back-compat if ( is_numeric( $languageCode ) ) { $languageCode = $languageFallbackChain; - $languageFallbackChain = $this->getLanguageFallbackChainFactory()->newFromLanguage( - Language::factory( $languageCode ), LanguageFallbackChainFactory::FALLBACK_SELF + $languageFallbackChain = $this->getLanguageFallbackChainFactory()->newFromLanguageCode( + $languageCode, LanguageFallbackChainFactory::FALLBACK_SELF ); } -- To view, visit https://gerrit.wikimedia.org/r/72354 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8884ac5c90883628282c8406a474974dd53408c8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] LanguageFallbackChain: Avoid creating Language objects in so... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72353 Change subject: LanguageFallbackChain: Avoid creating Language objects in some cases .. LanguageFallbackChain: Avoid creating Language objects in some cases Change-Id: I7c8c27026310adeeb8530de508e3fddb02fae557 --- M lib/includes/LanguageFallbackChain.php M lib/tests/phpunit/LanguageFallbackChainTest.php 2 files changed, 10 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/53/72353/1 diff --git a/lib/includes/LanguageFallbackChain.php b/lib/includes/LanguageFallbackChain.php index ee91987..795dbf2 100644 --- a/lib/includes/LanguageFallbackChain.php +++ b/lib/includes/LanguageFallbackChain.php @@ -66,8 +66,8 @@ public function extractPreferredValue( $data ) { foreach ( $this->chain as $languageWithConversion ) { - $fetchCode = $languageWithConversion->getFetchLanguage()->getCode(); - $languageCode = $languageWithConversion->getLanguage()->getCode(); + $fetchCode = $languageWithConversion->getFetchLanguageCode(); + $languageCode = $languageWithConversion->getLanguageCode(); if ( isset( $data[$fetchCode] ) ) { return array( diff --git a/lib/tests/phpunit/LanguageFallbackChainTest.php b/lib/tests/phpunit/LanguageFallbackChainTest.php index 455c981..8a81978 100644 --- a/lib/tests/phpunit/LanguageFallbackChainTest.php +++ b/lib/tests/phpunit/LanguageFallbackChainTest.php @@ -26,7 +26,7 @@ */ public function testExtractPreferredValue( $lang, $mode, $data, $expected ) { $factory = new LanguageFallbackChainFactory(); - $chain = $factory->newFromLanguage( \Language::factory( $lang ), $mode ); + $chain = $factory->newFromLanguageCode( $lang, $mode ); $resolved = $chain->extractPreferredValue( $data ); @@ -38,6 +38,8 @@ 'en' => 'foo', 'nl' => 'bar', 'zh-cn' => '测试', + 'lzh' => '試', + 'zh-classical' => '驗', ); return array( @@ -46,6 +48,11 @@ 'language' => 'en', 'source' => 'en', ) ), + array( 'zh-classical', LanguageFallbackChainFactory::FALLBACK_ALL, $data, array( + 'value' => '試', + 'language' => 'lzh', + 'source' => 'lzh', + ) ), array( 'nl', LanguageFallbackChainFactory::FALLBACK_ALL, $data, array( 'value' => 'bar', 'language' => 'nl', -- To view, visit https://gerrit.wikimedia.org/r/72353 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7c8c27026310adeeb8530de508e3fddb02fae557 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] LanguageFallbackChain: Avoid creating Language objects in so... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72352 Change subject: LanguageFallbackChain: Avoid creating Language objects in some cases .. LanguageFallbackChain: Avoid creating Language objects in some cases Change-Id: Ief3adf61cfa24ee58f6d2a6eb99d5ba6fe56a098 --- M lib/includes/LanguageFallbackChainFactory.php M lib/tests/phpunit/LanguageFallbackChainFactoryTest.php 2 files changed, 111 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/52/72352/1 diff --git a/lib/includes/LanguageFallbackChainFactory.php b/lib/includes/LanguageFallbackChainFactory.php index 5bcfda1..85cd28f 100644 --- a/lib/includes/LanguageFallbackChainFactory.php +++ b/lib/includes/LanguageFallbackChainFactory.php @@ -84,32 +84,69 @@ } /** -* Build fallback chain array for a given language. +* Get the fallback chain based a single language code, and specified fallback level. * -* @param Language $language +* @param string $language +* @param $mode bitfield of self::FALLBACK_* +* +* @return LanguageFallbackChain +*/ + public function newFromLanguageCode( $languageCode, $mode = self::FALLBACK_ALL ) { + + $validatedLanguageCode = LanguageWithConversion::validateLanguageCode( $languageCode ); + if ( $validatedLanguageCode === null ) { + throw new MWException( __METHOD__ . ': invalid language code ' . $languageCode ); + } + $languageCode = $validatedLanguageCode; + + if ( isset( $this->languageCache[$languageCode][$mode] ) ) { + return $this->languageCache[$languageCode][$mode]; + } + + $chain = $this->buildFromLanguage( $languageCode, $mode ); + $languageFallbackChain = new LanguageFallbackChain( $chain ); + + $this->languageCache[$languageCode][$mode] = $languageFallbackChain; + + return $languageFallbackChain; + } + + /** +* Build fallback chain array for a given language or validated language code. +* +* @param $language Language object or language code as string * @param $mode bitfield of self::FALLBACK_* * @param LanguageFallbackChain[] $chain for recursive calls * @param array $fetched for recursive calls * * @return LanguageWithConversion[] */ - public function buildFromLanguage( Language $language, $mode, &$chain = array(), &$fetched = array() ) { + public function buildFromLanguage( $language, $mode, &$chain = array(), &$fetched = array() ) { wfProfileIn( __METHOD__ ); + if ( is_string( $language ) ) { + $languageCode = $language; + } else { + $languageCode = $language->getCode(); + } + if ( $mode & self::FALLBACK_SELF ) { - if ( !isset( $fetched[$language->getCode()] ) ) { + if ( !isset( $fetched[$languageCode] ) ) { $chain[] = LanguageWithConversion::factory( $language ); - $fetched[$language->getCode()] = true; + $fetched[$languageCode] = true; } } if ( $mode & self::FALLBACK_VARIANTS ) { + if ( is_string( $language ) ) { + $language = Language::factory( $language ); + } $parentLanguage = $language->getParentLanguage(); if ( $parentLanguage ) { // It's less likely to trigger conversion mistakes by converting // zh-tw to zh-hk first instead of converting zh-cn to zh-tw. $variantFallbacks = $parentLanguage->getConverter() - ->getVariantFallbacks( $language->getCode() ); + ->getVariantFallbacks( $languageCode ); if ( is_array( $variantFallbacks ) ) { $variants = array_unique( array_merge( $variantFallbacks, $parentLanguage->getVariants() @@ -119,13 +156,12 @@ } foreach ( $variants as $variant ) { - $variantLanguage = Language::factory( $variant ); - if ( isset( $fetched[$variantLanguage->getCode()] ) ) { + if ( isset( $fetched[$variant] ) ) {
[MediaWiki-commits] [Gerrit] LanguageWithConversion: Allow lazy language object construction - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72320 Change subject: LanguageWithConversion: Allow lazy language object construction .. LanguageWithConversion: Allow lazy language object construction It seems language object construction is too expensive. Change-Id: I4ae84a8c2dc40874733d64866db4076ff8f43fd8 --- M lib/includes/LanguageWithConversion.php M lib/tests/phpunit/LanguageWithConversionTest.php 2 files changed, 157 insertions(+), 37 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/20/72320/1 diff --git a/lib/includes/LanguageWithConversion.php b/lib/includes/LanguageWithConversion.php index 5528e75..a234dd0 100644 --- a/lib/includes/LanguageWithConversion.php +++ b/lib/includes/LanguageWithConversion.php @@ -33,7 +33,9 @@ static protected $objectCache = array(); protected $language; + protected $languageCode; protected $sourceLanguage; + protected $sourceLanguageCode; protected $parentLanguage; protected $translateCache = array(); @@ -42,50 +44,108 @@ /** * Constructor. * -* @param $language Language -* @param $sourceLanguage null|Language -* @param $parentLanguage null|Language +* @param null|Language $language +* @param string $languageCode +* @param null|Language $sourceLanguage +* @param null|string $sourceLanguageCode +* @param null|Language $parentLanguage */ - protected function __construct( Language $language, $sourceLanguage, $parentLanguage ) { + protected function __construct( $language, $languageCode, $sourceLanguage, $sourceLanguageCode, $parentLanguage ) { $this->language = $language; + $this->languageCode = $languageCode; $this->sourceLanguage = $sourceLanguage; + $this->sourceLanguageCode = $sourceLanguageCode; $this->parentLanguage = $parentLanguage; + } + + /** +* Validate a language code. Logic taken from class Language. +* +* @param string $code Language code +* +* @return string|null Validated and normalized code, or null on invalid code. +*/ + private static function validateLanguageCode( $code ) { + global $wgDummyLanguageCodes; + + if ( isset( $wgDummyLanguageCodes[$code] ) ) { + $code = $wgDummyLanguageCodes[$code]; + } + + if ( !Language::isValidCode( $code ) + || strcspn( $code, ":/\\\000" ) !== strlen( $code ) + ) { + return null; + } + + return $code; } /** * Get a LanguageWithConversion object. * -* @param $language Language: Language for this object -* @param $sourceLanguage null|Language: -* Source language if this is a converted language, or null +* @param $language Language|string: Language (code) for this object +* @param $sourceLanguage null|Language|string: +* Source language (code) if this is a converted language, or null * @return LanguageWithConversion */ - public static function factory( Language $language, $sourceLanguage = null ) { - $sourceCode = $sourceLanguage ? $sourceLanguage->getCode() : ''; - if ( isset( self::$objectCache[$language->getCode()][$sourceCode] ) ) { - return self::$objectCache[$language->getCode()][$sourceCode]; + public static function factory( $language, $sourceLanguage = null ) { + if ( is_string( $language ) ) { + $languageCode = self::validateLanguageCode( $language ); + if ( $languageCode === null ) { + throw new MWException( __METHOD__ . ': invalid language code ' . $language ); + } + $language = null; + } else { + $languageCode = $language->getCode(); } - if ( $sourceLanguage ) { - $parentLanguage = $language->getParentLanguage(); - $sourceParentLanguage = $sourceLanguage->getParentLanguage(); - if ( !$parentLanguage || !$sourceParentLanguage ) { - throw new MWException( __METHOD__ . - ': either $language or $sourceLanguage does not support conversion.' - ); + if ( is_string( $sourceLanguage ) ) { + $sourceLanguageCode = self::validateLanguageCode( $sourceLanguage ); + if ( $sourceLanguageCode === nul
[MediaWiki-commits] [Gerrit] ApiGetEntities now accepts a new parameter, contextlanguage. - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72260 Change subject: ApiGetEntities now accepts a new parameter, contextlanguage. .. ApiGetEntities now accepts a new parameter, contextlanguage. API calls from Web UI should send the context language fallback chain info back from mw.config.get( 'wbContextLanguage' ), to receive multilingual data for what their context wants. Change-Id: Id62fdd16187c79549328711ded5265802bc9453a --- M repo/includes/api/GetEntities.php 1 file changed, 35 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/60/72260/1 diff --git a/repo/includes/api/GetEntities.php b/repo/includes/api/GetEntities.php index 9969088..b644bde 100644 --- a/repo/includes/api/GetEntities.php +++ b/repo/includes/api/GetEntities.php @@ -3,6 +3,7 @@ namespace Wikibase\Api; use ApiBase; +use ApiMain; use MWException; use Wikibase\Lib\Serializers\EntitySerializationOptions; @@ -13,6 +14,8 @@ use Wikibase\EntityId; use Wikibase\Item; use Wikibase\EntityContentFactory; +use Wikibase\LanguageFallbackChain; +use Wikibase\LanguageFallbackChainSerializer; /** * API module to get the data for one or more Wikibase entities. @@ -28,6 +31,22 @@ * @author Jeroen De Dauw < jeroended...@gmail.com > */ class GetEntities extends ApiWikibase { + + /** +* @var LanguageFallbackChainSerializer +*/ + protected $languageFallbackChainSerializer; + + /** +* Constructor. +* +* @since 0.4 +*/ + public function __construct( ApiMain $mainModule, $moduleName, $modulePrefix = '' ) { + parent::__construct( $mainModule, $moduleName, $modulePrefix ); + + $this->languageFallbackChainSerializer = new LanguageFallbackChainSerializer(); + } /** * @see \ApiBase::execute() @@ -178,7 +197,14 @@ // TODO: inject id formatter $options = new EntitySerializationOptions( WikibaseRepo::getDefaultInstance()->getIdFormatter() ); - $options->setLanguages( $params['languages'] ); + $languages = $params['languages']; + if ( $params['contextlanguage'] !== '' ) { + $chain = $this->languageFallbackChainSerializer->unserialize( $params['contextlanguage'] ); + if ( $chain ) { + $languages[LanguageFallbackChain::CONTEXT_LANGUAGE_CODE] = $chain; + } + } + $options->setLanguages( $languages ); $options->setSortDirection( $params['dir'] ); $options->setProps( $props ); $options->setIndexTags( $this->getResult()->getIsRawMode() ); @@ -247,6 +273,11 @@ ApiBase::PARAM_TYPE => Utils::getLanguageCodes(), ApiBase::PARAM_ISMULTI => true, ), + 'contextlanguage' => array( + ApiBase::PARAM_TYPE => 'string', + ApiBase::PARAM_DFLT => '', + ApiBase::PARAM_ISMULTI => false, + ), ) ); } @@ -276,6 +307,9 @@ 'languages' => array( 'By default the internationalized values are returned in all available languages.', 'This parameter allows filtering these down to one or more languages by providing one or more language codes.' ), + 'contextlanguage' => array( 'Serialized form of context language fallback chain to fetch values.', + "Taken from mw.config.get( 'wbContextLanguage' ), or don't send one for standalone requests.", + ), ) ); } -- To view, visit https://gerrit.wikimedia.org/r/72260 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id62fdd16187c79549328711ded5265802bc9453a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add a new language code, qqc, for data based on current context - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72258 Change subject: Add a new language code, qqc, for data based on current context .. Add a new language code, qqc, for data based on current context Change-Id: Id0eef45099469771d4d50787c4083eb238c21690 --- M lib/includes/LanguageFallbackChain.php 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/58/72258/1 diff --git a/lib/includes/LanguageFallbackChain.php b/lib/includes/LanguageFallbackChain.php index ee91987..03da481 100644 --- a/lib/includes/LanguageFallbackChain.php +++ b/lib/includes/LanguageFallbackChain.php @@ -30,6 +30,11 @@ class LanguageFallbackChain { /** +* Pseudo language code used to identify a fallback chain initialized from current context. +*/ + const CONTEXT_LANGUAGE_CODE = 'qqc'; + + /** * @var LanguageWithConversion[] */ private $chain = array(); -- To view, visit https://gerrit.wikimedia.org/r/72258 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id0eef45099469771d4d50787c4083eb238c21690 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Merge commit '66f9556e4c1d4784b32896cb479de4618820695d'; com... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72257 Change subject: Merge commit '66f9556e4c1d4784b32896cb479de4618820695d'; commit 'a92d541e52090bffdfd7a6e9cac70f877ec1aa22' into merge-Serializer-EntityView .. Merge commit '66f9556e4c1d4784b32896cb479de4618820695d'; commit 'a92d541e52090bffdfd7a6e9cac70f877ec1aa22' into merge-Serializer-EntityView Change-Id: Idbbb5a6563fdbe7ea2190dd3a9c15b12ce07bbe0 --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/57/72257/1 -- To view, visit https://gerrit.wikimedia.org/r/72257 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idbbb5a6563fdbe7ea2190dd3a9c15b12ce07bbe0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] New class LanguageFallbackChainSerializer - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72256 Change subject: New class LanguageFallbackChainSerializer .. New class LanguageFallbackChainSerializer Change-Id: I65d69c8b12fa4e754b02e95697a754622f06bf24 --- M lib/WikibaseLib.classes.php A lib/includes/LanguageFallbackChainSerializer.php A lib/tests/phpunit/LanguageFallbackChainSerializerTest.php 3 files changed, 203 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/56/72256/1 diff --git a/lib/WikibaseLib.classes.php b/lib/WikibaseLib.classes.php index 64893a8..56f4e40 100644 --- a/lib/WikibaseLib.classes.php +++ b/lib/WikibaseLib.classes.php @@ -42,6 +42,7 @@ 'Wikibase\DiffView' => 'includes/DiffView.php', 'Wikibase\LanguageFallbackChain' => 'includes/LanguageFallbackChain.php', 'Wikibase\LanguageFallbackChainFactory' => 'includes/LanguageFallbackChainFactory.php', + 'Wikibase\LanguageFallbackChainSerializer' => 'includes/LanguageFallbackChainSerializer.php', 'Wikibase\LanguageWithConversion' => 'includes/LanguageWithConversion.php', 'Wikibase\Lib\GuidGenerator' => 'includes/GuidGenerator.php', 'Wikibase\Lib\V4GuidGenerator' => 'includes/GuidGenerator.php', diff --git a/lib/includes/LanguageFallbackChainSerializer.php b/lib/includes/LanguageFallbackChainSerializer.php new file mode 100644 index 000..36318b6 --- /dev/null +++ b/lib/includes/LanguageFallbackChainSerializer.php @@ -0,0 +1,107 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since 0.4 + * + * @file + * @ingroup WikibaseLib + * + * @licence GNU GPL v2+ + */ +class LanguageFallbackChainSerializer { + + /** +* Serialize a language fallback chain into a string. JSON is used now, but +* any external component is not expected to understand the serialized form. +* +* @param LanguageFallbackChain $languageFallbackChain +* +* @return string serialized form +*/ + public function serialize( LanguageFallbackChain $languageFallbackChain ) { + wfProfileIn( __METHOD__ ); + $data = array(); + + // We sacrifice readability for length here, as the serialized form may be passed around in URLs. + foreach ( $languageFallbackChain->getFallbackChain() as $item ) { + $elem = array( $item->getLanguage()->getCode() ); + + $sourceLanguage = $item->getSourceLanguage(); + if ( $sourceLanguage ) { + $elem[] = $sourceLanguage->getCode(); + } + + $data[] = implode( ':', $elem ); + } + + wfProfileOut( __METHOD__ ); + return implode( '|', $data ); + } + + /** +* Unserialize a language fallback chain from a previous serializeLanguageFallbackChain output. +* +* @param string $serialized +* +* @return LanguageFallbackChain|null on bad input +*/ + public function unserialize( $serialized ) { + wfProfileIn( __METHOD__ ); + $data = explode( '|', $serialized ); + $chain = array(); + + foreach ( $data as $itemString ) { + $item = explode( ':', $itemString ); + $langCode = $item[0]; + + if ( !isset( $item[1] ) ) { + $sourceLangCode = false; + } else { + $sourceLangCode = $item[1]; + } + + try { + $language = Language::factory( $langCode ); + if ( $sourceLangCode ) { + $sourceLanguage = Language::factory( $sourceLangCode ); + } else { + $sourceLanguage = null; + } + $chainItem = LanguageWithConversion::factory( $language, $sourceLanguage ); + } catch ( MWException $e ) { + wfProfileOut( __METHOD__ ); + return null; + } + + $chain[] = $chainItem; + } + + $languageFallbackChain = new LanguageFallbackChain( $chain ); + wfProfileOut( __METHOD__ ); + return $languageFallbackChain; + } + +} diff --git a/lib/tests/phpunit/LanguageFallbackChainSerializerTest.php b/lib/tests/phpunit/LanguageFallbackChainSerializerTest.php new file mode 100644 index 000..1b33798 --- /dev/null +++ b/lib/tests/phpunit/LanguageFallbackChainSe
[MediaWiki-commits] [Gerrit] Add message docs for I0bf124b436d2cd076a5361102123c0a21c6c5b3b - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72255 Change subject: Add message docs for I0bf124b436d2cd076a5361102123c0a21c6c5b3b .. Add message docs for I0bf124b436d2cd076a5361102123c0a21c6c5b3b Change-Id: I4e31b28d546b6e416c153351893ed8c1a47ccadc --- M repo/Wikibase.i18n.php 1 file changed, 16 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/55/72255/1 diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index 8d27bf7..0f4176d 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -882,6 +882,22 @@ 'wikibase-entitydata-unsupported-format' => 'Error shown when the requested output format is not supported for entity data (HTTP error 415).', 'wikibase-entitydata-title' => 'Title shown on the special page when a form or text is presented', 'wikibase-entitydata-text' => 'Explanatory text shown on the special page.', + 'special-mylanguagefallbackchain' => '{{doc-special|MyLanguageFallbackChain}} +The special page display the language fallback chain used to display Wikibase data for current context.', + 'wikibase-mylanguagefallbackchain-text' => 'Explanatory text shown on the special page.', + 'wikibase-mylanguagefallbackchain-babel' => 'More explanatory text shown on the special page. Only displayed when Extension:Babel is installed and the user is logged in.', + 'wikibase-mylanguagefallbackchain-verbatim-item' => 'A "verbatim" (taken from database and displayed as-is) fallback chain item. + +Parameters: +* $1 - Language code +* $2 - Language name', + 'wikibase-mylanguagefallbackchain-converted-item' => 'A "converted" (taken from data in another language and converted to another language on display) fallback chain item. + +Parameters: +* $1 - Language code +* $2 - Language name +* $3 - Source language code +* $4 - Source language name', 'wikibase-api-aliases-invalid-list' => '!!DO NOT TRANSLATE!! This is an error message for a situation where the arguments to the API is inconsistent. Usually this should never be shown to the user, unless there are some exceptional error conditions. {{doc-important|Do not translate the names of the arguments: "set", "add" and "remove"}}', -- To view, visit https://gerrit.wikimedia.org/r/72255 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4e31b28d546b6e416c153351893ed8c1a47ccadc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Include preferred label for used entities on EntityView - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72226 Change subject: Include preferred label for used entities on EntityView .. Include preferred label for used entities on EntityView * A new pseudo language code, qqc, is added, for data based on current context * EntityView now initializes a fallback chain for current context, and send it for serialization, to have wbUsedEntities include some labels for view by final users. * A helper JS variable, wbContextLanguageCode, is added, to identify labels for page views on client side. Change-Id: Ic8ad24f49ba7fafe11e3dceb5d36e18d5b9ef19f --- M lib/includes/LanguageFallbackChain.php M repo/includes/EntityView.php 2 files changed, 19 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/26/72226/1 diff --git a/lib/includes/LanguageFallbackChain.php b/lib/includes/LanguageFallbackChain.php index ee91987..03da481 100644 --- a/lib/includes/LanguageFallbackChain.php +++ b/lib/includes/LanguageFallbackChain.php @@ -30,6 +30,11 @@ class LanguageFallbackChain { /** +* Pseudo language code used to identify a fallback chain initialized from current context. +*/ + const CONTEXT_LANGUAGE_CODE = 'qqc'; + + /** * @var LanguageWithConversion[] */ private $chain = array(); diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php index 628e562..a20278d 100644 --- a/repo/includes/EntityView.php +++ b/repo/includes/EntityView.php @@ -810,6 +810,9 @@ $out->addJsConfigVars( 'wbEntityType', $entity->getType() ); $out->addJsConfigVars( 'wbDataLangName', Utils::fetchLanguageName( $langCode ) ); + // Some constant, but to avoid hard coding it everywhere + $out->addJsConfigVars( 'wbContextLanguageCode', LanguageFallbackChain::CONTEXT_LANGUAGE_CODE ); + // entity specific data $out->addJsConfigVars( 'wbEntityId', $this->getFormattedIdForEntity( $entity ) ); @@ -832,7 +835,7 @@ $refFinder = new ReferencedEntitiesFinder( $entityLoader ); $usedEntityIds = $refFinder->findClaimLinks( $entity->getClaims() ); - $basicEntityInfo = static::getBasicEntityInfo( $entityLoader, $usedEntityIds, $langCode ); + $basicEntityInfo = static::getBasicEntityInfo( $entityLoader, $usedEntityIds, $langCode, $this->getContext() ); $out->addJsConfigVars( 'wbUsedEntities', @@ -850,9 +853,12 @@ * @param EntityLookup $entityLoader * @param EntityId[] $entityIds * @param string $langCode For the entity labels which will be included in one language only. +* @param IContextSource $context Set it to include labels to display for the given context too. * @return array */ - protected static function getBasicEntityInfo( EntityLookup $entityLoader, array $entityIds, $langCode ) { + protected static function getBasicEntityInfo( + EntityLookup $entityLoader, array $entityIds, $langCode, IContextSource $context = null + ) { wfProfileIn( __METHOD__ ); $entityContentFactory = EntityContentFactory::singleton(); @@ -864,7 +870,12 @@ $serializationOptions = new EntitySerializationOptions( WikibaseRepo::getDefaultInstance()->getIdFormatter() ); $serializationOptions->setProps( array( 'labels', 'descriptions', 'datatype' ) ); - $serializationOptions->setLanguages( array( $langCode ) ); + $languages = array( $langCode ); + if ( $context ) { + $factory = WikibaseRepo::getDefaultInstance()->getLanguageFallbackChainFactory(); + $languages[LanguageFallbackChain::CONTEXT_LANGUAGE_CODE] = $factory->newFromContext( $context ); + } + $serializationOptions->setLanguages( $languages ); foreach( $entities as $prefixedId => $entity ) { if( $entity === null ) { -- To view, visit https://gerrit.wikimedia.org/r/72226 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic8ad24f49ba7fafe11e3dceb5d36e18d5b9ef19f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Label serialization now accepts LanguageFallbackChain as the... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72225 Change subject: Label serialization now accepts LanguageFallbackChain as the language option .. Label serialization now accepts LanguageFallbackChain as the language option Labels in all serialized formats will get a new field 'source-language', to indicate the language where this label was fetched. Change-Id: Iec62d6817e3007e1982db65b5031ec09ecda3374 --- M lib/includes/serializers/EntitySerializer.php M lib/includes/serializers/LabelSerializer.php M lib/tests/phpunit/serializers/EntitySerializerBaseTest.php M lib/tests/phpunit/serializers/LabelSerializerTest.php 4 files changed, 87 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/25/72225/1 diff --git a/lib/includes/serializers/EntitySerializer.php b/lib/includes/serializers/EntitySerializer.php index f41e5f6..7ad4045 100644 --- a/lib/includes/serializers/EntitySerializer.php +++ b/lib/includes/serializers/EntitySerializer.php @@ -89,7 +89,19 @@ break; case 'labels': $labelSerializer = new LabelSerializer( $this->options ); - $labels = $entity->getLabels( $this->options->getLanguages() ); + $allLabels = $entity->getLabels(); + $labels = array(); + $languageFallbackChains = $this->options->getLanguageFallbackChains(); + if ( $languageFallbackChains ) { + foreach ( $languageFallbackChains as $languageCode => $languageFallbackChain ) { + $data = $languageFallbackChain->extractPreferredValue( $allLabels ); + if ( $data !== null ) { + $labels[$languageCode] = $data; + } + } + } else { + $labels = $allLabels; + } $serialization['labels'] = $labelSerializer->getSerialized( $labels ); break; case 'claims': diff --git a/lib/includes/serializers/LabelSerializer.php b/lib/includes/serializers/LabelSerializer.php index 13094f8..0789c27 100644 --- a/lib/includes/serializers/LabelSerializer.php +++ b/lib/includes/serializers/LabelSerializer.php @@ -73,12 +73,23 @@ $value = array(); $idx = 0; - foreach ( $labels as $languageCode => $label ) { + foreach ( $labels as $languageCode => $labelData ) { $key = $this->options->shouldUseKeys() ? $languageCode : $idx++; + if ( is_array( $labelData ) ) { + $label = $labelData['value']; + $labelLanguageCode = $labelData['language']; + $labelSourceLanguageCode = $labelData['source']; + } else { + // back-compat + $label = $labelData; + $labelLanguageCode = $languageCode; + $labelSourceLanguageCode = $languageCode; + } $valueKey = ( $label === '' ) ? 'removed' : 'value'; $value[$key] = array( - 'language' => $languageCode, - $valueKey => $label + 'language' => $labelLanguageCode, + 'source-language' => $labelSourceLanguageCode, + $valueKey => $label, ); } diff --git a/lib/tests/phpunit/serializers/EntitySerializerBaseTest.php b/lib/tests/phpunit/serializers/EntitySerializerBaseTest.php index 0abafa3..6c7d069 100644 --- a/lib/tests/phpunit/serializers/EntitySerializerBaseTest.php +++ b/lib/tests/phpunit/serializers/EntitySerializerBaseTest.php @@ -122,10 +122,12 @@ 'en' => array( 'value' => 'foo', 'language' => 'en', + 'source-language' => 'en', ), 'de' => array( 'v
[MediaWiki-commits] [Gerrit] Include preferred label for used entities on EntityView - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72139 Change subject: Include preferred label for used entities on EntityView .. Include preferred label for used entities on EntityView * A new pseudo language code, qqc, is added, for data based on current context * Label serialization now accepts LanguageFallbackChain as the language option * EntityView now makes use of these, by initializing a fallback chain for the current context, and send it for serialization, to have wbUsedEntities include some labels for view by final users * A helper JS variable, wbContextLanguageCode, is added, to identify labels for page views on client side. Change-Id: I314356382c8076a355e998481fc4d3f30867d8cd --- M lib/includes/LanguageFallbackChain.php M lib/includes/serializers/EntitySerializer.php M lib/includes/serializers/LabelSerializer.php M lib/tests/phpunit/serializers/EntitySerializerBaseTest.php M lib/tests/phpunit/serializers/LabelSerializerTest.php M repo/includes/EntityView.php 6 files changed, 106 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/39/72139/1 diff --git a/lib/includes/LanguageFallbackChain.php b/lib/includes/LanguageFallbackChain.php index ee91987..03da481 100644 --- a/lib/includes/LanguageFallbackChain.php +++ b/lib/includes/LanguageFallbackChain.php @@ -30,6 +30,11 @@ class LanguageFallbackChain { /** +* Pseudo language code used to identify a fallback chain initialized from current context. +*/ + const CONTEXT_LANGUAGE_CODE = 'qqc'; + + /** * @var LanguageWithConversion[] */ private $chain = array(); diff --git a/lib/includes/serializers/EntitySerializer.php b/lib/includes/serializers/EntitySerializer.php index f41e5f6..7ad4045 100644 --- a/lib/includes/serializers/EntitySerializer.php +++ b/lib/includes/serializers/EntitySerializer.php @@ -89,7 +89,19 @@ break; case 'labels': $labelSerializer = new LabelSerializer( $this->options ); - $labels = $entity->getLabels( $this->options->getLanguages() ); + $allLabels = $entity->getLabels(); + $labels = array(); + $languageFallbackChains = $this->options->getLanguageFallbackChains(); + if ( $languageFallbackChains ) { + foreach ( $languageFallbackChains as $languageCode => $languageFallbackChain ) { + $data = $languageFallbackChain->extractPreferredValue( $allLabels ); + if ( $data !== null ) { + $labels[$languageCode] = $data; + } + } + } else { + $labels = $allLabels; + } $serialization['labels'] = $labelSerializer->getSerialized( $labels ); break; case 'claims': diff --git a/lib/includes/serializers/LabelSerializer.php b/lib/includes/serializers/LabelSerializer.php index 13094f8..0789c27 100644 --- a/lib/includes/serializers/LabelSerializer.php +++ b/lib/includes/serializers/LabelSerializer.php @@ -73,12 +73,23 @@ $value = array(); $idx = 0; - foreach ( $labels as $languageCode => $label ) { + foreach ( $labels as $languageCode => $labelData ) { $key = $this->options->shouldUseKeys() ? $languageCode : $idx++; + if ( is_array( $labelData ) ) { + $label = $labelData['value']; + $labelLanguageCode = $labelData['language']; + $labelSourceLanguageCode = $labelData['source']; + } else { + // back-compat + $label = $labelData; + $labelLanguageCode = $languageCode; + $labelSourceLanguageCode = $languageCode; + } $valueKey = ( $label === '' ) ? 'removed' : 'value'; $value[$key] = array( - 'language' => $languageCode, - $valueKey => $label + 'language' => $labelLanguageCode, +
[MediaWiki-commits] [Gerrit] (bug 43547) New language variant en-x-piglatin DO NOT MERGE - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72053 Change subject: (bug 43547) New language variant en-x-piglatin DO NOT MERGE .. (bug 43547) New language variant en-x-piglatin DO NOT MERGE Bug: 43547 Change-Id: I7fa2d85d6364958c5138366e8b4504a2697a8731 --- M includes/DefaultSettings.php M languages/Language.php A languages/classes/LanguageEn.php 3 files changed, 72 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/53/72053/1 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index f9d280f..5713063 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2451,7 +2451,7 @@ * $wgDisabledVariants[] = 'zh-my'; * @endcode */ -$wgDisabledVariants = array(); +$wgDisabledVariants = array( 'en-x-piglatin' ); /** * Like $wgArticlePath, but on multi-variant wikis, this provides a diff --git a/languages/Language.php b/languages/Language.php index e5cab05..b6d143e 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -409,11 +409,7 @@ * @return String Name of the language class */ public static function classFromCode( $code ) { - if ( $code == 'en' ) { - return 'Language'; - } else { - return 'Language' . str_replace( '-', '_', ucfirst( $code ) ); - } + return 'Language' . str_replace( '-', '_', ucfirst( $code ) ); } /** diff --git a/languages/classes/LanguageEn.php b/languages/classes/LanguageEn.php new file mode 100644 index 000..c3d13a0 --- /dev/null +++ b/languages/classes/LanguageEn.php @@ -0,0 +1,70 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup Language + */ + +require_once __DIR__ . '/../LanguageConverter.php'; + +class EnConverter extends LanguageConverter { + + function loadDefaultTables() { + $this->mTables = array( + 'en' => new ReplacementArray(), + 'en-x-piglatin' => new ReplacementArray(), + ); + } + + /** +* It translates text into Pig Latin. +* +* @param $text string +* @param $toVariant string +* +* @throws MWException +* @return string +*/ + function translate( $text, $toVariant ) { + if ( $toVariant === 'en-x-piglatin' ) { + return '!PigLatin^' . strtoupper( $text ) . '^PigLatin!'; + } else { + return $text; + } + } + +} + +/** + * English + * + * @ingroup Language + */ +class LanguageEn extends Language { + + function __construct() { + global $wgHooks; + + parent::__construct(); + + $this->mConverter = new EnConverter( $this, 'en', array( 'en', 'en-x-piglatin' ) ); + $wgHooks['PageContentSaveComplete'][] = $this->mConverter; + } + +} -- To view, visit https://gerrit.wikimedia.org/r/72053 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7fa2d85d6364958c5138366e8b4504a2697a8731 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix documentation of PropertyParserFunction::render() - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72006 Change subject: Fix documentation of PropertyParserFunction::render() .. Fix documentation of PropertyParserFunction::render() Change-Id: Ib888cd9dc23cfb50e01f4bab301b11fa1cfc7a42 --- M client/includes/parserhooks/PropertyParserFunction.php 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/06/72006/1 diff --git a/client/includes/parserhooks/PropertyParserFunction.php b/client/includes/parserhooks/PropertyParserFunction.php index 4d09ab9..ff669f5 100644 --- a/client/includes/parserhooks/PropertyParserFunction.php +++ b/client/includes/parserhooks/PropertyParserFunction.php @@ -161,8 +161,9 @@ * @since 0.4 * * @param \Parser &$parser +* @param string $propertyLabel property label or ID (pXXX) * -* @return string +* @return array */ public static function render( \Parser $parser, $propertyLabel ) { wfProfileIn( __METHOD__ ); -- To view, visit https://gerrit.wikimedia.org/r/72006 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib888cd9dc23cfb50e01f4bab301b11fa1cfc7a42 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Disable language conversion for echoed sortkeys in defaultso... - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72003 Change subject: Disable language conversion for echoed sortkeys in defaultsort errors. .. Disable language conversion for echoed sortkeys in defaultsort errors. Change-Id: I24ac06687df126b59a3eddeb4ed00b2ca0ee22e9 --- M includes/parser/CoreParserFunctions.php 1 file changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/03/72003/1 diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 2b84358..511460d 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -864,8 +864,9 @@ } else { return '' . wfMessage( 'duplicate-defaultsort', - wfEscapeWikiText( $old ), // Message should be parsed, but these params should only be escaped. - wfEscapeWikiText( $text ) + // Message should be parsed, but these params should only be escaped. + $parser->getConverterLanguage()->getConverter()->markNoConversion( wfEscapeWikiText( $old ) ), + $parser->getConverterLanguage()->getConverter()->markNoConversion( wfEscapeWikiText( $text ) ) )->inContentLanguage()->text() . ''; } -- To view, visit https://gerrit.wikimedia.org/r/72003 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I24ac06687df126b59a3eddeb4ed00b2ca0ee22e9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use requested variant language instead of target language to... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71996 Change subject: Use requested variant language instead of target language to fetch labels .. Use requested variant language instead of target language to fetch labels Change-Id: I5a461251c5c4b0ff6c5abd701707c5c04910fadf --- M client/includes/parserhooks/PropertyParserFunction.php 1 file changed, 25 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/96/71996/1 diff --git a/client/includes/parserhooks/PropertyParserFunction.php b/client/includes/parserhooks/PropertyParserFunction.php index 4d09ab9..3a15074 100644 --- a/client/includes/parserhooks/PropertyParserFunction.php +++ b/client/includes/parserhooks/PropertyParserFunction.php @@ -2,6 +2,7 @@ namespace Wikibase; +use Language; use Wikibase\Client\WikibaseClient; use Wikibase\DataModel\SimpleSiteLink; use Wikibase\Lib\SnakFormatter; @@ -188,7 +189,18 @@ $propertyLabelResolver = $wikibaseClient->getStore()->getPropertyLabelResolver(); $formatter = $wikibaseClient->newSnakFormatter(); - $instance = new self( $targetLanguage, + // Use variant language instead of content language itself when the output will + // be converted, in case some labels can't be converted correctly afterwards. + $parserOptions = $parser->getOptions(); + $handleVariants = $parser->ot['html'] && !$parserOptions->getInterfaceMessage() + && !$parserOptions->getDisableContentConversion(); + if ( $handleVariants ) { + $labelLanguage = Language::factory( $targetLanguage->getPreferredVariant() ); + } else { + $labelLanguage = $targetLanguage; + } + + $instance = new self( $labelLanguage, $entityLookup, $propertyLabelResolver, $errorFormatter, $formatter ); @@ -210,10 +222,21 @@ $text = $status->isOK() ? $status->getValue() : ''; + // This condition is less strict than handleVariants. + if ( $parser->ot['html'] || $parser->ot['pre'] ) { + $text = wfEscapeWikitext( $text ); + + // Since we've already fetched labels in requested variant languages, + // prevent them from being converted again in further parsing process. + // Some tests may be added to ensure this behavior. + if ( $handleVariants ) { + $text = $targetLanguage->getConverter()->markNoConversion( $text ); + } + } + $result = array( $text, 'noparse' => false, - 'nowiki' => true, ); wfProfileOut( __METHOD__ ); -- To view, visit https://gerrit.wikimedia.org/r/71996 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5a461251c5c4b0ff6c5abd701707c5c04910fadf Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Show entity label with language fallback in action=history - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71865 Change subject: Show entity label with language fallback in action=history .. Show entity label with language fallback in action=history Change-Id: I79e99d34cf4e6318a7a865e5a910b144d23677da --- M repo/includes/actions/HistoryEntityAction.php 1 file changed, 9 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/65/71865/1 diff --git a/repo/includes/actions/HistoryEntityAction.php b/repo/includes/actions/HistoryEntityAction.php index 2fc5ff8..45bd92a 100644 --- a/repo/includes/actions/HistoryEntityAction.php +++ b/repo/includes/actions/HistoryEntityAction.php @@ -45,7 +45,15 @@ $entity = $content->getEntity(); - $labelText = $entity->getLabel( $this->getContext()->getLanguage()->getCode() ); + $languageFallbackChainFactory = WikibaseRepo::getDefaultInstance()->getLanguageFallbackChainFactory(); + $languageFallbackChain = $languageFallbackChainFactory->newFromContext( $this->getContext() ); + $labelData = $languageFallbackChain->extractPreferredValueOrAny( $content->getEntity()->getLabels() ); + + if ( $labelData ) { + $labelText = $labelData['value']; + } else { + $labelText = null; + } $idPrefixer = WikibaseRepo::getDefaultInstance()->getIdFormatter(); $prefixedId = ucfirst( $idPrefixer->format( $entity->getId() ) ); -- To view, visit https://gerrit.wikimedia.org/r/71865 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I79e99d34cf4e6318a7a865e5a910b144d23677da Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove Utils::lookupUserMultilangText(): replace by language... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71852 Change subject: Remove Utils::lookupUserMultilangText(): replace by language fallback chain .. Remove Utils::lookupUserMultilangText(): replace by language fallback chain Utils::reorderArray() and Utils::filterMultilangText() can be removed later, after both this and I40ad9647ba489a7950773f21a2ec04273ef1fe9e are merged. Change-Id: Icf35995c962a3d65d329994d0312f085f83d3088 --- M lib/includes/Utils.php M repo/includes/actions/EditEntityAction.php M repo/includes/actions/ViewEntityAction.php 3 files changed, 14 insertions(+), 89 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/52/71852/1 diff --git a/lib/includes/Utils.php b/lib/includes/Utils.php index c6ce523..98cf1f6 100644 --- a/lib/includes/Utils.php +++ b/lib/includes/Utils.php @@ -338,74 +338,6 @@ } /** -* Find the first multilingual string that can be used for constructing a language object -* for the current user. If a preferred language can't be identified the global chain is -* used. -* -* Note that a user specific multilingual string is not globally cachable. -* -* FIXME: duplication with @see lookupMultilangText, needs refactor -* -* @since 0.1 -* -* @param array $texts the key-value pairs to check for existence -* @param array $sequence the list of keys that should exist -* @param array $fallback an array of values that are used as a replacement if nothing is found -* The fallback is in the form array( code, text, language ) -* @return array|null triplet with the initial language code, the text, and the language object -*/ - static public function lookupUserMultilangText( array $texts = null, array $sequence = null, array $fallback = null ) { - // FIXME: deprecated globals! - global $wgUser, $wgLang; - - // Prerequisites for further processing - if ( is_null( $texts ) || is_null( $sequence ) ) { - return $fallback; // makes the simplest use case - } - - // Filter down the result - $texts = \Wikibase\Utils::filterMultilangText( $texts, $sequence ); - if ( is_null( $texts ) || empty( $texts ) ) { - return $fallback; - } - - // Check if we can use the ordinary language - // This should always be used if possible because this will match - // with the user set language - reset($texts); - list( $code, $text ) = each( $texts ); - if ( $wgLang->getCode() === $code ) { - $lang = Language::factory( $code ); - if ( !is_null( $lang ) ) { - return array( $code, $text, $lang ); - } - } - - // Find the first preferred language code we can turn into a language object - // Note that the factory call do a pretty dumb cleaning up that can make this vejjy slow - foreach ( $texts as $code => $text ) { - if ( $wgUser->getOption( "sttl-languages-$code" ) ) { - $lang = Language::factory( $code ); - if ( !is_null( $lang ) ) { - return array( $code, $text, $lang ); - } - } - } - - // Find the first ordinary language code we can turn into a language object - // Note that the factory call do a pretty dumb cleaning up that can make this vejjy slow - foreach ( $texts as $code => $text ) { - $lang = Language::factory( $code ); - if ( !is_null( $lang ) ) { - return array( $code, $text, $lang ); - } - } - - // Use the fallback if the previous fails - return $fallback; - } - - /** * Get the fallback languages prepended with the source language itself. * * A language chain in this respect is the language itself and all fallback diff --git a/repo/includes/actions/EditEntityAction.php b/repo/includes/actions/EditEntityAction.php index 1312945..7908750 100644 --- a/repo/includes/actions/EditEntityAction.php +++ b/repo/includes/actions/EditEntityAction.php @@ -288,15 +288,15 @@ */ public function getLabelText( EntityContent $content ) { - $langCode = $this->getContext()->getLanguage()->getCode(); - list( , $labelText, ) = - Utils::l
[MediaWiki-commits] [Gerrit] Remove Utils::lookupMultilangText(): replaced by language fa... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71845 Change subject: Remove Utils::lookupMultilangText(): replaced by language fallback chain .. Remove Utils::lookupMultilangText(): replaced by language fallback chain Change-Id: I40ad9647ba489a7950773f21a2ec04273ef1fe9e --- M lib/includes/Utils.php M repo/Wikibase.hooks.php 2 files changed, 27 insertions(+), 71 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/45/71845/1 diff --git a/lib/includes/Utils.php b/lib/includes/Utils.php index c6ce523..95412a2 100644 --- a/lib/includes/Utils.php +++ b/lib/includes/Utils.php @@ -298,46 +298,6 @@ } /** -* Find the first multilingual string that can be used for constructing a language object. The -* global chain is always used. -* -* Note that a multilingual string from the global chain will always be globally cachable. -* -* @since 0.1 -* -* @param array $texts the key-value pairs to check for existence -* @param array $sequence the list of keys that should exist -* @param array $fallback an array of values that are used as a replacement if nothing is found -* The fallback is in the form array( code, text, language ) -* @return array|null triplet with the initial language code, the text, and the language object -*/ - static public function lookupMultilangText( array $texts = null, array $sequence = null, array $fallback = null ) { - - // Prerequisites for further processing - if ( is_null( $texts ) || is_null( $sequence ) ) { - return $fallback; // makes the simplest use case - } - - // Filter down the result - $texts = \Wikibase\Utils::filterMultilangText( $texts, $sequence ); - if ( is_null( $texts ) || empty( $texts ) ) { - return $fallback; - } - - // Find the first language code we can turn into a language object - // Note that the factory call do a pretty dumb cleaning up that can make this vejjy slow - foreach ( $texts as $code => $text ) { - $lang = Language::factory( $code ); - if ( !is_null( $lang ) ) { - return array( $code, $text, $lang ); - } - } - - // Use the fallback if the previous fails - return $fallback; - } - - /** * Find the first multilingual string that can be used for constructing a language object * for the current user. If a preferred language can't be identified the global chain is * used. diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 2848577..73cb80d 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -1,8 +1,8 @@ getCode(); - static $langStore = array(); - if ( !isset( $langStore[$lang] ) ) { - $langStore[$lang] = array_merge( array( $lang ), Language::getFallbacksFor( $lang ) ); + // Try to find the most preferred available language to display data in current context. + $languageFallbackChainFactory = WikibaseRepo::getDefaultInstance()->getLanguageFallbackChainFactory(); + $context = RequestContext::getMain(); + $languageFallbackChain = $languageFallbackChainFactory->newFromContext( $context ); + + $labelData = $languageFallbackChain->extractPreferredValue( $entity->getLabels() ); + $descriptionData = $languageFallbackChain->extractPreferredValue( $entity->getDescriptions() ); + + if ( $labelData ) { + $labelText = $labelData['value']; + $labelLang = Language::factory( $labelData['language'] ); + } else { + $labelText = ''; + $labelLang = $context->getLanguage(); } - // Get the label and description for the first languages on the chain - // that doesn't fail, use a fallback if everything fails. This could - // use the user supplied list of acceptable languages as a filter. - list( , $labelText, $labelLang) = $labelTriplet = - Utils::lookupMultilangText( - $entity->getLabels( $langStore[$lang] ), - $langStore[$lang], - array( $wgLang->getCode(), null, $wgLang ) - ); - list( , $descriptionText, $descriptionLang) = $descriptionTriplet = - Utils::lookupMultilangText( -
[MediaWiki-commits] [Gerrit] Merge commit '412716e86e0c68b4561ccbae2967fcdb6ba1320c'; com... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71787 Change subject: Merge commit '412716e86e0c68b4561ccbae2967fcdb6ba1320c'; commit '6cfddb53638e9153c26320a6e4c90dd6d5d8e9a5' into SerializationContextX .. Merge commit '412716e86e0c68b4561ccbae2967fcdb6ba1320c'; commit '6cfddb53638e9153c26320a6e4c90dd6d5d8e9a5' into SerializationContextX Change-Id: I5760063179e27d5567f7e84ce18d868c349bc182 --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/87/71787/1 [Octopus merge; cannot be formatted as a diff.] -- To view, visit https://gerrit.wikimedia.org/r/71787 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5760063179e27d5567f7e84ce18d868c349bc182 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] DO NOT MERGE - WAITING FOR TESTS - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71788 Change subject: DO NOT MERGE - WAITING FOR TESTS .. DO NOT MERGE - WAITING FOR TESTS Change-Id: Ibd21394b17a72a2c08338e750bb98f5e5e1b5e67 --- M lib/includes/LanguageFallbackChain.php M lib/includes/serializers/EntitySerializer.php M lib/includes/serializers/LabelSerializer.php M lib/includes/serializers/SerializerFactory.php M repo/includes/EntityView.php 5 files changed, 47 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/88/71788/1 diff --git a/lib/includes/LanguageFallbackChain.php b/lib/includes/LanguageFallbackChain.php index e9e78e5..85f7c51 100644 --- a/lib/includes/LanguageFallbackChain.php +++ b/lib/includes/LanguageFallbackChain.php @@ -30,6 +30,11 @@ class LanguageFallbackChain { /** +* Pseudo language code used to identify a fallback chain initialized from current context. +*/ + const CONTEXT_LANGUAGE_CODE = 'qqc'; + + /** * @var LanguageWithConversion[] */ private $chain = array(); diff --git a/lib/includes/serializers/EntitySerializer.php b/lib/includes/serializers/EntitySerializer.php index f41e5f6..7ad4045 100644 --- a/lib/includes/serializers/EntitySerializer.php +++ b/lib/includes/serializers/EntitySerializer.php @@ -89,7 +89,19 @@ break; case 'labels': $labelSerializer = new LabelSerializer( $this->options ); - $labels = $entity->getLabels( $this->options->getLanguages() ); + $allLabels = $entity->getLabels(); + $labels = array(); + $languageFallbackChains = $this->options->getLanguageFallbackChains(); + if ( $languageFallbackChains ) { + foreach ( $languageFallbackChains as $languageCode => $languageFallbackChain ) { + $data = $languageFallbackChain->extractPreferredValue( $allLabels ); + if ( $data !== null ) { + $labels[$languageCode] = $data; + } + } + } else { + $labels = $allLabels; + } $serialization['labels'] = $labelSerializer->getSerialized( $labels ); break; case 'claims': diff --git a/lib/includes/serializers/LabelSerializer.php b/lib/includes/serializers/LabelSerializer.php index 13094f8..0789c27 100644 --- a/lib/includes/serializers/LabelSerializer.php +++ b/lib/includes/serializers/LabelSerializer.php @@ -73,12 +73,23 @@ $value = array(); $idx = 0; - foreach ( $labels as $languageCode => $label ) { + foreach ( $labels as $languageCode => $labelData ) { $key = $this->options->shouldUseKeys() ? $languageCode : $idx++; + if ( is_array( $labelData ) ) { + $label = $labelData['value']; + $labelLanguageCode = $labelData['language']; + $labelSourceLanguageCode = $labelData['source']; + } else { + // back-compat + $label = $labelData; + $labelLanguageCode = $languageCode; + $labelSourceLanguageCode = $languageCode; + } $valueKey = ( $label === '' ) ? 'removed' : 'value'; $value[$key] = array( - 'language' => $languageCode, - $valueKey => $label + 'language' => $labelLanguageCode, + 'source-language' => $labelSourceLanguageCode, + $valueKey => $label, ); } diff --git a/lib/includes/serializers/SerializerFactory.php b/lib/includes/serializers/SerializerFactory.php index 4c24074..db3fc90 100644 --- a/lib/includes/serializers/SerializerFactory.php +++ b/lib/includes/serializers/SerializerFactory.php @@ -91,4 +91,4 @@ throw new OutOfBoundsException( '"' . $className . '" has no associated unserializer' ); } -} \ No newline at end
[MediaWiki-commits] [Gerrit] Improve class LanguageFallbackChain and its factory - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71778 Change subject: Improve class LanguageFallbackChain and its factory .. Improve class LanguageFallbackChain and its factory Change-Id: I55516170998e983ef7bc0b7c99cf63d31098d46c --- M lib/includes/LanguageFallbackChain.php M lib/includes/LanguageFallbackChainFactory.php M lib/tests/phpunit/LanguageFallbackChainFactoryTest.php 3 files changed, 21 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/78/71778/1 diff --git a/lib/includes/LanguageFallbackChain.php b/lib/includes/LanguageFallbackChain.php index e9e78e5..634679f 100644 --- a/lib/includes/LanguageFallbackChain.php +++ b/lib/includes/LanguageFallbackChain.php @@ -66,13 +66,13 @@ public function extractPreferredValue( $data ) { foreach ( $this->chain as $languageWithConversion ) { - if ( isset( $data[$languageWithConversion->getFetchLanguage()->getCode()] ) ) { + $fetchCode = $languageWithConversion->getFetchLanguage()->getCode(); + $languageCode = $languageWithConversion->getLanguage()->getCode(); + if ( isset( $data[$fetchCode] ) ) { return array( - 'value' => $languageWithConversion->translate( - $data[$languageWithConversion->getFetchLanguage()->getCode()] - ), - 'language' => $languageWithConversion->getLanguage()->getCode(), - 'source' => $languageWithConversion->getFetchLanguage()->getCode(), + 'value' => $languageWithConversion->translate( $data[$fetchCode] ), + 'language' => $languageCode, + 'source' => $fetchCode, ); } } diff --git a/lib/includes/LanguageFallbackChainFactory.php b/lib/includes/LanguageFallbackChainFactory.php index e5ede9d..c766895 100644 --- a/lib/includes/LanguageFallbackChainFactory.php +++ b/lib/includes/LanguageFallbackChainFactory.php @@ -84,14 +84,16 @@ } /** -* Build fallback chain for a given language. +* Build fallback chain array for a given language. * * @param Language $language * @param $mode bitfield of self::FALLBACK_* * @param LanguageFallbackChain[] $chain for recursive calls * @param array $fetched for recursive calls +* +* @return array of LanguageWithConversion objects */ - private function buildFromLanguage( Language $language, $mode, &$chain = array(), &$fetched = array() ) { + public function buildFromLanguage( Language $language, $mode, &$chain = array(), &$fetched = array() ) { if ( $mode & self::FALLBACK_SELF ) { if ( !isset( $fetched[$language->getCode()] ) ) { @@ -191,11 +193,13 @@ } /** -* Build fallback chain for a given babel array. +* Build fallback chain array for a given babel array. * * @param array $babel +* +* @return array of LanguageWithConversion objects */ - private function buildFromBabel( array $babel ) { + public function buildFromBabel( array $babel ) { $chain = array(); $fetched = array(); diff --git a/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php b/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php index cd8b09a..19e8e5a 100644 --- a/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php +++ b/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php @@ -24,17 +24,17 @@ * @group WikibaseLib * @dataProvider providerNewFromLanguage */ - public function testNewFromLanguage( $lang, $mode, $expected ) { + public function testNewFromLanguage( $lang, $mode, $expectedItems ) { $factory = new LanguageFallbackChainFactory(); $chain = $factory->newFromLanguage( \Language::factory( $lang ), $mode )->getFallbackChain(); - $this->assertEquals( count( $expected ), count( $chain ) ); - for ( $i = 0; $i < count( $chain ); $i++ ) { - if ( is_array( $expected[$i] ) ) { - $this->assertEquals( $expected[$i][0], $chain[$i]->getLanguage()->getCode() ); - $this->assertEquals( $expected[$i][1], $chain[$i]->getSourceLanguage()->getCode() ); + $this->assertEquals( count( $expectedItems ), count( $chain ) ); + foreach ( $expectedItems as $i => $expected
[MediaWiki-commits] [Gerrit] Drop a code path in wfBCP47() which is never reached. - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71300 Change subject: Drop a code path in wfBCP47() which is never reached. .. Drop a code path in wfBCP47() which is never reached. count( $codeSegment ) > 0 should be never true in a foreach loop of $codeSegment itself. See also Iffe166f3. Change-Id: I453b5ec3379951a2ad6e34b9835907c2eba3046b --- M includes/GlobalFunctions.php 1 file changed, 10 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/00/71300/1 diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a44e45b..4f9347a 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3750,22 +3750,17 @@ $codeSegment = explode( '-', $code ); $codeBCP = array(); foreach ( $codeSegment as $segNo => $seg ) { - if ( count( $codeSegment ) > 0 ) { - // when previous segment is x, it is a private segment and should be lc - if ( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) { - $codeBCP[$segNo] = strtolower( $seg ); - // ISO 3166 country code - } elseif ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) { - $codeBCP[$segNo] = strtoupper( $seg ); - // ISO 15924 script code - } elseif ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) { - $codeBCP[$segNo] = ucfirst( strtolower( $seg ) ); - // Use lowercase for other cases - } else { - $codeBCP[$segNo] = strtolower( $seg ); - } + // when previous segment is x, it is a private segment and should be lc + if ( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) { + $codeBCP[$segNo] = strtolower( $seg ); + // ISO 3166 country code + } elseif ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) { + $codeBCP[$segNo] = strtoupper( $seg ); + // ISO 15924 script code + } elseif ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) { + $codeBCP[$segNo] = ucfirst( strtolower( $seg ) ); + // Use lowercase for other cases } else { - // Use lowercase for single segment $codeBCP[$segNo] = strtolower( $seg ); } } -- To view, visit https://gerrit.wikimedia.org/r/71300 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I453b5ec3379951a2ad6e34b9835907c2eba3046b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Uncomment a few tests in includes/GlobalFunctions/wfBCP47Tes... - change (mediawiki/core)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71298 Change subject: Uncomment a few tests in includes/GlobalFunctions/wfBCP47Test.php .. Uncomment a few tests in includes/GlobalFunctions/wfBCP47Test.php Change-Id: I4e275c0258e5028a4d48686af88ee2f5c9993047 --- M tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php 1 file changed, 0 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/98/71298/1 diff --git a/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php b/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php index 6229be3..bfdee23 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php +++ b/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php @@ -116,7 +116,6 @@ // a-DE // ar-a-aaa-b-bbb-a-ccc - /* // ISO 15924 : array( 'sr-Cyrl', 'sr-Cyrl' ), # @todo FIXME: Fix our function? @@ -128,7 +127,6 @@ array( 'uS', 'us' ), # USA array( 'Fr', 'fr' ), # France array( 'va', 'va' ), # Holy See (Vatican City State) -*/ ); } } -- To view, visit https://gerrit.wikimedia.org/r/71298 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4e275c0258e5028a4d48686af88ee2f5c9993047 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] New special page Special:MyLanguageFallbackChain mostly for ... - change (mediawiki...Wikibase)
Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/71281 Change subject: New special page Special:MyLanguageFallbackChain mostly for confirmation .. New special page Special:MyLanguageFallbackChain mostly for confirmation Change-Id: I0bf124b436d2cd076a5361102123c0a21c6c5b3b --- M repo/Wikibase.classes.php M repo/Wikibase.i18n.alias.php M repo/Wikibase.i18n.php M repo/Wikibase.php A repo/includes/specials/SpecialMyLanguageFallbackChain.php 5 files changed, 101 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/81/71281/1 diff --git a/repo/Wikibase.classes.php b/repo/Wikibase.classes.php index adfa41e..81f44fb 100644 --- a/repo/Wikibase.classes.php +++ b/repo/Wikibase.classes.php @@ -126,6 +126,7 @@ 'SpecialListDatatypes' => 'includes/specials/SpecialListDatatypes.php', 'SpecialDispatchStats' => 'includes/specials/SpecialDispatchStats.php', 'SpecialEntityData' => 'includes/specials/SpecialEntityData.php', + 'SpecialMyLanguageFallbackChain' => 'includes/specials/SpecialMyLanguageFallbackChain.php', 'Wikibase\LinkedData\EntityDataSerializationService' => 'includes/LinkedData/EntityDataSerializationService.php', 'Wikibase\LinkedData\EntityDataRequestHandler' => 'includes/LinkedData/EntityDataRequestHandler.php', 'Wikibase\LinkedData\EntityDataUriManager' => 'includes/LinkedData/EntityDataUriManager.php', diff --git a/repo/Wikibase.i18n.alias.php b/repo/Wikibase.i18n.alias.php index b5027ac..866d9bd 100644 --- a/repo/Wikibase.i18n.alias.php +++ b/repo/Wikibase.i18n.alias.php @@ -29,6 +29,7 @@ 'SetSiteLink' => array( 'SetSiteLink' ), 'EntitiesWithoutLabel' => array( 'EntitiesWithoutLabel' ), 'ItemsWithoutSitelinks' => array( 'ItemsWithoutSitelinks' ), + 'MyLanguageFallbackChain' => array( 'MyLanguageFallbackChain' ), ); /** Arabic (العربية) */ @@ -272,4 +273,4 @@ 'SetAliases' => array( '設置別名' ), 'EntitiesWithoutLabel' => array( '沒有標籤的實體' ), 'ItemsWithoutSitelinks' => array( '沒有條目連結的項目' ), -); \ No newline at end of file +); diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index c1d4827..3d4e708 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -228,6 +228,11 @@ 'wikibase-entitydata-unsupported-format' => "The data format $1 is not supported by this interface.", 'wikibase-entitydata-title' => 'Entity Data', 'wikibase-entitydata-text' => 'This page provides a linked data interface to entity values. Please provide the entity ID in the URL, using subpage syntax.', + 'special-mylanguagefallbackchain' => 'My language fallback chain', + 'wikibase-mylanguagefallbackchain-text' => 'The language fallback chain used to display entity labels for you is shown below.', + 'wikibase-mylanguagefallbackchain-babel' => 'You can edit it by putting {{#babel: }} on your [[Special:MyPage|user page]].', + 'wikibase-mylanguagefallbackchain-verbatim-item' => '$1', + 'wikibase-mylanguagefallbackchain-converted-item' => '$1 (converted from $2)', // API errors - these messages should not be translated 'wikibase-api-aliases-invalid-list' => 'Use either "set" or "add"/"remove" parameters.', # Do not translate diff --git a/repo/Wikibase.php b/repo/Wikibase.php index b541afb..96976fc 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -137,6 +137,7 @@ $wgSpecialPages['ListDatatypes'] = 'SpecialListDatatypes'; $wgSpecialPages['DispatchStats'] = 'SpecialDispatchStats'; $wgSpecialPages['EntityData'] = 'SpecialEntityData'; + $wgSpecialPages['MyLanguageFallbackChain'] = 'SpecialMyLanguageFallbackChain'; // Special page groups $wgSpecialPageGroups['NewItem'] = 'wikibaserepo'; diff --git a/repo/includes/specials/SpecialMyLanguageFallbackChain.php b/repo/includes/specials/SpecialMyLanguageFallbackChain.php new file mode 100644 index 000..75947a2 --- /dev/null +++ b/repo/includes/specials/SpecialMyLanguageFallbackChain.php @@ -0,0 +1,92 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since 0.4 + * + * @file + * @ingroup WikibaseRepo + * + * @licence GNU GPL v2+ + */ +class SpecialMyLanguageFallbackChain extends SpecialPage { + + /** +* Constructor. +* +* @since 0.4 +*/ + public function __construct() { + parent::__construct( 'MyLanguageFallbackChain' ); + } + + /** +* @see SpecialPage::getDescription +* +* @since 0.4 +* @return String +*/ + pu