ویکی‌پدیا mznwiki https://mzn.wikipedia.org/wiki/%DA%AF%D8%AA_%D8%B5%D9%81%D8%AD%D9%87 MediaWiki 1.47.0-wmf.11 first-letter مدیا شا گپ کارور کارور گپ ویکی‌پدیا ویکی‌پدیا گپ پرونده پرونده گپ مدیاویکی مدیاویکی گپ شابلون شابلون گپ رانما رانما گپ رج رج گپ پورتال پورتال گپ پروژه پروژه گپ TimedText TimedText talk ماژول ماژول گپ Event Event talk ایقتصاد 0 1795 390389 209634 2026-07-18T00:44:44Z Xqbot 827 ربوت:عوض هایتن دکشیه‌ئون دِتایی → [[اقتیصاد]] 390389 wikitext text/x-wiki #بور [[اقتیصاد]] mxele916q3gedaqd4000uafd8hem2l2 آمریکای متحده ایالات 0 1863 390388 327918 2026-07-17T23:43:29Z InternetArchiveBot 25385 Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5 390388 wikitext text/x-wiki {{کشور |native_name = ''United States of America''' <br />(متحده ایالات آمریکا)'' |common_name = متحده ایالات آمریکا |conventional_long_name = |image_flag = Flag of the United States.svg |image_coat = US-GreatSeal-Obverse.svg |image_map = United States (orthographic projection).svg |capital = [[واشینگتن]] |largest_city = [[نیویورک]] |official_languages = [[انگلیسی زبون]] |government_type = جمهوری فدرال |area = ۹٬۸۲۶٬۶۳۰ |percent_water = (%)۴٫۸۷ |population_estimate = ۳۰۹٬۵۳۴٬۰۰۰ |population_density = ۳۱ |currency = [[دلار]] |currency_code = USD |time_zone = CET |cctld = [[.us]] [[.gov]] [[.edu]] [[.mil]] [[.um]] |calling_code = 1 }} '''متحده ایالات آمریکا''' {{انگلیسی|United States of America<small> ونه مخفف وانه: </small>USA}} کشوری هسته که [[شومالی آمریکا]] دله دره، ونه نیشتنگاء شهر [[واشینگتن|واشنگتن دی‌سی]] هسته. آمریکا جمعیت وری سومین کشور و از لحاظ گت بودن چهارمین کشوره، و از لحاظ نژاد مردِم، متنوع‌ترین کشور جهون به حیساب انه<ref>{{یادکرد |کیتاب=Dealing with Diversity |نویسنده = Adams, J.Q., and Pearlie Strother-Adams |شهر=Chicago |ناشر =Kendall/Hunt |سال=2001 |شابک=ISBN 0-7872-8145-X }}</ref>. آمریکا اتا سال دله تولید ناخالص داخلیش ویشته از ۱۳٬۰۰۰ میلیارد دلار هسته و ۱۹٪ قدرت خرید جهون، گت‌ترین ایقتیصاد میون کشورون جهون ره دانـّه.<ref name=autogenerated2>Rank Order - GDP (purchasing power parity)</ref> نظوم حکومتی آمریکا چارچوب قانون اساسی، و بر اساس سیستم جوموری فدرال دِرِس بیّه. اینتا کشور سال ۱۷۷۶ میلادی (۱۱۵۵هـ.خ.)، اعلام هستهقلال هکرده و ۱۳ ایالت سابق [[بریتانیا]] ره شه بال بِن بیته. کشور آمریکا از شرق با [[اطلس اقیانوس]]، غرب جه با [[آروم اقیانوس]]، شومال جه با کشور [[کانادا]] ، و جنوب جه با [[مکزیک]] هم‌سامون‌هسته. اینتا کشور از راه پایگاه دریایی [[بازداشتگاه گوانتانامو|گوانتانامو]] هم [[کوبا]] جه همسایه هسته. آمریکا همینتی از طریق [[آلاسکا]] با [[روسیه]] ئوسامون دانّه. به علاوه، مجموعه‌یی از جزیره‌ئون، ناحیه‌ئون، و مناطق متعلق به آمریکا سراسر جهون دله دکلستونه. این کشور با نامای دیگری مثل ''متحده ایالات آمریکا''، (''اِمریکا'' یا ''آمریکا'') ''متحده ایالات''، ''اتازونی'' (برگرفته از واژهٔ [[زوون فرانسوی|فرانسوی]] États-Unis، به معنای ایالت‌ئون متحد)<ref>[http://www.mibosearch.com/word.aspx?wName=%D8%A7%D8%AA%D8%A7%D8%B2%D9%88%D9%86%D9%8A لغت نامه دهخدا]</ref> و (بطور عامیانه) ینگه دنیا<ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده=دهخدا{{#if:علی‌اکبر|، {{چر}}علی‌اکبر}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=fa |مقاله= [http://www.loghatnaameh.com/dehkhodaworddetail-f5904c4c9c3146588d9ade1029ed2611-fa.html لغت‌نامه دهخدا] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه= |تاریخ= {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2009-04-16|بازیابی‌شده در تاریخ ۱۶-۰۴-۲۰۰۹ .}} {{#if:|Retrieved on , {{چر}}.}}</ref> هم بخوندسته وانه. متحده ایالات آمریکا بعد از حضور [[جهونی جنگ اول]] و [[جهونی جنگ دوم]]، دنیا دله اثر گوذار بیّه. آمریکا به عضویت دائم [[شورای امنیت|شورای امنیت سازمان ملل]] در بموئه و از بونیانگوذاران پیمون نیظامی [[ناتو]] حیساب وانه. <ref>{{یادکرد|فصل= |کیتاب={{#if:http://books.google.com/books?id=UV-ti1sYcbcC&dq=united+state+founding+member+of+NATO&lr=&as_drrb_is=q&as_minm_is=0&as_miny_is=&as_maxm_is=0&as_maxy_is=&num=50&as_brr=0&as_pt=ALLTYPES&output=html&source=gbs_summary_s&cad=0|[http://books.google.com/books?id=UV-ti1sYcbcC&dq=united+state+founding+member+of+NATO&lr=&as_drrb_is=q&as_minm_is=0&as_miny_is=&as_maxm_is=0&as_maxy_is=&num=50&as_brr=0&as_pt=ALLTYPES&output=html&source=gbs_summary_s&cad=0 NATO 1948: the birth of the transatlantic Alliance‎]|NATO 1948: the birth of the transatlantic Alliance‎}}|ناشر= Rowman & Littlefield|چاپ= |شهر= |کوشش= {{#if:|, {{چر}}}} |دچی‌ین= |سال=2007 {{#if:|, {{چر}}}} |شابک={{#if:0742539172|ISBN 0-7425-3917-2}} |نویسنده=S. Kaplan{{#if:Lawrence|, {{چر}}Lawrence}} |نویسندگون سایر بخش‌ئون=Morris Honick|ترجومه=|صفحه= |زوون=en |مقاله= |ژورنال= |نشریه= |تاریخ= |دوره= |شوماره= |شاپا=}} {{#if:|Retrieved on .}}</ref> و بعد از رِقِدبوردن [[شوروی]] و تموم بیّن [[سرد جنگ]] به اتا ابرقدرت بیّه.<ref>{{یادکرد|فصل= |کیتاب={{#if:http://books.google.com/books?pg=PA9&dq=he+United+States+emerged+as+the+sole+superpower&lr=&as_drrb_is=q&as_minm_is=0&as_miny_is=&as_maxm_is=0&as_maxy_is=&ei=hHznScmMM4eyyQTar8TRCA&id=rnNnOxvm3ZwC&num=50&as_brr=0&as_pt=ALLTYPES|[http://books.google.com/books?pg=PA9&dq=he+United+States+emerged+as+the+sole+superpower&lr=&as_drrb_is=q&as_minm_is=0&as_miny_is=&as_maxm_is=0&as_maxy_is=&ei=hHznScmMM4eyyQTar8TRCA&id=rnNnOxvm3ZwC&num=50&as_brr=0&as_pt=ALLTYPES Asian security order: instrumental and normative features]|Asian security order: instrumental and normative features}}|ناشر= Stanford University Press|چاپ= |شهر= |کوشش= {{#if:|, {{چر}}}} |دچی‌ین= |سال=2003 {{#if:|, {{چر}}}} |شابک={{#if:|ISBN }} |نویسنده=Alagappa{{#if:Muthiah|, {{چر}}Muthiah}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه=9 |زوون=en |مقاله= |ژورنال= |نشریه= |تاریخ= |دوره= |شوماره= |شاپا=}} {{#if:|Retrieved on .}}</ref> آمریکای مردمون ره گانّه "آمریکایی". == جوغرافیا == {{اصلی|موحیط زیست آمریکا}} [[پرونده:Baldeagle-05jul2.jpg|thumb|left|[[اسپه سر جول]] پرنده میلّی آمریکا از سال ۱۷۸۲ میلادی]] متحده ایالاتٔ آمریکا نیمکورهٔ غربی زمین، و شومال [[آمریکا قاره]] دله دره. اینتا کشور از ۴۸ ایالت نزدیک به هم، و دِتا ایالت سِوا از بقیه (جزیره‌مونا [[آلاسکا]] شومال شرق آمریکا دله و مجمع‌الجزایر [[هاوائی|هاوایی]] [[آروم اقیانوس]] دله) جه دِرِس بیّه. همینتی دِتا منطقهٔ [[دریای کارائیب]]، و هم بخش‌ئونی از [[آروم اقیانوس]] ، جزایر کوچک و سِوا از همی وجود دانه که قلمرو آمریکا محسوب وانّه، ولی به اتّی [[خودمختار|خودگردان]] اداره وانّه (مثل [[پورتوریکو|پورتو ریکو]]).<ref>https://web.archive.org/web/20200229153648/https://www.gao.gov/archive/1998/og98005.pdf</ref><br /> [[آلاسکا]] گت ترین<ref>{{یادکرد|فصل= |کیتاب={{#if:http://books.google.com/books?pg=PA4&lpg=PA3&dq=The+Climate+of+Alaska+alaska++largest+state&lr=&id=aUDWK8zDr50C&num=50&as_brr=0&as_pt=ALLTYPES|[http://books.google.com/books?pg=PA4&lpg=PA3&dq=The+Climate+of+Alaska+alaska++largest+state&lr=&id=aUDWK8zDr50C&num=50&as_brr=0&as_pt=ALLTYPES The Climate of Alaska]|The Climate of Alaska}}|ناشر= University of Alaska Press|چاپ= |شهر= |کوشش= {{#if:|, {{چر}}}} |دچی‌ین= |سال=2007 {{#if:|, {{چر}}}} |شابک={{#if:1602230072|ISBN 1-60223-007-2}} |نویسنده=Shulski{{#if:Martha|, {{چر}}Martha}} |نویسندگون سایر قسمت‌ئون=Gerd Wendler|ترجومه=|صفحه=4 |زوون=en |مقاله= |ژورنال= |نشریه= |تاریخ= |دوره= |شوماره= |شاپا=}} {{#if:|Retrieved on .}}</ref> و [[رود آیلند|رودآیلند]] کوچکترین ایالت در آمریکا می‌باشند.<ref>{{یادکرد|فصل= |کیتاب={{#if:http://books.google.com/books?pg=PA67&dq=The+smallest+state+is+Rhode+Island&lr=&as_drrb_is=q&as_minm_is=0&as_miny_is=&as_maxm_is=0&as_maxy_is=&ei=g5nnSezbM4GUkATH-pWUAQ&id=PHi2qWoR29sC&num=50&as_brr=0&as_pt=ALLTYPES|[http://books.google.com/books?pg=PA67&dq=The+smallest+state+is+Rhode+Island&lr=&as_drrb_is=q&as_minm_is=0&as_miny_is=&as_maxm_is=0&as_maxy_is=&ei=g5nnSezbM4GUkATH-pWUAQ&id=PHi2qWoR29sC&num=50&as_brr=0&as_pt=ALLTYPES Rhode Island]|Rhode Island}}|ناشر= Marshall Cavendish|چاپ= |شهر= |کوشش= {{#if:|, {{چر}}}} |دچی‌ین= |سال=2007 {{#if:|, {{چر}}}} |شابک={{#if:0761425608|ISBN 0-7614-2560-8}} |نویسنده=Klein{{#if:Ted|, {{چر}}Ted}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه=67 |زوون=en |مقاله= |ژورنال= |نشریه= |تاریخ= |دوره= |شوماره= |شاپا=}} {{#if:|Retrieved on .}}</ref><br /> [[پرونده:Alaska-Size.png|thumb|right|موقایسه [[آلاسکا]] با گتی ۴۸ ایالت این کشور]] ات تیکه از رشته کوه‌ئون راکی غرب آمریکا دله دره که گت‌ترین قله وه [[کلرادو|ایالت کلرادو]] دله دره. گت‌ترین کوه آمریکا [[مک کینلی]] هسته که آلاسکا دله دره. [[میسیسیپی]] گت‌ترین و موهم‌ترین روخنه قاره‌ی آمریکا و چارومین روخنه طولانی جهون آمریکا دله دره. این روخنه که [[میسوری]] دله کلنه، ایقتیصاد و تجارت دله هم به کار شونه. قسمتی از [[ئوشار نیاگارا]] آمریکا و کانادای سامون په دره که خله قشنگه. {{-}} === آمریکای گتی === [[پرونده:MtHood TrilliumLake.jpg|thumb|کوه هود و دریاچه تریلیوم ایالت [[اورگن|ارگن]] دله]] از نظر کُل گتی ئو و خاک، [[متحده ایالات آمریکا|آمریکا]] بعد از [[روسیه]] و [[کانادا]] ، سومین کشور گت جهون هسته.<ref>اگه ئو ره حیساب نکانیم چین ، آمریکا جه گت‌ته هسته.</ref> === موختصات و موقعیت جوغرافیایی آمریکا === کشور آمریکا از شرق با [[اطلس اقیانوس]]، غرب جه با [[آروم اقیانوس]]، شومال جه با کشور [[کانادا]] ، و جنوب جه با [[مکزیک]] هم‌سامون‌هسته. اینتا کشور از راه پایگاه دریایی [[بازداشتگاه گوانتانامو|گوانتانامو]] هم [[کوبا]] جه همسایه هسته. آمریکا همینتی از طریق [[آلاسکا]] با [[روسیه]] ئوسامون دانّه. به علاوه، مجموعه‌یی از جزیره‌ئون، ناحیه‌ئون، و مناطق متعلق به آمریکا سراسر جهون دله دکلستونه. مناطق جوغرافیایی و فرنگی آمریکا عبارتنه از: [[نیوانگلند]]، ایالتای ساحلی اطلس ِاقیانوس ،ایالت‌ئون جنوبی آمریکا ، ایالت‌ئون غرب میونه (میدوست) ، ایالت‌ئون جنوب غربی آمریکا و ایالت‌ئون غرب. کشور آمریکا در مجموع ۹٬۸۲۶٬۶۳۰ کیلومیتر موربع گتی دانّه <ref>[http://www.indexmundi.com/united_states/area.html United States Area - Geography]</ref> که البته ۴۷۰ هیزار کیلومیتر وه ره جزایر سِوا از هم و تحت قلمروو آمریکا [[آروم اقیانوس]] و [[دریای کارائیب]] دله تشکیل دنّه. == جوغرافیای آدمی == [[پرونده:Census-2000-Data-Top-US-Ancestries-by-County-1396x955Farsi.PNG|300px|left|thumb|اقوام و زوون مردم آمریکا (رِفاندم سال ۲۰۰۰)]] آمریکا سال 2009دله ۳۰۶٬۲۱۵٬۸۸۶ نفر تخمین جمعیت داشته <ref>[http://www.census.gov/main/www/popclock.html U.S. and World Population Clocks - POPClocks]</ref>. روشد جمعیت آمریکا، حدود ۰٫۹۷۵٪ هسته.<ref name=autogenerated2>[https://web.archive.org/web/20181226055200/https://www.cia.gov/library/publications/the-world-factbook/geos/us.html#People CIA - The World Factbook - United States]</ref> به اساس آمار دربموئه سال2003 اینان اقوام آمریکا بینه:<ref>[http://www.census.gov/popest/national/asrh/NC-EST2007-srh.html Population Estimates<!-- عونوان تصحیح شده توسط ربات -->]</ref> * [[اسپه پوست|اسپه]]‌ئون: ۸۱٪ * [[سیو پوست|سیو]] (آمریکایی‌ئون آفریقایی‌تِبار): ۱۲٫۹٪ * آسیایی: ۴٫۲٪ * [[سرخ پوستون|سرخپوستون آمریکایی]]‌: ۱٪ * [[هاوائی|هاوایی]] مردِم و جزایر [[آروم اقیانوس|پاسفیک]]: ۰٫۲٪ این آمار دله، نژاد اسپانیایی‌تبار (موسوم به [[هیسپانیک]]، یا لاتینو) همراه با اسپه‌ئون حیساب بیّه. بر اساس بررسی سال ۲۰۰۰ موهاجرون کشورون دیگه به ترتیب جمعیت برابر بینه: [[مکزیک]](۱۷۳٬۹۱۹ موهاجر)، [[چین]](۴۵٬۶۵۲)، [[فیلیپین]](۴۲٬۴۷۴)، [[هند]](۴۲٬۰۴۶)، [[ویتنام]](۲۶٬۷۴۷)، [[السالوادور]](۲۲٬۵۷۸)[[هائیتی]](۲۲٬۳۶۴)، [[کوبا]](۲۰٬۸۳۱)، [[دومینکن]](۱۷٬۵۳۶)، [[روسیه]](۱۷٬۱۱۰)، [[جامائیکا]](۱۶٬۰۰۰)[[کانادا]](۱۶٬۲۱۰)، [[کوره]](۱۵٬۸۳۰)، [[اوکراین]](۱۵٬۸۱۰)، [[پاکئون]](۱۴٬۵۳۵)، [[کلمبیا]](۱۴٬۴۹۸)، [[بریتانئون]](۱۳٬۳۸۵)، [[بوسنی و هرزگوین]](۱۱٬۸۲۸)، [[گواتمالا]](۹٬۹۷۰)، [[ئیران]](۸٬۹۱۵) <ref>{{یادکرد|فصل= United States (review)|کیتاب={{#if:|[ Microsoft Encarta 2006]|Microsoft Encarta 2006}}|ناشر= Microsoft|چاپ= |شهر= |کوشش= {{#if:|, {{چر}}}} |دچی‌ین= |سال= {{#if:|, {{چر}}}}2006 |شابک={{#if:|ISBN }} |نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= |ژورنال= |نشریه= |تاریخ= |دوره= |شوماره= |شاپا=}} {{#if:22-04-2009|Retrieved on 22-04-2009.}} </ref> == زوون == <div style="font-size: 90%"> {| class="wikitable" border="1" table cellspacing="0" style="border:1px black; float:left; margin-left:1em;" ! style="background:#F99;" colspan="2"|زوون‌ها (۲۰۰۵)<ref name="USCB Lang">{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= Statistical Abstract of the United States 2006 |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.census.gov/prod/2007pubs/08statab/pop.pdf Table 52—Languages Spoken at Home by Language: 2005] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=U.S. Census Bureau |تاریخ= {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2008-10-18|Retrieved on 2008-10-18.}} {{#if:|Retrieved on , {{چر}}.}}</ref> |- |''فقط'' [[انگلیسی آمریکایی]]||۲۱۶٫۲ میلیون |- |اسپانیایی (همراه کریول اسپانیایی)||۳۲٫۲ میلیون |- |چینی||۲٫۳ میلیون |- |فرانسوی (با زوون‌ئون کریول فرانسوی)||۱٫۹ میلیون |- |تاگالوگ||۱٫۴ میلیون |- |ویتنامی||۱٫۱ میلیون |- |آلمونی||۱٫۱ میلیون |} </div> کشور آمریکا رسمی زوون ندانه، ولی [[انگلیسی زبون]] همه جا گپ بزه وانه. هر کی بخائه بوره امیکا اول ونه انگلیسی زبون ره خار یاد بیره .<ref>[https://web.archive.org/web/20100328182034/http://www.uscis.gov/portal/site/uscis/menuitem.5af9bb95919f35e66f614176543f6d1a/?vgnextoid=12e596981298d010VgnVCM10000048f3d6a1RCRD General Naturalization Requirements<!-- عونوان تصحیح شده توسط ربات -->]</ref> همینتی [[انگلیسی زبون|انگلیسی]] ۲۸ ایالت به عونوان رسمی زوون بشناسی‌یه وانه. <ref>[http://www.independent.co.uk/news/world/americas/at-last-america-has-an-official-language-and-yes-its-english-478896.html Senate Makes English Official Language of the United States]</ref><ref>{{یادکرد وب | نشونی = http://www.senate.gov/legislative/LIS/roll_call_lists/roll_call_vote_cfm.cfm?congress=110&session=1&vote=00198 | عونوان = Amendment of Title 4 of United States Code | تاریخ = ۶ ژوئن ۲۰۰۷ | تاریخ بدی‌ین = ۶ آوریل ۲۰۰۸ |ناشر = مجلس سنای متحده ایالات | زوون = انگلیسی زبون }}</ref> زوونای آمریکا اینان هستنه :<ref>[http://www.census.gov/prod/2007pubs/08statab/pop.pdf Statistical Abstract of the United States: 2008<!-- عونوان تصحیح شده توسط ربات -->]</ref>: * [[انگلیسی زبون]]: ۸۲٫۱٪ * [[اسپانیولی]]: ۱۰٫۷٪ * بقیه زوونای هند و ئوروپایی: ۳٫۸٪ * زوون‌ئون آسیایی و اقیانوسیه: ۲٫۷٪ * بقیه زوون‌ئون: ۰٫۷٪. == تاریخ == [[پرونده:Native American Chiefs 1865.jpg|left|thumb|اولین آدمایی که آمریکا دله دینه [[سرخ پوستون]] بینه.]] [[پرونده:Washington_Crossing_the_Delaware_by_Emanuel_Leutze,_MMA-NYC,_1851.jpg|thumb|left| [[جرج واشنگتن]] عکس دله دره بریتانئون جه جنگ کاند اونجه هم [[دلاویر|دلاویر روخنه]] هسته.]] الآن ده هیزار ساله که آمریکا دله مردِم زندگی کانّه.<ref>''One vast winter count: the Native American West before Lewis and Clark''. Colin Gordon Calloway. Published by U of Nebraska Press, 2003. ISBN 0-8032-1530-4 pp.27</ref> [[کریستف کلمب]] سال ۱۴۹۲ اول آمریکا ره پیدا هکرده ولی وه فکر هاکرده اونجه هندوستون هسته ات مدت بعد [[آمریگو وسپوچی]] ایعلام هکرده که اینتا اتا جدید ِقاره هسته. <ref>{{یادکرد |فصل=ئوروپای رونسانس |کیتاب=ئیران و جهون تاریخ 1 |نویسنده = مسعود جوادیان، عبدالرسول خیراندیش، جواد عباسی و طوبی فاضلی |ناشر =شرکت چاپ و نشر کیتاب‌های درسی ایران |چاپ=شیشوم |صفحه=۲۲۰ |سال=۱۳۸۴ |شابک=ISBN 964-05-0734-2 }}</ref> اما تاریخ آمریکا به عونوان اتا کشور موستقل به سال ۱۷۸۳ میلادی برگردنه که آمریکا معاهده پاریس دله رسمیت پیدا هکرده.<ref name=autogenerated1>[https://web.archive.org/web/20181226055200/https://www.cia.gov/library/publications/the-world-factbook/geos/us.html CIA - The World Factbook - United States<!-- عونوان تصحیح شده توسط ربات -->]</ref> قبل از ایعلام هستهقلال آمریکا <ref>[http://www.ourdocuments.gov/doc.php?flash=true&doc=2 Our Documents - Declaration of Independence (1776)<!-- عونوان تصحیح شده توسط ربات -->]</ref>، اونجه مجموعه‌ئی از موستعمرات ئوروپایی بی‌یه. مثلأ، [[ایسپانیا]]یی‌ئون [[فلوریدا|فلوریدای]] دله ساکن بینه، [[بریتانئون|انگلیسی‌ئون]] [[جیمز تاون]] ِ [[ویرجینیا|ویرجینیای]] دله دینه، [[هلند]]یا [[نیو آمستردام]] ره که الان [[نیویورک]] گانه وه ره، و [[فرانسه|فرانسویا]] هم ایالت جنوبی [[لوئیزیانا]] و اطراف [[میسیسیپی]] ره بیت بینه. کم‌کم، قسمت‌ئونی زیادی از موستعمرات سیزده‌گونه با بریتانئون جنگ هاکردنه. اینتی امریکای انقیلاب آوریل ۱۷۷۵ با [[جنگ لگزینگتون]] شروع بیّه، و سال ۱۷۸۳ با ایمضاء قرارداد صلح با بریتائون تموم بیّه. هستهقلال ۱۳ مستعمرهٔ آمریکای شومالی با صدور ایعلامیه ایستیقلال آمریکا [[شابلون:ویکی‌پدیا:امروز واری روز/۴ جولای|۴ جولای]] [[۱۷۷۶]] دله دِرِس بیّه.<ref name="C" /> آمریکا اول ۱۳ ایالت خودمختار داشته فرق داشتن قوانین هر ایالت مثل مالیات به واردات باعث رکود ایقتیصادی و در نتیجه شورش‌ئون مثل [[شورش شیمز]] بیّه به همین دلیل ۵۵ نماینده از ۱۲ ایالت (به جز رودآیلند) در فیلادلفیا منجومله [[جورج واشنگتن]] ، [[بنیامین فرانکلین|بنجامین فرانکلین]] و [[جیمز مدیسون]] قانون اساسی متحده ایالات آمریکا ره تصویب هکردنه که الان هم قانون اساسی آمریکا هسته و از اون موقع ۲۵ اصلاحیه بخارده.<ref name="C">{{یادکرد|فصل= |کیتاب={{#if:|[ بنیانگذاری آمریکا و قانون اساسی آن]|بنیانگذاری آمریکا و قانون اساسی آن}}|ناشر= ققنوس |چاپ= |شهر= |کوشش= {{#if:|, {{چر}}}} |دچی‌ین= تاریخ جهون |سال=۱۳۸۷|شابک={{#if:|ISBN }} |نویسنده=بجورنلوند{{#if:لیدیا|، {{چر}}لیدیا}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=fa |مقاله= |ژورنال= |نشریه= |تاریخ= |دوره= |شوماره= |شاپا=}}</ref> با شروع قرن جدید و دکش‌هاکردن نیشتنگاء از [[فیلادلفیا]] به [[واشینگتن|واشنگتن دی سی]] و خرید لوئیزیانا سال ۱۸۰۳دله، سال ۱۸۱۲ دله ارتش بریتانئون بار دیگه به آمریکا قشون‌کشی هکرده و نیشتنگاء جدید ره به تـَش دمبدائه، ولی جنگ ره بباخته. امریکا دله دِتا گت اتفاق دکته. اتا جنگ داخلی آمریکا قرن نوزدهم په بی‌یه، و دخاتن ِبازار آزاد اواخر دهه ۱۹۲۰ میلادی دله بی‌یه. سال ۱۸۶۱ جنگ داخلی آمریکا که ۶۰۰٬۰۰۰ تلفات و ۵۰۰٬۰۰۰ نفر زخمی داشته شروع بیّه.<ref>''From Lexington to Desert Storm and beyond: war and politics in the American experience''. Donald M. Snow, Dennis M. Drew. Published by M.E. Sharpe, 2000. ISBN 0-7656-0699-2 pp.60</ref> علت این جنگ به برده‌داری ۱۱ ایالت جنوبی مشهور به "ایالات مؤتلفه آمریکا" مربوط بی‌یه که [[آبراهام لینکلن]] خهستهه وه ره از بین بوره. این جنگ سال 1865 با بوردن شومالی‌ئون به فرماندهی [[یولیسیز سایمن گرانت]]، تموم بیّه. <ref>[http://www.nps.gov/history/logcabin/html/usg2.html History: Ulysses S. Grant: The Hero of the Civil War<!-- عونوان تصحیح شده توسط ربات -->]</ref> دخاتِن بازار امریکا ۱۹۲۹ باعیث بیّه که 4سال دله کل مردم آمریکا بی‌کار بواشن.<ref name=autogenerated1 /> با بَوردن [[جهونی جنگ اول]]، رِقِدهدائن متفقین [[جهونی جنگ دوم]] دله و شکست نهایی [[آلمان]] و خراب بیّن ایقتیصاد ئوروپا ، آمریکا که کمترین خسارات ره بدی‌بی‌یه، گت بیّه. از بین بوردن [[شوروی|اتحاد جماهیر شوروی]] باعیث بیه تا آمریکا [[جنگ سرد]]، [[جنگ ویتنام]]، و [[جنگ کره]] دله دیگه رقیب نداره<ref>''Encyclopedia of American foreign policy''. Alexander DeConde, Richard Dean Burns, Fredrik Logevall. Published by Simon and Schuster, 2002. ISBN 0-684-80657-6 pp.309</ref> [[حملات ۱۱ سپتامبر|وقایع یازدهم سپتامبر]] باعیث بیّه تا آمریکایی‌ئون شه سربازا ره بیارن خاورمیونه دله و اینجه چنتا جنگ ره سر بیرن. == نیظام سیاسی == نیظام سیاسی آمریکا چارچوب اتا [[قانون اساسی]] و به صورت اتا "نیظام فدرالی" هسته که از ویژگی‌ئون حکومتی این کشور به شومار شونه. "سیستم سِوا هکردن قوا" این کشور دله خله تابلوئه. بونیان گوذاران و نویسندگون "ایعلامیه ایستقلال متحده ایالات آمریکا" و قانون اساسی متحده ایالات به دلیل نگرانی از دِرِس بیّن نیظام سلطنتی ئوروپایی که ونه دله [[شاء]] قودرت داره، نیظام سیاسی ره اتی بساتنه که ات نفر نتونه کل قودرت ره شه دست دله بیره. <ref>[https://web.archive.org/web/20090501220644/http://www.ncsl.org/programs/legismgt/SeparationPowers.htm Separation of Powers<!-- عونوان تصحیح شده توسط ربات -->]</ref> همینتی اتی وه ره بساتنه که اکثریت همیشه اقلیت ره سر بوئه<ref>[https://web.archive.org/web/20090210203355/http://usconstitution.net/consttop_sepp.html#america Constitutional Topic: Separation of Powers - The U.S. Constitution Online - USConstitution.net<!-- عونوان تصحیح شده توسط ربات -->]</ref> <ref>گفتهٔ جیمز مدیسون:<br />The system of checks and balances is designed to allow each branch to restrain abuse by another branch</ref> بر اساس قانون اساسی آمریکا، قوهٔ مقننه یا '''کونگره آمریکا''' از دِتا مجلس تشکیل بیّه که مسؤولیت قانونگوذاری ره به طور کامل به عوهده دارنه: "مجلس نمایندگون" و "مجلس سنا". بر اساس "نیظام اینتیخابی متحده ایالات دله" ، نمایندگون با رأی موستقیم و برابر مردِم انتیخاب وانّه. <ref>[http://www.law.cornell.edu/constitution/constitution.articlei.html LII: Constitution<!-- عونوان تصحیح شده توسط ربات -->]</ref> <center><gallery> پرونده:United states supreme court building.png|'''قوهٔ قضائیه''': دیوان عالی فدرال متحده ایالات آمریکا WhiteHouseSouthFacade.JPG|'''قوهٔ مجریه''': [[اسپه کاخ]]، محل کار و زندگی رییس جومور امریکا Capitol Building Full View.jpg|'''قوهٔ مقننه''': [[ساختمون کاپیتول]] محل همیشگی "کونگره متحده ایالات آمریکا" </gallery></center> <center><gallery> John Roberts.jpg|"جان جی.رابرتس" ، قاضی ارشد "دیوان عالی فدرال متحده ایالات " Nancy Pelosi.jpeg|"نانسی پلوسی" رئیس "مجلس نمایندگان" متحده ایالات Donald Trump official portrait.jpg|[[دونالد ترامپ]]"رئیس جومور آمریکا" </gallery></center> '''رییس جومور متحده ایالات''' هم به عونوان رئیس قوهٔ مجریه و فرمانده کل قوا با رأی موستقیم مردم و از طریق آرای "هیات الکترال" انتخاب وانه و شه وزیرا ره انتخاب کانده. ولی لازم نی‌یه که وشون دیی بوئن ِوسّه رای اعتماد بیره. سومین شاخه از نیظام سیاسی آمریکا، "سیستم حقوقی امریکا" هسته که کاملاً موستقل عمل کانده و قوهٔ مجریه و قوهٔ مقننه نتونه ونه سر تاثیر بیلنوانه بئوتن که رییس جومور یا کونگره نتونه رای '''دیوان عالی آمریکا''' ره باطل هکنن. نیظام حزبی هم شکل‌هدائن به سیاست و حکومت این کشور دله نقش دانّه. == سیاست خارجی == [[پرونده:Secretary Clinton 8x10 2400 1.jpg|thumb|"هیلاری رودهام کلینتون" وزیر امور خارجی متحده ایالات، وزارت امور خارجه این کشور مسئول رسمی سیاست خارجی آمریکا هسته.]] متحده ایالات آمریکا به کومک توانایی‌ئون ایقتیصادی و نیظامی قابل توجه خادش، نقش موهمی ره سیاست جهونی دله ایفا کانده. این کشور عضو ثابت "شورای امنیت سازمان ملل" هسته و دفتر مرکزی :[سازمان ملل متحد" هم نیویورک دله دره. به استثای کشورون [[ئیران]]، [[شومالی کوره]]<ref name="لس آنجلس تایمز">{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://articles.latimes.com/2008/mar/04/world/fg-norkor4 U.S. relations with North Korea possible, diplomat says] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه= |تاریخ=4 March 2008 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2009-04-16|Retrieved on 2009-04-16.}} {{#if:|Retrieved on , {{چر}}.}}</ref>، [[تایوان]]، [[بوتان]]<ref name="the Bureau of Consular Affairs, U.S. Department of State">{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://travel.state.gov/travel/cis_pa_tw/cis/cis_1068.html Country Specific Information] {{#if:انگلیسی|(انگلیسی)}} {{#if:|()}} |ژورنال= |نشریه= |تاریخ=April 25, 2008 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2009-04-16|Retrieved on 2009-04-16.}} {{#if:|Retrieved on , {{چر}}.}}</ref> و [[سودان]]، [[کوبا]]، [[ونزوئلا]] و [[بولیوی]] <ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://edition.cnn.com/2008/WORLD/americas/09/12/venezuela.us/index.html U.S. expelling Venezuelan envoy in response to Chavez] {{#if:English|(English)}} {{#if:|()}} |ژورنال= |نشریه=[[سی‌ان‌ان|CNN]] |تاریخ=12 September 2008 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2009-04-17|Retrieved on 2009-04-17.}} {{#if:|Retrieved on , {{چر}}.}}</ref>، بقیه کشورون با امریکا روابط دیپلوماتیک دارنه. آمریکا بوسیله "قرارداد تجارت آزاد آمریکای شومالی" و "سازمان کشورون آمریکایی" با همسایه‌ئون خادش ( [[کانادا]] و [[مکزیک]] ) روابط نزدیکی دانه. دولت این کشور هرساله میلیاردا دلار کومک مالی برای توسعه کشورون دیگه اختصاص دنه، اما درصد این کومکا از تولید ناخالص میلی نسبت به دیگر کشورون کومک کوننده، پائین هسته. رئیس جومور آمریکا اتا از عوامل اصلی تعیین کونندهٔ جهت‌ئون کلی سیاست خارجی آمریکا هسته. بسیاری از مدارک و اسناد دوران هر رئیس جومور امروزه کیتاب‌خنه‌ئون ویژه هر رئیس جمهور دله درنه. کونگره آمریکا بودجه‌ئون کومکای خارجی ره تعیین کانده، تحریم‌ئون خارجی وضع کانده، و به کومک کمیته‌ئون مخصوصی مسائل سیاست خارجه دله اختیارات بررسی و هارشائن امور ویژه ره دانه. هر دور سیاستون خارجی امریکا با عوض بیّن حزب‌ئون تغییر کانده دِتا حزب اصلی امریکا "جوموری‌خاء" و "دموکراتیک" هستنه. <ref>[https://web.archive.org/web/20081220124800/http://www.cfr.org/publication/9488/ U.S. Political Parties and Foreign Policy - Council on Foreign Relations<!-- عونوان تصحیح شده توسط ربات -->]</ref> [[لابی (سازمان)|گروه‌ئون لابی]] هم سیاستون خارجی دله نفوذ زیادی دارنه. == ایالت‌ئون == کشور آمریکا ۵۰ ایالت دانه که هر کدوم از وشون بنا بر سامونه فدرالی حاکم، ات جور خودموختار حکومت هستنه. البته ناحیهٔ [[واشینگتن|واشنگتن دی سی]] جزو هیچ کدوم از ایالات آمریکا نیسته و "منطقه خودموختار کلمبیا" دله دره. ناحیهٔ کلمبیا، اولا بخشی از ایالت [[مریلند]] بی‌یه که سال ۱۷۹۰ برای تأسیس نیشتنگاء آمریکا یعنی شهر واشنگتن در نظر بیت‌بیّه. {{نقشه متحده ایالات}} == شهرهای آمریکا == [[پرونده:Vista aérea de Times Square desde el Empire State Building.jpg|thumb|250px|[[نیویورک|شهر نیویورک]]، گت‌ترین شهر آمریکا، به «گت ِسه»(به فارسی:سیب بزرگ) شوهرت دانّه.]] [[پرونده:Los Angeles, CA from the air.jpg|250px| [[لس‌آنجلس]] که دومین شهر گت ِآمریکا هسته.|thumb]] [[پرونده:Good Bye Chicago.jpg|thumb|250 px|شیکاگو، سومین شهر گت متحده ایالات]] {| class="wikitable" style="text-align:right; margin-right:۶۰px" |- !rowspan=۲|رتبه !rowspan=۲ align=center |شهر !rowspan=۲|جمعیت<br /><small> محدوده شهری<br />(۲۰۰۸)<ref>http://www.census.gov/popest/cities/tables/SUB-EST2008-01.csv</ref></small> !rowspan=۲| ایالت |- | ۱ ||align=right | [[نیویورک]] || '''۸٬۳۶۳٬۷۱۰''' ||نیویورک |- | ۲ ||align=right | [[لس‌آنجلس]] || '''۳٬۸۳۳٬۹۹۵''' ||[[کالیفرنیا] |- | ۳ ||align=right | [[شیکاگو]] || '''۲٬۸۵۳٬۱۱۴''' ||[[ایلینوی]] |- | ۴ ||align=right | [[هیوستون|هوستون]] || '''۲٬۲۴۲٬۱۹۳''' ||[[تگزاس]] |- | ۵ ||align=right | [[فینیکس]] || '''۱٬۵۶۷٬۹۲۴''' ||[[آریزونا]] |- | ۶ ||align=right | [[فیلادلفیا]] || '''۱٬۴۴۷٬۳۹۵''' ||[[پنسیلوانیا]] |- | ۷ ||align=right | [[سن‌آنتونیو]] || '''۱٬۳۵۱٬۳۰۵''' ||[[تگزاس]] |- | ۸ ||align=right | [[دالاس]] || '''۱٬۲۷۹٬۹۱۰''' ||[[تگزاس]] |- | ۹ ||align=right | [[سن دیگو|سن دییگو]] || '''۱٬۲۷۹٬۳۲۹''' ||[[کالیفرنیا]] |- |۱۰ ||align=right | [[سن خوزه]] || '''۹۴۸٬۲۷۹''' ||[[کالیفرنیا]] |} {| class="wikitable" style="text-align:right; margin-right:۶۰px" |- !rowspan=۲|رتبه !rowspan=۲ align=center |شهر با حیساب حومه ! rowspan=۱ colspan=۲|جمعیت<br /><small>(۲۰۰۹)<ref>http://www.census.gov/popest/metro/files/2009/CBSA-EST2009-alldata.csv</ref></small> !rowspan=۲| ایالت |- | ۱ ||align=right | [[نیویورک]]-[[نیوآرک]]-[[لانگ آیلند]]-[[جرزی سیتی]] || '''۱۹٬۰۶۹٬۷۹۶''' ||نیویورک -[[نیوجرسی]] |- | ۲ ||align=right | [[لس‌آنجلس]] || '''۱۷٬۷۸۶٬۴۱۹''' ||[[کالیفرنیا]] |- | ۳ ||align=right | [[شیکاگو]] || '''۹٬۵۸۰٬۵۶۷''' ||[[ایلینوی]]-[[ایندیانا]] |- | ۴ ||align=right | منطقه دالاس-فورت وورث || '''۶٬۴۴۷٬۶۱۵''' ||[[تگزاس]] |- | ۵ ||align=right | [[فیلادلفیا]]- [[کمدن]]-[[ویلمینگتن]] || '''۵٬۹۶۸٬۲۵۲''' ||[[پنسیلوانیا]]-[[نیوجرسی]]-[[دلاویر]] |- | ۶ ||align=right | [[هیوستون]]-[[شوگرلند]]-[[گلوستون]] || '''۵٬۸۶۷٬۴۸۹''' ||[[تگزاس]] |- | ۷ ||align=right | [[میامیفورت لادردیل-وست پالم بیچ || '''۵٬۵۴۷٬۰۵۱''' ||[[فلوریدا]] |- | ۸ ||align=right | [[واشینگتن دی.سی.]]- [[آرلینگتن]] || '''۵٬۴۷۶٬۲۴۱''' ||ناحیه کلمبیا-[[مریلند]]-[[ویرجینیا]] |- | ۹ ||align=right | [[آتلانتا]] || '''۵٬۴۷۵٬۲۵۳''' ||[[جورجیا|جرجیا]] |- |۱۰ ||align=right | [[بوستون]] || '''۴٬۵۸۸٬۶۵۰''' ||[[ماساچوست]] |- |۱۱ ||align=right | [[دیترویت|دترویت]]-[[ان آربر]] || '''۴٬۴۰۳٬۴۳۷''' ||[[میشیگان]] |- |۱۲ ||align=right | [[فینیکس]]- گلندیل-میزا- [[سکاتزدیل]] || '''۴٬۳۶۴٬۰۹۴''' ||[[آریزونا]] |- |۱۳ ||align=right | [[سان‌فرانسیسکو]]-[[اوکلند]]-منطقه خلیج سانفرانسیسکو || '''۴٬۳۱۷٬۸۵۳''' ||[[کالیفرنیا]] |- |۱۴ ||align=right | [[سیاتل|سیتل]]-[[تاکوما]]-[[بلویو]] || '''۳٬۴۰۷٬۸۴۸''' ||[[واشینگتن]] |- |۱۵ ||align=right | [[مینیاپولیس]]-[[سینت‌پال]] || '''۳٬۲۶۹٬۸۱۴''' ||[[مینسوتا]] |} == آموزش و پژوهش == [[پرونده:Buzz_salutes_the_U.S._Flag.jpg|thumb|left|پرچم آمریکا روی [[ماه|کره ماه]] ، آپولو ۱۷ زمون.]] پول آموزش و تحصیلات سطوح مدرسه‌ئی و متوسطه ره اکثراً دولت دنه. متحده ایالات با داشتن نزدیک به ۵٬۸۰۰ دانشگاه و یا مؤسسه آموزش عالی<ref>{{یادکرد وب | نشونی = http://www.aneki.com/universities.html | عونوان = Countries with Most Universities | تاریخ بدی‌ین = ۵ آوریل ۲۰۰۸ | زوون = انگلیسی }}</ref> تقریبا تونده تموم مردم ره درس یاد بده. وام‌ئون کم‌بهره، کومک هزینه‌ئون بلاعوض، و انواع بورس‌ئون تحصیلی، از اقسام راه‌ئونی هستنه که دانشجوئون ایقدام به پرداخت شهریه‌ئون شه کانه. این میون "دانشگاه ایالتی اوهایو" با داشتن ویشته از ۵۳٬۷۱۵ دانشجو اتا پردیس دله، پرجمعیت‌ترین دانشگاه آمریکا هسته. <ref>[http://www.bizjournals.com/dayton/stories/2008/10/20/daily3.html Ohio State named nation’s largest college – again - Dayton Business Journal:<!-- عونوان تصحیح شده توسط ربات -->]</ref> میون آمریکاییا بالای ۲۵ سال، ۸۴٫۶ درصد از دبیرستون فارغ‌التحصیل بینه، ۵۲٫۶ درصد کالج دله شونه ، ۲۷٫۲ درصد مدرک کارشیناسی دریافت هکردنه، و ۹٫۶ درصد دارای مدارک کارشیناسی ارشد و بالاته هستنه.<ref>{{یادکرد وب | نشونی = http://www.census.gov/prod/2004pubs/p20-550.pdf | عونوان = Educational Attainment in the United States: 2003 | تاریخ بدی‌ین = ۶ آوریل ۲۰۰۸ | زوون = انگلیسی |قالب= PDF }}</ref> تقریبا ۹۹ درصد آمریکاییا حداقل سواد پایه دارنه. در طبقه‌بندی سازمان ملل متحد، شاخص آموزشی در کشور متحده ایالات ۰٫۹۷ هسته که رتبه دوازدهم جهونی دله دره.<ref>Human Development Indicators</ref> == ایقتیصاد == [[پرونده:NYC_NYSE.jpg|thumb|left|ورودی ساختمان "بورس اوراق بهادار نیویورک"، "وال هستهریت" دله، گت ترین بازار بورس جهونی هسته]] [[پرونده:Cornfields of Hanover Township, Columbiana County.jpg|thumb|تولیدات کشاورزی]] متحده ایالات آمریکا ایقتیصاد "کاپتالیستی" از نوع سرمایه‌داری انحصاری دانه.ویژگی بارز ایقتیصاد متحده ایالات عبارته از تسلط انحصارون رشته‌ئون موختلف دله، که بر مبنای منابع طبیعی فراوون، زیربنای توسعه‌دکته، تولید زیاد، و مصرف زیاد استوار هسته. تولید ناخالص داخلی آمریکا ویشته از ۱۳ تریلیون [[دلار]]، <ref>{{یادکرد وب | نشونی = https://www.cia.gov/library/publications/the-world-factbook/rankorder/2001rank.html | عونوان = Rank Order - GDP (purchasing power parity) | تاریخ بدی‌ین = ۵ آوریل ۲۰۰۸ | زوون = انگلیسی }}</ref> یعنی حدود ۲۰٪ تولید ناخالص جهون، اولین ایقتیصاد بزرگ جهون هسته. <ref>[http://www.cnn.com/2009/WORLD/asiapcf/01/15/china.economy/index.html China passes Germany in economic rankings - CNN.com<!-- عونوان تصحیح شده توسط ربات -->]</ref> متحده ایالات گت‌ترین واردکوننده، و - بعد از [[آلمان]] و [[چین]] - سومین صادرکونندهٔ جهون هسته. <ref>[https://web.archive.org/web/20080423205710/http://www.radiofarda.com/Article/2008/04/19/f3_oil_Iran.html بهای نفت به رکورد تازه ۱۱۷ دلار در بشکه رسید - © 2009تمام حقوق این وب‌سایت بر اساس قانون کپی‌رایت برای رادیو فردا محفوظ هسته<!-- عونوان تصحیح شده توسط ربات -->]</ref> [[کانادا]]، [[چین]]، [[مکزیک]]، [[جاپون]] و [[آلمان]]، به ترتیب گتترین شریکای تجاری آمریکا هستنه.<ref>[http://www.census.gov/foreign-trade/top/dst/current/balance.html Top Ten Countries with which the U.S. Trades]</ref> امریکا این دهه دله گت‌ترین بدهی جهون ره هم داشته .<ref>[https://web.archive.org/web/20090206103043/http://political-analysis.org/ww/id8.html The U.S. National Debt and How It Got So Big]</ref> گت‌ترین وسیله‌ئون صادراتی آمریکا به ترتیب تجهیزات صنعتی (۲۹٫۸٪)، ماشین‌آلات (۲۹٫۵٪)، کالائون مصرفی غیر اتومبیل (۱۲٫۴٪)، خودرو و تولیدات وابسته (۹٫۳٪)، تولیدات صنایع غذایی (۸٫۳٪)، و تولیدات صنایع هوایی (۶٫۶٪) هستنه ، ولی گت‌ترین چیزای وارداتی به آمریکا وسیله‌ئون مصرفی غیر اتومبیل (۲۳٪)، سوخت (۲۲٫۱٪)، ماشین‌آلات (۱۹٫۹٪)، تجهیزات صنعتی (۱۴٫۸٪)، تولیدات خودرو (۱۱٫۱٪)، صنایع غذایی (۴٫۲٪)، و صنایع هوایی (۱٫۷٪) هسته.<ref>آمار منتشره سال ۲۰۰۸ میلادی</ref> اما گت‌ترین محصولات تولیدی آمریکا مواد شیمیایی، تولیدات نفتی، فولاد، خودرو، تولیدات صنایع هوایی، ارتباطات، الکترونیک، تولیدات غذایی و مصرفی، و صنایع معدن و چو هستنه. <ref>http://www.bea.gov/industry/gpotables/gpo_action.cfm?anon=326®istered=0&table_id=23981&format_type=0</ref> آمریکا برق ِدِرِس هاکردن <ref>[https://web.archive.org/web/20130309182439/https://www.cia.gov/library/publications/the-world-factbook/rankorder/2038rank.html CIA - The World Factbook - Country Comparison :: Electricity<!-- عونوان تصحیح شده توسط ربات -->]</ref>، ظرفیت پالایش [[نفت]]<ref>[http://www.bp.com/liveassets/bp_internet/globalbp/globalbp_uk_english/reports_and_publications/statistical_energy_review_2007/STAGING/local_assets/downloads/spreadsheets/statistical_review_full_report_workbook_2007.xls#'Oil - Refinery capacities'!A1]</ref>، ذخیره‌ئون ذغال سنگ <ref>http://www.bp.com/liveassets/bp_internet/globalbp/globalbp_uk_english/reports_and_publications/statistical_energy_review_2007/STAGING/local_assets/downloads/spreadsheets/statistical_review_full_report_workbook_2007.xls</ref>، تولید انرژی با وا <ref>[https://web.archive.org/web/20100117181731/http://cleantechnica.com/2008/12/27/us-becomes-largest-wind-power-producer-in-the-world/ US Becomes Largest Wind Power Producer in the World: CleanTechnica<!-- عونوان تصحیح شده توسط ربات -->]</ref>، و [[انرژی هسته‌ای]]<ref>[https://web.archive.org/web/20120114011707/http://www.world-nuclear.org/info/reactors.html Nuclear Power Reactors and Uranium Requirements:<!-- عونوان تصحیح شده توسط ربات -->]</ref> دله ، رتبه اول ره دانّه. ویشته چرخه ایقتیصادی آمریکا موتعلق به بخش خصوصی هسته، تا جایی که بخش دولتی فقط ۱۲٫۴٪ تولید ناخالص میلّی ره سالیونه سازنه.<ref>[http://www.bea.gov U.S. Bureau of Economic Analysis (BEA) - bea.gov Home Page<!-- عونوان تصحیح شده توسط ربات -->]</ref> با این حال ۷۵٪ تولید ناخالص میلّی محصول بخش خدماتی هسته. با ایکه تولیدات کشاورزی آمریکا حدود ۱٪ تولید ناخالص میلّی این کشور هسته، همنده تولید حدود ۶۰٪ کل تولیدات کشاورزی جهون ره تشکیل دنه. {| class="wikitable" border="1" table cellspacing="0" style="border:1px black; float:left; margin-left:1em;" |- ! style="background:#F99;" colspan="2"|شاخصای ایقتیصادی |- |نرخ بیکاری||۹,۷٪ <sup>مارس ۲۰۱۰</sup><ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.bls.gov/news.release/empsit.nr0.htm Employment Situation Summary] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=U.S. Dept. of Labor |تاریخ=2009-04-03 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2009-04-04|Retrieved on 2009-04-04.}} {{#if:|Retrieved on , {{چر}}.}}</ref> |- |روشد تولید ناخالص داخلی||۶٫۲٪- <sup>ربع چهارم سال ۲۰۰۸<br /></sup>۱٫۱٪ <sup>در طول سال ۲۰۰۸</sup><ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.bea.gov/national/xls/gdpchg.xls Gross Domestic Product] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=Bureau of Economic Analysis |تاریخ=2009-02-27 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2009-02-28|Retrieved on 2009-02-28.}} {{#if:|Retrieved on , {{چر}}.}} Quarterly growth is expressed as an annualized rate.</ref> |- |تورم شاخص بهای مصرف‌کننده||۰٪ <sup>ژانویه ۲۰۰۸–۲۰۰۹</sup><ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.bls.gov/news.release/pdf/cpi.pdf Consumer Price Index: November 2008] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=U.S. Dept. of Labor |تاریخ=2009-02-20 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2009-02-28|Retrieved on 2009-02-28.}} {{#if:|Retrieved on , {{چر}}.}}</ref> |- |بدهی||۱۰۸۸۱ میلیارد دلار<sup>فوریه ۲۶، ۲۰۰۹</sup><ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.treasurydirect.gov/NP/BPDLogin?application=np Debt Statistics] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=U.S. Dept. of the Treasury |تاریخ= {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2009-02-28|Retrieved on 2009-02-28.}} {{#if:|Retrieved on , {{چر}}.}}</ref> |- |میزان فقر||۱۲٫۵٪ <sup>۲۰۰۷</sup><ref name="CBPR08">{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.census.gov/Press-Release/www/releases/archives/income_wealth/012528.html Household Income Rises, Poverty Rate Unchanged, Number of Uninsured Down] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=U.S. Census Bureau |تاریخ=2008-08-26 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2008-09-06|Retrieved on 2008-09-06.}} {{#if:|Retrieved on , {{چر}}.}}</ref> |} بخش بهداشت و خدمات ایجتیماعی با داشتن ۱۶ میلیون نفر کارگر، گت‌ترین بخش کاری آمریکا ره سازنه.<ref>[http://www.census.gov/prod/2006pubs/07statab/business.pdf Statistical Abstract of the United States: 2007<!-- عونوان تصحیح شده توسط ربات -->]</ref> از لحاظ مجموع ساعات کاری طول سال، آمریکایی‌ئون ویشترین تعداد روز سال ره کار کانّه. <ref>[https://web.archive.org/web/20090225083027/http://www.ilo.org/global/About_the_ILO/Media_and_public_information/Press_releases/lang--en/WCMS_071326/index.htm Americans work longest hours among industrialized countries, Japanese second longest. Europeans work less Time, but register faster productivity gains New ILO statistical volu...<!-- عونوان تصحیح شده توسط ربات -->]</ref> ولی همینتی موقایسه با کشورون صنعتی دیگه، از نظر تولید به حسب ساعات کاری آمریکایی‌ئون از بعضی کشورون ئوروپایی عقب‌تر درنه .<ref>[https://web.archive.org/web/20090608164943/http://www.ilo.org/global/About_the_ILO/Media_and_public_information/Press_releases/lang--en/WCMS_082827 Working Time Around the World]</ref> میون ۵۰ ایالت آمریکا، از لحاظ درآمد سرانه <ref>Median Household Income</ref>، ایالت "نیوجرسی" رتبه اول ، و "ایالت میسیسیپی" رتبه آخر دره. <ref>[http://www.census.gov/hhes/www/income/income07/statemhi.html Income 2006 - Two-Year-Average Median Household Income by State: 2001-2005<!-- عونوان تصحیح شده توسط ربات -->]</ref> نزدیک به ۱۳٪ آمریکاییا زیر خط فقر درنه. <ref>[http://www.infoplease.com/ipa/A0104520.html Poverty in the United States, 2007 — Infoplease.com<!-- عونوان تصحیح شده توسط ربات -->]</ref> و فاصله طبقاتی بین بالاترین و پایین‌ترین اقشار جامعه آمریکا در حال ویشته بیّن هسته. <ref>[http://www.nytimes.com/2007/03/29/business/29tax.html Income Gap Is Widening, Data Shows]</ref> === حمل و نقل === [[پرونده:Map of current Interstates.svg|thumb|گت‌راه‌ئون میون ایالتی که ۴۶۸۷۶ مایل هستنه .<ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.fhwa.dot.gov/interstate/faq.htm#question3 Interstate FAQ (Question #3)] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=Federal Highway Administration |تاریخ= {{#if:|, {{چر}}}}2006 |دوره= |شوماره= |شاپا=}} {{#if:2009-03-04|Retrieved on 2009-03-04.}} {{#if:|Retrieved on , {{چر}}.}}</ref>]] سال ۲۰۰۳ هر ۱٬۰۰۰ آمریکایی وسّه ۷۵۹ "ماشین" دیّه <ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://europa.eu/rapid/pressReleasesAction.do?reference=STAT/06/125 Car Free Day 2006: Nearly One Car per Two Inhabitants in the EU25 in 2004] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=Europa, Eurostat Press Office |تاریخ=2006-09-19 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2007-08-15|Retrieved on 2007-08-15.}} {{#if:|Retrieved on , {{چر}}.}}</ref> و هر آمریکایی اتا روز دله ۵۵ دقیقه (یا ۲۹ مایل) ماشین جه ایستیفاده کانده.<ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= 2001 National Household Travel Survey |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.bts.gov/publications/highlights_of_the_2001_national_household_travel_survey/html/section_02.html Daily Passenger Travel] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=U.S. Dept. of Transportation, Bureau of Transportation Statistics |تاریخ= {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2007-08-15|Retrieved on 2007-08-15.}} {{#if:|Retrieved on , {{چر}}.}}</ref> ولی در عوض امریکای راه‌آهن کم‌ته از ماشینا هسته.<ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.gao.gov/products/GAO-07-15 Intercity Passenger Rail: National Policy and Strategies Needed to Maximize Public Benefits from Federal Expenditures] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=U.S. Government Accountability Office |تاریخ=2006-11-13 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2007-06-20|Retrieved on 2007-06-20.}} {{#if:|Retrieved on , {{چر}}.}}</ref> از نظر "حمل و نقل عمومی" ، فقط ۹٪ از سفرا از طریق قطار انجوم وانه در صورتی که ئوروپا دله ۳۸٪سفرا ریل جه انجوم وانه. <ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} Renne, John L., and Jan S. Wells|نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.policy.rutgers.edu/vtc/documents/TOD.Euro-Style_Planning-Renne-Wells.pdf Emerging European-Style Planning in the United States: Transit-Oriented Development (p. 2)] {{#if:|()}} {{#if:PDF|(PDF)}} |ژورنال= |نشریه=Rutgers, The State University of New Jersey |تاریخ= {{#if:|, {{چر}}}}2003 |دوره= |شوماره= |شاپا=}} {{#if:2007-06-11|Retrieved on 2007-06-11.}} {{#if:|Retrieved on , {{چر}}.}}</ref>. امریکایی‌ئون دِچرخه جه هم کمته استیفاده کانّه. <ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= Transportation Quarterly |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} Pucher, John, and Lewis Dijkstra|نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.transalt.org/files/resources/other/010901TQpdf021.pdf Making Walking and Cycling Safer: Lessons from Europe] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=Transportation Alternatives |تاریخ= {{#if:February|February, {{چر}}}}2000 |دوره= |شوماره= |شاپا=}} {{#if:2007-08-15|Retrieved on 2007-08-15.}} {{#if:|Retrieved on , {{چر}}.}}</ref> پنج‌تا از گت‌ترین شرکتای هواپیمایی هم آمریکایی هستنه. شرکت [[امریکن ایرلاینز]] اولین رتبه ره دانه.<ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.iata.org/ps/publications/wats-passenger-carried.htm Scheduled Passengers Carried] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=International Air Transport Association (IATA) |تاریخ= {{#if:|, {{چر}}}}2006 |دوره= |شوماره= |شاپا=}} {{#if:2007-08-15|Retrieved on 2007-08-15.}} {{#if:|Retrieved on , {{چر}}.}}</ref>. همینتی سی‌تا فرودگاه مهم دنیا دله ، شونزده‌تا آمریکا شنه. <ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.airports.org/cda/aci_common/display/main/aci_content07_c.jsp?zn=aci&cp=1-5-54-55_666_2__ Passenger Traffic 2006 Final] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=Airports Council International |تاریخ=2007-07-18 {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2007-08-15|Retrieved on 2007-08-15.}} {{#if:|Retrieved on , {{چر}}.}}</ref>. == دین == {{bar box |title=دینای آمریکا |titlebar=#ddd |چپ۱='''دین''' |راست۱='''درصد''' |چینش=left |نوارون= {{bar percent|مسیحیت|blue|78.4}} {{bar percent|بی‌دین|red|16.1}} {{bar percent|یهودیت|yellow|1.7}} {{bar percent|بودایی|orange|0.7}} {{bar percent|ایسلام|green|0.6}} {{bar percent|هندو|purple|0.4}} {{bar percent|دیگه|brown|1.2}} }} [[پرونده:Jewish population in the USA in 2000.svg|thumb|left|یهودیای آمریکا ، یهودیا این کشور دله اتا خورد اقلیت هستنه اما موهم حیساب وانه. به عونوان نمونه ۳۷ درصد از کل برندگون آمریکایی [[جایزه نوبل]] از جمعیت ۲ درصدی اینتا اقلیت‌نه.]] آمریکا به طور رسمی اتا [[دولت سکولار|کشور سکولار]] هسته. متحده ایالات دله بر اساس "موتمم اول قانون اساسی متحده ایالات"، هیچ دینی بطور رسمی وجود ندانه ، ولی مردم آزادنه هر دینی ره انتخاب هاکنن. همینتا وسّه هسته که مثلاً زنای محجبهٔ موسلمون آمریکایی ایجازه دارنه چادر جه بورن به مراکز دولتی و دانشگائی. با وجود سِوا بی‌ین دین از سیاست آمریکا دله، دین اهمیت ونقش موهمی این کشور دله دانه که نماد وه جومله "ما به خدا ایمون دارمی" شوعار کشور آمریکا هسته که روی اسکناس دلار هم دکشی‌یوئه<ref name="خزانه داری آمریکاً>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.ustreas.gov/education/fact-sheets/currency/in-god-we-trust.shtml History of 'In God We Trust'] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه= |تاریخ= {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2009-04-17|Retrieved on 2009-04-17.}} {{#if:|Retrieved on , {{چر}}.}}</ref>گروه‌ئون مذهبی قودرت اثر گوذاری قابل توجهی آمریکا دله دارنه دهه ۱۹۲۰ این گروه‌ئون بتونستنه دولت ره مجبور هاکنن که محصولات الکلی نسازه <ref>{{یادکرد|فصل= |کیتاب={{#if:http://books.google.com/books?pg=PA87&dq=1920+alcohol+prohibition+religion&lr=lang_en&ei=JPLoSdKXHoqGNv_D4I4B&id=Hmr_ZFXcOR4C&num=50&as_brr=0&as_pt=ALLTYPES|[http://books.google.com/books?pg=PA87&dq=1920+alcohol+prohibition+religion&lr=lang_en&ei=JPLoSdKXHoqGNv_D4I4B&id=Hmr_ZFXcOR4C&num=50&as_brr=0&as_pt=ALLTYPES Religion, deviance, and social control]|Religion, deviance, and social control}}|ناشر= Routledge|چاپ= |شهر= |کوشش= {{#if:|, {{چر}}}} |دچی‌ین= |سال=1996 {{#if:|, {{چر}}}} |شابک={{#if:0415915295|ISBN 0-415-91529-5}} |نویسنده=Stark{{#if:Rodney|, {{چر}}Rodney}} |نویسندگون سایر قسمت‌ئون=Sims Bainbridge|ترجومه=|صفحه=87 |زوون=en |مقاله= |ژورنال= |نشریه= |تاریخ= |دوره= |شوماره= |شاپا=}} {{#if:|Retrieved on .}}</ref>(اصلاحیه هیجدهوم قانون اساسی آمریکا ولی با زیاد بیّن خشونت ، قاچاق و... اصلاحیه بیست و یکم دله وه ره بیتنه<ref name="C" />)و به درس‌هدائن [[نظریه تکامل]] مدارس آمریکا دله بصورت محدود و برخی ایالات دله محدودیت ایجاد هکنن. <ref>{{یادکرد|فصل= |کیتاب={{#if:http://books.google.com/books?pg=PA50&dq=Advanced+Philosophy+and+Ethics+of+Religion&lr=lang_en&id=pMFVfv0O7BYC&num=50&as_brr=0&as_pt=ALLTYPES|[http://books.google.com/books?pg=PA50&dq=Advanced+Philosophy+and+Ethics+of+Religion&lr=lang_en&id=pMFVfv0O7BYC&num=50&as_brr=0&as_pt=ALLTYPES Advanced Philosophy and Ethics of Religion]|Advanced Philosophy and Ethics of Religion}}|ناشر= Oxford University Press|چاپ= |شهر= |کوشش= {{#if:|, {{چر}}}} |دچی‌ین= |سال=2002 {{#if:|, {{چر}}}} |شابک={{#if:0199148732|ISBN 0-19-914873-2}} |نویسنده=Dewar{{#if:Greg|, {{چر}}Greg}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه=50 |زوون=en |مقاله= |ژورنال= |نشریه= |تاریخ= |دوره= |شوماره= |شاپا=}} {{#if:|Retrieved on .}}</ref> .گروه‌ئون مذهبی به خصوص پروتستان‌ئون اونجلیکال و [[کاتولیک|کاتولیک‌ئون]]، مواضع جدی‌ای ره برابر موضوعاتی مثل [[همجنس‌گرایی|همجنسگرایی]]، [[سقط جنین]] و آموزش مختلط مدارس آمریکا دله، نشون هدانه. <br /> به اساس آمار ۲۰۰۲، ترکیب مذهبی مردم آمریکا اینتی هسته:<ref name=autogenerated2 />: [[پروتستان]] ۵۲٪، [[کاتولیک]] ۲۴٪، [[مورمون]] ۲٪، [[یهودیت]] ۲٪، [[ایسلام|مسلمان]] ۱٪، دیگرون ۱۰٪، بی‌دین ۱۰٪. [[پروتستان]]‌ئون آمریکا هم به فرقه‌ئون موختلفی تقسیم وانه. بعضی از وشون میلیونا نفر ره شه سمت دارنه ، در حالی که پچیک ِ[[کلیسا]]ئون ، فقط هزارون عضو دارنه. بعضی از فرقه‌ئون مذهبی معروف آمریکا اینان هستنه: [[اپیسکوپلین|اپیسکوپلین‌ئون]]، [[پرسبیترین‌ئون]]، [[متدیست|متدیست‌ئون]]، [[باپتیست‌ئون]]، [[یونیتارین‌ئون]]، [[مریدون مسیح]]، [[کلیسای اصلاحی هلندی]]، [[کوایکرون]] و [[کانگروگیشنالیست‌ئون]]. == فرنگ == آمریکا صعنت فیلم‌سازی و سینمایی خله معروفی ره دانه که نیشتنگاء وه [[هالیوود]] هسته که شهر [[لس‌آنجلس|لس آنجلس]] دله دره. [[هالیوود]] امروزه با ۶۳ میلیارد دلار درآمد، ۳۵ درصد کل تولیدات صنعت فیلمسازی جهون ره شه وسه دانه .<ref>[https://web.archive.org/web/20100710043029/http://www.factbook.net/wbglobal_rev.htm European Film Exhibition Industry]</ref> از سبک‌ئون موسیقی آمریکایی تومبی سبکای [[جاز]]، [[بلوز]]، [[رپ|هیپ هاپ]] و [[کانتری]] اشاره هکردن.<br /> [[نیویورک|شهر نیویورک]] از جائون موهم جهون هسته که ونه دله نیمایش ایجراء وانه. <ref>{{یادکرد|فصل= |کیتاب={{#if:http://books.google.com/books?pg=PA161&dq=new+york+world%E2%80%99s+leading+center+for+performing+arts&lr=&as_drrb_is=q&as_minm_is=0&as_miny_is=&as_maxm_is=0&as_maxy_is=&ei=lgLpSb6ANJjSzAT0_amSBQ&id=MogUGqknWZYC&num=50&as_brr=0&as_pt=ALLTYPES|[http://books.google.com/books?pg=PA161&dq=new+york+world%E2%80%99s+leading+center+for+performing+arts&lr=&as_drrb_is=q&as_minm_is=0&as_miny_is=&as_maxm_is=0&as_maxy_is=&ei=lgLpSb6ANJjSzAT0_amSBQ&id=MogUGqknWZYC&num=50&as_brr=0&as_pt=ALLTYPES Frommer's New York State]|Frommer's New York State}}|ناشر= John Wiley and Sons|چاپ= |شهر= |کوشش= {{#if:|, {{چر}}}} |دچی‌ین= |سال=2005 {{#if:|, {{چر}}}} |شابک={{#if:0471751731|ISBN 0-471-75173-1}} |نویسنده=Schlecht{{#if:Neil E.|, {{چر}}Neil E.}} |نویسندگون سایر قسمت‌ئون=Brian Silverman|ترجومه=|صفحه=161 |زوون=en |مقاله= |ژورنال= |نشریه= |تاریخ= |دوره= |شوماره= |شاپا=}} {{#if:|Retrieved on .}}</ref> همینتی "خیابون برادوی" گت‌ترین مرکز تیاتر ِآمریکا، اینتا شهر دله دره. [[ادبیات]]ِسر نویسندگونی مثل [[ارنست همینگوی]] ، [[مارک تواین]] ، [[ادگار آلن پو]] ، [[توماس هستهرنز الیوت|تی اس الیوت]] ، [[ویلیام فاکنر]] ، [[تنسی ویلیامز]] ، [[جی. دی. سالینجر|جی دی سالینجر]] ، [[آیزاک آسیموف]] ، [[مایکل کرایتون]] ، و [[ریموند کارور]] آمریکا دله درنه. [[هنر]] و معماری هم هنرمندون آمریکایی از [[فرانک لوید رایت]] بیته تا [[اندی وارهول|اندی وارهال]] آثار بسیار قابل توجهی سطح جهونی دله بساته بینه. هرم ورودی [[موزه لوور]] ، کاخ مجلس میلّی [[بنگلادش]]، و [[پوئرتا دو ئوروپا]]ی ایسپانیا، نمونه‌ئونی از طراحی معمارون آمریکایی جهون دله هستنه. <center> <gallery> Image:Salkinstitute lajolla062005.jpg|موسسه سالک سن دییگو، اثر مشهور "لوئیس کان" معمار آمریکایی Image:Louis Armstrong restored.jpg|موسیقی جاز نوین هویت خادش ره مدیون هنرمندونی مثل "لویی آرمسترانگ" هسته. Image:Jordan by Lipofsky 16577.jpg|[[مایکل جردن]] و دیگه ستارگون "ان بی ای" طرفدارون زیادی دارنه. Image:Estatua Woody Allen en Oviedo.jpg|موجستمه وودی آلن ِ[[ایسپانیا]]، [[هالیوود]] اتا از صادرات اصلی آمریکا به جهونیون هسته. </gallery> </center> {{-}} === ورزش === [[پرونده:NBA Game.jpg|thumb|[[ان بی ای]] ، موعتبرترین لیگ [[بسکتبال]] جهون هسته.]] از قرن نوزدهوم [[بیسبال]] به عونوان ورزش میلی آمریکا انتخاب بیّه. در وهله بعدی [[فوتبال آمریکایی]] ، [[بسکتبال]] و [[هاکی یخ سر]] ورزش‌ئون میلّی آمریکا به شومار شونّه. "فوتبال کالجی" و "بسکتبال کالجی" هم پرطرفدارنه. [[فوتبال آمریکایی]] الان پرطرفدارترین ورزش ِآمریکا هسته.<ref>{{یادکرد|فصل=|کیتاب=|ناشر=|چاپ=|شهر=|کوشش=|دچی‌ین=|سال=|شابک=|نویسنده={{#if:|, {{چر}}}} Krane, David K.|نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه=|زوون=en|مقاله=[http://www.harrisinteractive.com/harris_poll/index.asp?PID=337 Professional Football Widens Its Lead Over Baseball as Nation's Favorite Sport] {{#if:|()}} {{#if:|()}}|ژورنال=|نشریه=Harris Interactive|تاریخ=2002-10-30 {{#if:|, {{چر}}}}|دوره=|شوماره=|شاپا=}} {{#if:2007-09-14|Retrieved on 2007-09-14.}} {{#if:|Retrieved on , {{چر}}.}} Maccambridge, Michael (2004). ''America's Game: The Epic Story of How Pro Football Captured a Nation''. New York: Random House. ISBN 0-375-50454-0.</ref> [[بوکس]] و [[سوارکاری|اسب‌دوانی]] هم خله طرفدار دارنه، اما این ورزش‌ئون زیر سایه دِ ورزش [[گلف]] و [[رالی|اتومبیل‌رونی]] هستنه. متحده ایالات با داشتن ۲٬۱۰۳ مدال [[المپیک تابستانی]] موفق‌ترین کشور دِنیا المپیک دله محسوب وانه ،<ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.infoplease.com/ipsa/A0115108.html All-Time Medal Standings, 1896–2004] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=Information Please |تاریخ= {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2007-06-14|Retrieved on 2007-06-14.}} {{#if:|Retrieved on , {{چر}}.}}</ref><ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.factmonster.com/sports/olympics/2008/distribution-medals-summer-games.html Distribution of Medals—2008 Summer Games] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=Fact Monster |تاریخ= {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2008-09-02|Retrieved on 2008-09-02.}} {{#if:|Retrieved on , {{چر}}.}}</ref> و با داشتن ۲۱۶ مدال ِ [[المپیک زمستونی|بازی‌ئون المپیک زمستونی]] رده دوم دله دره.<ref>{{یادکرد|فصل=|کیتاب=|ناشر= |چاپ= |شهر= |کوشش= |دچی‌ین= |سال=|شابک=|نویسنده={{#if:|, {{چر}}}} |نویسندگون سایر قسمت‌ئون=|ترجومه=|صفحه= |زوون=en |مقاله= [http://www.infoplease.com/ipsa/A0115207.html All-Time Medal Standings, 1924–2006] {{#if:|()}} {{#if:|()}} |ژورنال= |نشریه=Information Please |تاریخ= {{#if:|, {{چر}}}} |دوره= |شوماره= |شاپا=}} {{#if:2007-06-14|Retrieved on 2007-06-14.}} {{#if:|Retrieved on , {{چر}}.}} نروژ اول هسته; و شوروی سوم.</ref> == نیروی نظامی == [[پرونده:USS Abraham Lincoln (CVN-72) underway in the South China Sea on 8 May 2006 (060508-N-4166B-030).jpg|thumb|left|ناو هواپیمابر آبراهام لینکلن.آمریکا با دارا بودن دوازده ناو هواپیمابر بزرگ‌ترین نیروی دریایی دنیا را دارهسته.]] نیروی نیظامی آمریکا به پنج دسته تقسیم وانه:<ref>[https://web.archive.org/web/20181226055200/https://www.cia.gov/library/publications/the-world-factbook/geos/us.html#Military Military of the United States]</ref> * نیروی زمینی متحده ایالات آمریکا * نیروی هوایی متحده ایالات آمریکا * نیروی دریایی متحده ایالات آمریکا * نیروی تفنگدار دریایی متحده ایالات آمریکا * گارد ساحلی متحده ایالات آمریکا وزیر دفاع زیر نظر رییس جومور که مقام فرمانده کل قوا ره بر عهده دانّه فعالیت کانده. در سال ۲۰۰۴ آمریکا با بودجه نیظامی ۵۲۲ میلیارد دلار، ۳٫۷٪ تولید ناخالص داخلی ره صرف هزینه‌ئون نیظامی هکرده ، که این هزینه‌ئون نیظامی به تنهایی تقریباً موعادل نصف هزینه‌ئون نیظامی جهونی بینه. <ref>{{یادکرد وب | نشونی = http://www.usatoday.com/news/world/2005-06-07-world-military_x.htm | عونوان = Report: World military spending tops $1T in 2004 |ناشر = USAToday | تاریخ = ۷ ژوئن ۲۰۰۵ | تاریخ بدی‌ین = ۶ آوریل ۲۰۰۸ | زوون = انگلیسی }}{{یادکرد وب | نشونی = http://www.cbsnews.com/stories/2004/06/09/world/main622012.shtml | عونوان = World Military Spending Soars |ناشر = شبکه خبری سی‌بی‌اس | تاریخ = ۹ ژوئن ۲۰۰۴ | تاریخ بدی‌ین = ۶ آوریل ۲۰۰۸ | زوون = انگلیسی }}</ref> رئیس جومور آمریکا برای اقدام نیظامی از مشورت‌ئون "م.شاور امنیت میلّی متحده ایالات" برخوردار هسته. در رده پایین‌تر، وزیر دفاع قرار دانّه؛ رییس سیتاد موشترک ارتش آمریکا هم به فرمانده کل قوا و هم به وزیر دفاع مشورت دنه. == رسانه == [[پرونده:USA Today building.jpg|thumb|200 px|left|دفتر مرکزی روزنامه "یواس‌ای تودی" شهر مک لین ایالت ویرجینیا ، یواس‌ای تودی دومین روزنامه قطع بزرگ [[انگلیسی زبون|انگلیسی]] زوون کثیرالانتشار دِنیا هسته.]] به غیر از ارگان‌ئونی مثل "گروه فرارسی شوماره‌یی" ، "آمریکای ونگ" ، و یا "هیئت کارفرمایون پخش" که توسط اورگان‌ئون دولتی برای مخاطبین خارج از آمریکا تنظیم وانه، اکثر رسانه‌ئون درون آمریکا یا مثلا شبکه‌ئونی نظیر "فاکس" ، "اچ بی او" ، "ام‌تی‌وی" ، و "سی‌ان‌ان" بطور کاملا خصوصی و با درآمد حاصل از تبلیغات و آگهی‌ئون تجارتی اداره وانه، یا مثل "رادیوی عمومی میلّی" و "پی‌بی‌اس" توسط موسسات و بنیادون خیریه تامین مالی وانه. از ۱۲۰۰ شبکهٔ تلویریونی آمریکا، از گت‌ترین و معروفترین وشون در تاریخ رسانه‌ئون آمریکا بتومبی به ۳ شبکهٔ [[ای‌بی‌سی]]، [[ان‌بی‌سی]]، و [[سی‌بی‌اس]] اشاره هکردن.<ref>''Handbook of children and the media'' Dorothy G. Singer, Jerome L. Singer. Published by SAGE, 2001. ISBN 0-7619-1955-4 pp.480</ref> {{پاک کن}} == منابع == {{چپ‌چین}} {{پانویس|۲|اندازه=ریز}} {{پایان چپ‌چین}} == بِریمْ بگردستن == {{commons|United States|متحده ایالات آمریکا}} * [http://www.usa.gov/ وب‌گاه رسمی دولت آمریکا] * [https://web.archive.org/web/20080113043108/http://persian.usinfo.state.gov/ بخش فارسی usinfo.state.gov] * [https://web.archive.org/web/20080806215118/http://www.america.gov/persian// وبگاه فارسی America.gov] * {{یادکرد وب| نشونی = http://www.fita.org/countries/us.html| عونوان = United States information| تاریخ بدی‌ین = ۵ آوریل ۲۰۰۸| زوون = انگلیسی}} * [http://www.census.gov/population/www/popclockus.html شومارشگر لحظه‌ئی جمعیت کشور آمریکا] * [https://web.archive.org/web/20091211220234/http://www.terraserverusa.com/ تصویر ماهواره‌ئی کشور آمریکا با قابلیت گت‌بیّن] == وابسته جستارون == * [[لیست رییس‌جوموری‌ئون متحده ایالات]] {{Navbox | name = ؟ | title = نیشتنگائون ایالات ، متحده ایالات آمریکا دله | list1 = آتلانتا، [[جورجیا]] {{!}} اسپرینگفیلد، [[ایلینوی]] {{!}} آستین، [[تگزاس]] {{!}} اوکلاهوماسیتی، [[اوکلاهوما]] {{!}} آگوستا، [[مین]] {{!}} آلبانی، [[نیویورک]] {{!}} المپیا، [[واشنگتن]] {{!}} آناپولیس، [[مریلند]] {{!}} ایندیاناپولیس، [[ایندیانا]] {{!}} باتن روژ، [[لوئیزیانا]] {{!}} بوستون، [[ماساچوست]] {{!}} بویزی، [[آیداهو]] {{!}} بیسمارک، [[شمالی داکوتا]] {{!}} پراویدنس، [[رود آیلند]] {{!}} پییر، [[جنوبی داکوتا]] {{!}} تالاهاسی، [[فلوریدا]] {{!}} ترنتون، [[نیوجرسی]] {{!}} توپیکا، [[کانزاس]] {{!}} جفرسون سیتی، [[میسوری]] {{!}} جکسون، [[میسیسیپی]] {{!}} جونو، [[آلاسکا]] {{!}} چارلستون، [[غربی ویرجینیا]] {{!}} دنور، [[کلرادو]] {{!}} دوور، [[دلاویر]] {{!}} دی موین، [[آیووا]] {{!}} رالی، [[شمالی کارولینا]] {{!}} ریچموند، [[ویرجینیا]] {{!}} ساکرامنتو، [[کالیفرنیا]] {{!}} سالت لیک سیتی، [[یوتا]] {{!}} سنتا فه، [[نیومکزیکو]] {{!}} سیلم، [[اورگن]] {{!}} سنت پال، [[مینسوتا]] {{!}} شاین، [[وایومینگ]] {{!}} فرانکفورت، [[کنتاکی]] {{!}} فینکس، [[آریزونا]] {{!}} کارسون سیتی، [[نوادا]] {{!}} کلمبوس، [[اوهایو]] {{!}} کلمبیا، [[جنوبی کارولینا]] {{!}} کنکورد، [[نیوهمشایر|نیوهمپشر]] {{!}} لنسینگ، [[میشیگان]] {{!}} لیتل راک، [[آرکانزاس]] {{!}} لینکلن، [[نبراسکا]] {{!}} مونتگومری، [[آلاباما]] {{!}} مدیسون، [[ویسکانسین]] {{!}} مون پلیه، [[ورمانت]] {{!}} نشویل، [[تنسی]] {{!}} هارتفورد، [[کنتیکت]] {{!}} هریسبورگ، [[پنسیلوانیا]] {{!}} هلنا، [[مونتانا]] {{!}} هونولولو، [[هاوایی]] }} {{آمریکا کشورون}} {{نفتا}} {{ناتو}} {{سازمان ملل}} {{انگلیسی زبون}} {{جی بیست}} {{جی هشت}} <!-- رج --> [[رج:آمریکای متحده ایالات|*]] [[رج:ناتو]] [[رج:نفتا]] [[رج:انگلیسی‌زوون کشورون]] [[رج:بریتانیا قدیمی مستعمرات]] [[رج:ایسپانیا قدیمی مستعمرات]] [[رج:آمریکا کشورون]] [[رج:جی بیست]] [[رج:جی هشت]] 2whczsamsfz604l20dfxxtsxuizk0k3 ویکی‌مدیا 0 3937 390371 40053 2026-07-17T14:31:11Z For2jss 46038 /* */ 390371 wikitext text/x-wiki '''ویکی‌مدیا''' أتا ناسود بر و خاری سازمون هسه که [[موتحده ایالات]] دله کار کەنه.اینتا سازمان چن تا برنومه ره اینترنت دله گردوندەنه. [[رده:ویکی‌مدیا]] sy17lfveetg46orhkhtvcxblhimdtl6 علی 0 5047 390386 390370 2026-07-17T19:03:56Z محک 1023 اونچی که [[Special:Contributions/~2026-40066-16|~2026-40066-16]] ([[User talk:~2026-40066-16|گپ]]) دچی بی‌یه، دگارسته بیه همونتایی که [[User:Sazwar|Sazwar]] این ولگه دله، اواخر بنویشت بی‌یه. 327398 wikitext text/x-wiki {{جعبه اطلاعات ایمام شیعه | نام = علی بن ابی‌طالب | تصویر = Istanbul - Santa Sofia - Medalló (cropped).JPG | اندازه تصویر = | عنوان تصویر = خِشنویسی «علی» نوم [[ایا صوفیه]] دله | نقش = امام اول کل شاخه های شیعه(زیدیه،اسماعیلیه،اثناعشریه) | کنیه = ابوالحسن<br />ابوتراب | زادروز = | زادگاه = [[مکه]]، [[کعبه]] دله | درگذشت =۲۱ رمضان سال ۴۰ پس از هجرت | مدفن = [[نجف]] | محل زندگی = | القاب = امیرالمؤمنین<br />اسداللّه<br />حیدر کرار<br />سید عرب<br />سیدالمسلمین<br />امام‌المتّقین<br />مرتضی | پدر = ابی‌طالب | مادر = فاطمه بنت اسد | همسران = [[زهرا]] | فرزندان = [[#علی وچون|پایین ره هارشین]] | طول عمر = ۷۵ }} '''علی بن ابی‌طالب''' (بزائه‌ی [[۱۳ رجب]] [[۲۴ پیش از هجرت]] – بمرده‌ی ۲۱[[۲۱ رمضان]] [[۴۰ (قمری)|۴۰ هجری قمری]]) اسلامِ چارومین خلیفه و [[شیعه|شیعیون]] نوخوستین ایمام هسته. == وچگی جه تا بمردن == علی بن ابی‌طالب (۱۳ رجب سنه ۲۴ پیش از هجرت ، ۲۱ رمضان ۴۰ ه.ق.) عموزا دوماد و نزدیکترین یارون [[محمد ابن عبدالله|محمد]]، (پیومبر ایسلام) و از اهل بیت پیومبر هسه. بنا بر روایات محمد وه ره به برادری خادش اینتخاب هکرده و با وه پیمون برادری دوسه. وه از دیدگاه اهل سنت چهارمین خلیفه مسلمونا و از نظر شیعیون بنابر وصیت و سفارش‌های محمد جانشین پیومبر و ایمام اول هسه. دو کنیه معروف وه «ابوالحسن» و «ابو تراب» هسه و بین گروه‌های مختلف با لقب‌های گوناگونی (به مانند امیرالمومنین، اسدالله و حیدر کرار) خونده وانه. مدت خلافت وه ۵ سال (از ۶۵۶ م تا ۶۶۱ م.) بیه. وه مکه دله به دنیا بموئه ون پیر [[ابوطالب]] ون مار هم [[فاطمه بنت اسد|فاطمه اسد کیجا]] بیه. در خانه محمد گت بیه و در حالی که حدود ده سال ویشته نداشته، اولین اینسان مذکری بیه که موسلمون بیه. علی زمانی که پیومبر در مکه ایسلام ره تبلیغ کارده و مورد آزار و اذیت مشرکان قرار گیته یار و مددکار وه بیه. هنگام هجرت محمد، علی به جای وه ون جا بخاته تا نقشه بکاشتن پیومبر ره خراب هاکنه و وه بتونه از مکه دربوره بعداً امونت وه ره ادا هکرده و به همراه [[فاطمه]] زهرا، شه مار و زنی دیگر به مدینه هجرت هاکرده. در سال دیم پس از هجرت محمد بئوته که به فرمون خدا وه ره به همسری شه دتر فاطمه در می‌آورد که حاصل این ازدواج چند فرزند از جمله [[حسن]] و [[حسین]] بینه. در طول دورانی که پیومبر اداره جامئه موسلمونا [[مدینه]] دله ره به عهده داشته علی وه ره یاری کارده و در تموم جنگا به جز [[جنگ تبوک|تبوک]] شرکت داشته. هم اینتی وه حامل پیغوما و دستورای وه بیه. محمد هنگام بردگسن از آخرین حج خادش در [[غدیر خم]]، وه ره «مولای موسلمونا» معرفی هاکرده و مردمون با وه بیعت هاکردنه و تبریک بائوتنه و این از دید شیعیون به معنی معرفی علی به جانشینی پیومبر هسته. پس از بمردن پیومبر در ماجرای اینتخاب جانشین پیومبر بین وه و [[ابوبکر]] اختلاف رخ هدائه.وه تا شش ماه از بیعت با ابوبکر سرباز بزو و مدتی پس از درگذشت فاطمه زهرا به ظاهر با وه بیعت هاکرده اما همچنون بر غصب خلافت از جانب وی هارشا داشته. علی در دوران خلافت سه خلیفه اول جز در انتخاب خلیفه سوم فعالیت سیاستون نداشته و در جنگا شرکت نکارده و تنها در امور دینی و قضایی و سیاستون به خلفا مشورت دائه. پس از سقط بین [[عثمان]] ،خلیفه سوم، علی با اصرار مردمون خلافت ره بیته و از سال ۳۵ تا ۴۰ هجری قمری این منصب ره بر عهده داشته. وه با مخالفت برخی از گتای [[قریش]] و [[عایشه]] مواجه بیه. این امر منجر به بروز سه جنگ [[جمل]] ، [[صفین]] و [[نهروان]] در دوران خلافتش بیه. نهایتا [[ابن ملجم مرادی]] یکی از بازماندگان [[خوراج]] نهروان در مسجد [[کوفه]] به هنگام نماز صبح با شمشیر زهرآلود فرق وه ره بشکافته و ۲ روز پس از وه در ۲۱ مارمضون سال ۴۰ هجری دربگذشته. علی(ع) پس از بمردنش نیز تأثیر زیادی بر جامئه مسلمونا داشته. از وه احادیث، سخنرانیا، پیغوما، اشعار و دعاهای فراوانی به جابموند‌سه که در کتابای مختلف نظیر [[نهج البلاغه]] و [[غررالحکم]] ، به جای بموندسه‌. عموم موسلمونا وه ره گت‌ترین مفسر قرآن و عالم‌ترین شخص به دانش فقه دونه.همین تی ویشته [[صوفیه]] برای وه مرتبه بالای ولایت را قائل دونه. فیلسوفان شیعه وه ره بنیانگذار [[فلسفه الهی]] دونه. علاوه بر اینا موسلمونا وه ره به جهت کوشش‌های بیدریغ و از جان گذشتگیش در راه ایسلام ارج می‌نهندگت دونه و همینتی به خاطر شجاعت، کرم، گوذشت، ایدالت و گت بوئنش نسبت به مردمون وه ره دوست دارنه. به همین هارشا در دانش، فرنگ و هونر موسلمونا آثار خله زیادی در مورد وه و برای وه ایجاد هاکردنه. == علی وچون == اینجه به بئوتن وچون علی و تعداد وشون و اسامی وشون گپ زمبی و به کمی از کارای مربوط به وشون اشاره کامبی. علی ۲۸ تا وچه داشته: # [[حسن]] # [[حسین]] # [[زینب]] # زینب صغری # محسن # محمّد (معروف به محمّد حَنَفیّه # عمر # رقیّه: وه و عمر که دِکالی بینه و وشون مار ((ام حبیب)) ربیعه دِتر بی‌یه # [[عباس|عباس ابن علی]] # جئفر # عثمان # عبداللّه # محمد اصغر # عُبیداللّه # یحیی # اُمّ الحسن # رمله # نفیسه # زینب صغری # رقیه صغری # اُمّ هانی # ام الکرام # جمانه که کنیه‌اش اُمّ جعفر بی‌یه # امامه # اُمّ سلمه # میمونه # خدیجه # فاطمه # [[هلال علی ریکا|هلال ابن علی]]''«ونه قبر [[آران و بیدگل]] دله دره»'' == جوستارای وابسته == * [[تشیع]] * [[ایسلام]] * [[نهج البلاغه]] * [[شیعه ایمامون]] * [[معاویه]] == مطلب ریشه (منابع) == *[[ابن ابی الحدید]]، جلوه‌های تاریخ شرح نهج البلاغه دله ابن ابی الحدید، زوون دگاردسن [[محمود مهدوی دامغانی]] *[[ابن اثیر]]، تاریخ کامل *جرداق، جرج، امام علی صدای ایدالت اینسانی، زوون دگاردسن سی هادی خسروشاهی، نشر خرم *جعفریان ، رسول، تاریخ خلفا *حکیمی، محمدرضا (۱۳۸۲) حماسه غدیر، قم:انتشارات دلیل ما، ISBN ۹۶۴-۷۹۹۰-۷۶-۶ *حلی، جمال الدین حسن بن یوسف بن مطهّر، نگاهی بر زندگی دیوازده ایمام، زوون دگاردسن [[محمد محمدی اشتهاردی]] *سبحانی، جعفر، فروغ ولایت، انتشارات امام صادق، ISBN ۹۶۴-۶۲۴۳-۱۱-۸ *رسولی محلاتی، زندگانی حضرت ممد(ص) *طباطبایی، محمد حسین، تفسیر المیزان، زوون دگاردسن سید محمدباقر موسوی همدانی، ناشر: دفتر انتشارات اسلامی [[طبرسی|فضل ابن حسن طبرسی]] ، فضل بن حسن، [[تفسیر مجمع البیان]] *[[محمد بن جریر]]، [[تاریخ طبری]] (تاریخ پیومبرون و پادشاهون) *علی بن ابیطالب، نهج البلاغه، گردآوری سید رضی *فیضی پور، علی اصغر، امام علی علیه السلام از زبان دیگران، مجله کلام اسلامی *قندوزی، سلیمان، ینابیع الموده *مجلسی، محمدباقر، [[بحارالانوار]] مطهری، مرتضی، سیری در نهج البلاغه، «مجموعه آثار» جلد ۱۶، چاپ اول، انتشارات صدرا، ISBN ۹۶۴-۵۶۰۰-۰۶-۵ *مطهری، مرتضی، «فلسفه اخلاق»، انتشارات صدرا، ISBN ۹۶۴-۵۶۰۰-۰۸-۱ چاپ بیست و پنجم *مکارم شیرازی، ناصر،[[تفسیر نمونه]] *Holt, P.M. and Bernard Lewis (۱۹۷۷). Cambridge History of Islam, Vol. ۱. Cambridge University Press. ISBN ۰۵۲۱۲۹۱۳۶۴ *Lapidus, Ira. (۲۰۰۲). A History of Islamic Societies. Cambridge University Press. ۲nd edition. ISBN ۹۷۸-۰۵۲۱۷۷۹۳۳۳ *Madelung, Wilferd. (۱۹۹۷). The Succession to Muhammad: A Study of the Early Caliphate. Cambridge University Press. ISBN ۰۵۲۱۶۴۶۹۶۰ == بیرون بگردسن == * [https://web.archive.org/web/20090723212113/http://imamalinet.net/PER/INDEXP.HTM سایت امام علی 1] * [https://web.archive.org/web/20090831101849/http://www.emamali.net/ سایت امام علی 2] * [https://web.archive.org/web/20090708060949/http://www.hawzah.net/Hawzah/Subjects/Subjects.aspx?id=4937& دانشنامه امام علی سایت حوزه دله] * [https://web.archive.org/web/20090803214124/http://www.imamali.ir/ پورتال امیرالمومنین] * [https://web.archive.org/web/20090721083247/http://www.aboutorab.com/ سایت ابوتراب] * {{یادکرد وب|پیوند=http://fa.wikipedia.org/wiki/%D8%AD%D8%B3%DB%8C%D9%86_%D8%A8%D9%86_%D8%B9%D9%84%DB%8C|عنوان=حسین بن علی|تاریخ بازدید=1-8-2011|زبان=پارسی}} [[رج:ایمامون شیعیون]] [[رج:خلفای راشدین]] hvcs4p7qsxgh6a86vjgh8dnyoehsz5f İqtisad 0 5562 390390 209626 2026-07-18T00:44:49Z Xqbot 827 ربوت:عوض هایتن دکشیه‌ئون دِتایی → [[اقتیصاد]] 390390 wikitext text/x-wiki #بور [[اقتیصاد]] mxele916q3gedaqd4000uafd8hem2l2 شابلون:Country data United Nations 10 16775 390398 239916 2026-07-18T05:50:14Z محک 1023 390398 wikitext text/x-wiki {{ {{{1<noinclude>|country showdata</noinclude>}}} | alias = متحد ملل سازمان | flag alias = Flag of the United Nations.svg | size = {{{size|}}} | name = {{{name|}}} | variant = {{{variant|}}} <noinclude> | redir1 = UN | redir2 = UNO | redir3 = the United Nations </noinclude> }} lpey7b4jg41q7jz6998ia72k8fq7vpt کس 0 25354 390383 389387 2026-07-17T18:49:04Z ~2026-40084-65 46101 /* */ 390383 wikitext text/x-wiki [[پرونده:Vaginal opening description.jpg|250px|بندانگشتی|چپ|پپش ِمختلفِ بخشون:{{سخ}}۱. کلیتوریس هود (تینگِ جلد){{سخ}}۲.[[تینگ]] یا [[کلیتوریس]]{{سخ}}۳.دله‌یی لو{{سخ}}۴.شاش‌مقوم{{سخ}}۵.پپش دله{{سخ}}۶.کتم و تینگ{{سخ}}۷.[[موس]]]] '''پَپُش''' یا '''پَپِش''' یا '''پَپُس''' یا '''پَپِس''' یا '''بِند''' یا '''کاس''' یا '''کُس''' یا '''کِس''' {{انگلیسی جه|Vulva}} اتا بیرونی بخش زن‌کون ِچک میون دَره. ونه دله شه بخشای مختلفی قرار دارنه. مثلاً کس پشم، [[کتم]] و [[تینگ]] (انگلیسی نوم: [[کلیتوریس]]) <ref>[http://www.tabarestan.ir/dictionary?searchMethod=contains&searchword=%D8%A2%D9%84%D8%AA+%D8%AA%D9%86%D8%A7%D8%B3%D9%84%DB%8C+%D8%B2%D9%86&searchType=n.meaning&search=%D8%AC%D8%B3%D8%AA%D8%AC%D9%88&limitstart=0&option=com_dictionary&Itemid=437&1d46f051b99d2862ec8955e4f7c6604f=1 تبرستون آنلاین لغتنومه: کس]</ref> == نگارخانه == <gallery> Labioplasty and Clitoral Hood Reduc یا tion.jpg|زنان پپش بتونده شکلای مختلف داره Female_sexual_arousal.JPG|تحریک بیی پپش و معمولی پپش ِمقایسه </gallery> {{شابلون:آدم تن}} == منابع == {{تلمبار-رج|Female genitalia}} {{پانویس}} {{چپ‌چین}} * Wikipedia contributors, "Vulva," Wikipedia, The Free Encyclopedia, http://en.wikipedia.org/w/index.php?title=Vulva&oldid=487428553 (accessed April 19, 2012). {{پایان چپ‌چین}} [[رج:بگائستن]] [[رج:بدن]] pw261xz7843zvdvqde68sz7rze56szh باب‌المندب 0 29773 390403 132723 2026-07-18T06:11:04Z محک 1023 390403 wikitext text/x-wiki {{coord|12|35|N|43|20|E|type:waterbody|display=title}} {{صندخ/سطحی ئو |نقشه= Locatie Bab el Mandeb.PNG }} ''' باب‌المندب ''' اتا دریایی تنگه هسته که [[سرخ دریا]]ی ِجنوبی قِسمت ره [[هند اوقیانوس]] جه وصل کانده. این تنگه‌ی ِدِ وَر [[آفریقا]]یی و [[آسیا]]یی کشورون دَرنه. آفریقا جه [[جیبوتی]] و آسیا جه [[یمن]] این تنگه په دَرنه. این تنگه خله استراتژیک هسته و دِنیای ِجهونی تجارتون ِشصت درصد ونه این منطقه جه گُذِر هاکنه.<ref>[http://ir.sputniknews.com/politics/20150327/65341.html sputniknews.com]</ref> == منابع == {{تلمبار-رج|Bab-el-Mandeb}} {{پانویس}} [[رج:تنگه‌ئون]] [[رج:جیبوتی]] [[رج:یمن]] [[رج:هند اوقیانوس ]] [[رج:باب‌المندب| ]] [[رج:سرخ دریا]] a67dqkc4byse4qvul6v5l1swrsdkqoa آنتونیو گوترش 0 33603 390394 192675 2026-07-18T05:33:39Z محک 1023 390394 wikitext text/x-wiki {{صندخ/شخص | نام = آنتونیو گوتریس | تصویر = [[پرونده:António Guterres, 23.03.23.jpg|200px]] | زادروز = ۳۰ آوریل ۱۹۴۹ | شهر تولد = لیسبون | کشور تولد = {{POR}} | تاریخ مرگ = | شهر مرگ = | کشور مرگ = | نام همسر = لیسا گیمارائس ا ملو<br>کاترینا واز پینتو | سمت =[[پرتغال]] ۱۱۴مین نخست‌وزیر {{سخ}} اکتبر ۱۹۹۵ تا آوریل ۲۰۰۲ <br>[[متحد ملل سازمان]] دبیرکل<br>۱ ژانویه ۲۰۱۷ تاسا }} '''آنتونیو مانوئل د الویسیرا گوترش''' اتا پرتغالی سیاستمدار و دیپلمات هسته [[متحد ملل سازمان]] دله ریاست کنده.<ref>[http://www.politico.eu/article/master-of-dialogue/ Master of dialogue] ''[[European Voice]]'', 5 January 2000.</ref>وه پیش از این، سال ۱۹۹۵ تا ۲۰۰۲ شه کشور نخست وزیر بی‌یه.<ref>Rory Watson (4 October 1995), [http://www.politico.eu/article/socialists-prepare-to-govern/ Socialists prepare to govern] ''[[European Voice]]''.</ref> ==منابع== {{پانویس}} [[رج:زننه آدمون]] [[رج:۱۹۴۹ بزائه‌ئون]] [[رج:پرتغال نخست‌وزیرون]] [[رج:دبیر کل سازمان ملل متحد]] ejr2hpdiappw419tiwbmbhhx9m19lh9 390399 390394 2026-07-18T05:50:23Z محک 1023 390399 wikitext text/x-wiki {{صندخ/شخص | نام = آنتونیو گوتریس | تصویر = [[پرونده:António Guterres, 23.03.23.jpg|200px]] | زادروز = ۳۰ آوریل ۱۹۴۹ | شهر تولد = لیسبون | کشور تولد = {{POR}} | تاریخ مرگ = | شهر مرگ = | کشور مرگ = | نام همسر = لیسا گیمارائس ا ملو<br>کاترینا واز پینتو | سمت = {{پرچمک|پرتغال}} '''[[پرتغال]] ۱۱۴مین نخست‌وزیر''' {{سخ}} اکتبر ۱۹۹۵ تا آوریل ۲۰۰۲ <br>{{پرچمک|UN}} '''[[متحد ملل سازمان]] دبیرکل'''<br>۱ ژانویه ۲۰۱۷ تاسا }} '''آنتونیو مانوئل د الویسیرا گوترش''' اتا پرتغالی سیاستمدار و دیپلمات هسته [[متحد ملل سازمان]] دله ریاست کنده.<ref>[http://www.politico.eu/article/master-of-dialogue/ Master of dialogue] ''[[European Voice]]'', 5 January 2000.</ref>وه پیش از این، سال ۱۹۹۵ تا ۲۰۰۲ شه کشور نخست وزیر بی‌یه.<ref>Rory Watson (4 October 1995), [http://www.politico.eu/article/socialists-prepare-to-govern/ Socialists prepare to govern] ''[[European Voice]]''.</ref> ==منابع== {{پانویس}} [[رج:زننه آدمون]] [[رج:۱۹۴۹ بزائه‌ئون]] [[رج:پرتغال نخست‌وزیرون]] [[رج:دبیر کل سازمان ملل متحد]] kitv2z4lk7w74xir467661eo7f5bsp8 شابلون:صندخ/کامپیوتری کا 10 38763 390381 191769 2026-07-17T18:26:02Z محک 1023 شابلون:صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی 390381 wikitext text/x-wiki {{صندخ/سر}} {{صندخ/عنوان |{{{کا نوم|{{{title|{{{نوم|{{PAGENAME}}}}}}}}}}} ||Kontrollikon_1.0d_-_Grey.svg |right }} {{صندخ/سطر اختیاری |{{ویکی دیتا مقدار |{{{محلی نوم|{{{نام اصلی|{{{اصلی نوم|{{{محلی|{{#property:P1705}}}}}}}} }}} }}} |خاصیه=P1705 |قائمه=yes }}}} {{صندخ/ویکی دیتا عکس|ویکی دیتا={{{ویکی دیتا|}}} |{{{لوگو|{{{تصویر نشان‌واره|{{{logo|}}}}}}}}} |{{{logo caption|{{{لوگو جیرنویس|}}}}}} | خاصیه=P154 }} {{صندخ/ویکی دیتا عکس|ویکی دیتا={{{ویکی دیتا|}}} |{{{جلد|{{{عکس|{{{image|}}}}}}}}} |{{{جلد جیرنویس|{{{caption|{{{جیرنویس|}}}}}}}}} | خاصیه=P18 }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |سازنده |{{{developer|{{{سازنده|}}} }}} |خاصیه=P178 }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |ناشر |{{{publisher|{{{ناشر|}}} }}} |خاصیه=P123 }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}}|خاصیه=P750 |تنک‌کَر |{{{distributor|{{{تنک‌کر|{{{توضیع کننده|}}}}}} }}} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}}|خاصیه=P287 |طراح |{{{designer|{{{طراح|}}} }}} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}}|خاصیه=P57 |کارگردان |{{{director|{{{کارگردان|}}} }}} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}}|خاصیه=P943 |برنامه‌نویس |{{{programmer|{{{برنامه‌نویس|}}} }}} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |زوون |{{{زوون|}}} |خاصیه=P364 }} {{صندخ/پشوبزه خط اختیاری |نویسنده |{{{writer|{{{نویسنده|}}} }}} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}}|خاصیه=P162 |تولیدکَر |{{{producer|{{{تولیدکر|}}} }}} }} {{صندخ/پشوبزه خط اختیاری |هنرمند |{{{artist|{{{هنرمند|}}} }}} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |ویدیو-موزیک آلبوم |{{{ویدیو-موزیک آلبوم|}}} |خاصیه=P406 }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |[[کامپیوتری کا موسیقی|موسیقی]] |{{{composer|{{{موسیقى|}}} }}} |خاصیه=P86 }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |مجوز |{{{مجوز|{{{اجازه‌نومه|}}}}}} |خاصیه=P275 }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |سری |{{{series|{{{سری|}}} }}} |خاصیه=P179 }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |موتور |{{{engine|{{{موتور|}}}}}} |خاصیه=P408 |تصفیه=P348 |تصفیه1=P400 |لیست=yes }} {{صندخ/پشوبزه خط اختیاری|فروش نسبت| {{{عکس شکل|{{{فروش|}}}}}} }} {{صندخ/پشوبزه خط اختیاری|وضوح| {{{رزولیشن|{{{رزولوشن|}}}}}} }} {{صندخ/پشوبزه خط اختیاری|نسخه| {{{نسخه|{{{ورژن|}}}}}} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |پلتفورم | {{{platform|{{{پلتفورم|{{{platforms|{{{سیستم|{{{سیستمون|{{{سیستم‌ها|}}}}}}}}} }}} }}} }}} |خاصیه=P400 |لیست=yes }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |انتشار گدر |{{{إصدر|{{{released|{{{انتشار|{{{release|}}}}}}}}}}}} |خاصیه=P577 |تصفیه=P291 |تصفیه1=P400 |لیست=yes }} {{صندخ/پشوبزه خط اختیاری |آخرین نسخه | {{{آخرین نسخه|}}} {{#اگر: {{{آخرین نسخه تاریخ|}}}| / {{{آخرین نسخه تاریخ|}}} }} }} {{صندخ/پشوبزه خط اختیاری |تریلر انتشار | {{{تریلر انتشار|}}} {{#اگر: {{{تریلر انتشار تاریخ|}}}| / {{{تریلر انتشار تاریخ|}}} }} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |ژانر | {{{genre|{{{ژانر|{{{سبک|}}}}}} }}} |خاصیه=P136 }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |مُد | {{{mode|{{{مد|{{{modes|{{{مدل|}}}}}}}}}}}} |خاصیه=P404 }} {{صندخ/پشوبزه خط اختیاری|[[نظام تقییم محتوى لعبه فیدیو|التقدیر]]| {{{تقدیر|}}} }} {{صندخ/پشوبزه خط اختیاری |تنک بیّن |{{{تنک|{{{توزیع|}}}}}} }} {{صندخ/پشوبزه خط اختیاری|حداقل سیستم| {{{حداقل سیستم|}}} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}}|خاصیه=P437|تصفیه=P400|لیست=yes |مدیا | {{{media|{{{مدیا|}}} }}} }} {{صندخ/پشوبزه خط اختیاری|کا صندخ نوع| {{{cabinet|{{{صندخ نوع|}}} }}} }} {{صندخ/پشوبزه خط اختیاری|کا صندخ سیستم| {{{arcade system|{{{کا صندخ سیستم|}}} }}} }} {{صندخ/پشوبزه خط اختیاری|سی‌پی‌یو| {{{cpu|{{{سی پی یو|}}} }}} }} {{صندخ/پشوبزه خط اختیاری|صوتی سیستم| {{{sound|{{{صوت|}}} }}} }} {{صندخ/پشوبزه خط اختیاری|نمایش سیستم| {{{display|{{{نمایش|}}} }}} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |ورودی | {{{input|{{{ورودی|}}} }}} |خاصیه=P479 }} {{صندخ/عنوان فرعی اختیاری |سنی رج‌وَندی |{{{PEGI|}}}{{{ESRB|}}}{{{USK|}}}{{#switch:{{{ویکی دیتا|}}}|no=|#default={{#invoke:Wikidata2|formatStatements|property=P852|noref=true|firstvalue=true|formatting=raw}} {{#invoke:Wikidata2|formatStatements|property=P914|noref=true|firstvalue=true|formatting=raw}} {{#invoke:Wikidata2|formatStatements|property=P908|noref=true|firstvalue=true|formatting=raw}} }} }} <!-- {{صندخ/سطر اختیاری |{{صندخ/کامپیوتری کا/سنی رج‌وَندی | PEGI = {{{PEGI|}}} | USK = {{{USK|}}} | ESRB = {{{ESRB|}}} }} }} --> {{صندخ/سطر معلومات | 1 = {{ESRB|{{{ESRB|}}}|عنوان=yes|wikidata={{#switch:{{{ویکی دیتا|}}}|no=|#default=yes}}}} | 2 = {{PEGI|{{{PEGI|}}}|60|x58|عنوان=yes|wikidata={{#switch:{{{ویکی دیتا|}}}|no=|#default=yes}}}} | 3 = {{USK|{{{USK|}}}|60|x58|عنوان=yes|wikidata={{#switch:{{{ویکی دیتا|}}}|no=|#default=yes}}}} | 4 = | 5 = }} {{صندخ/فاصل اختیاری |{{{PEGI|}}}{{{USK|}}}{{{ESRB|}}} {{#switch:{{{ویکی دیتا|}}}|no=|#default={{#invoke:Wikidata2|formatStatements|property=P852|noref=true|firstvalue=true|formatting=raw}} {{#invoke:Wikidata2|formatStatements|property=P914|noref=true|firstvalue=true|formatting=raw}} {{#invoke:Wikidata2|formatStatements|property=P908|noref=true|firstvalue=true|formatting=raw}} }} }} {{صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی|ویکی دیتا={{{ویکی دیتا|}}} |رسمی سایت | {{{سایت|{{{رسمی سایت|}}} }}} |خاصیه=P856 |کامل لینک=yes }} {{صندخ/قبل-بعد ویکی دیتا|{{{قبلی|}}}|{{{بعدی|}}}}} {{صندخ/اشاره|صندخ/کامپیوتری کا}} |}<noinclude> [[رج:شابلون:صندخ]] {{توضیحات}} </noinclude> 2uijxkpnsxl476bkhh9ergn41jqyb1g ماژول:Citation/CS1/Utilities 828 41038 390385 328961 2026-07-17T19:02:09Z محک 1023 390385 Scribunto text/plain local z = { error_cats_t = {}; -- for categorizing citations that contain errors error_ids_t = {}; -- list of error identifiers; used to prevent duplication of certain errors; local to this module error_msgs_t = {}; -- sequence table of error messages maint_cats_t = {}; -- for categorizing citations that aren't erroneous per se, but could use a little work prop_cats_t = {}; -- for categorizing citations based on certain properties, language of source for instance prop_keys_t = {}; -- for adding classes to the citation's <cite> tag }; --[[--------------------------< F O R W A R D D E C L A R A T I O N S >-------------------------------------- ]] local cfg; -- table of tables imported from selected Module:Citation/CS1/Configuration --[[--------------------------< I S _ S E T >------------------------------------------------------------------ Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string. ]] local function is_set (var) return not (var == nil or var == ''); end --[[--------------------------< I N _ A R R A Y >-------------------------------------------------------------- Whether needle is in haystack ]] local function in_array (needle, haystack) if needle == nil then return false; end for n, v in ipairs (haystack) do if v == needle then return n; end end return false; end --[[--------------------------< H A S _ A C C E P T _ A S _ W R I T T E N >------------------------------------ When <str> is wholly wrapped in accept-as-written markup, return <str> without markup and true; return <str> and false else with allow_empty = false, <str> must have at least one character inside the markup with allow_empty = true, <str> the markup frame can be empty like (()) to distinguish an empty template parameter from the specific condition "has no applicable value" in citation-context. After further evaluation the two cases might be merged at a later stage, but should be kept separated for now. ]] local function has_accept_as_written (str, allow_empty) if not is_set (str) then return str, false; end local count; if true == allow_empty then str, count = str:gsub ('^%(%((.*)%)%)$', '%1'); -- allows (()) to be an empty set else str, count = str:gsub ('^%(%((.+)%)%)$', '%1'); end return str, 0 ~= count; end --[[--------------------------< S U B S T I T U T E >---------------------------------------------------------- Populates numbered arguments in a message string using an argument table. <args> may be a single string or a sequence table of multiple strings. ]] local function substitute (msg, args) return args and mw.message.newRawMessage (msg, args):plain() or msg; end --[[--------------------------< E R R O R _ C O M M E N T >---------------------------------------------------- Wraps error messages with CSS markup according to the state of hidden. <content> may be a single string or a sequence table of multiple strings. ]] local function error_comment (content, hidden) return substitute (hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content); end --[[--------------------------< H Y P H E N _ T O _ D A S H >-------------------------------------------------- Converts a hyphen, endash, emdash to endash under certain conditions. The hyphen/en/em must separate like items; unlike items are returned unmodified. These forms are modified: letter - letter (A-B) digit - digit (4-5) digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5) letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5) digitletter - digitletter (5a-5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d) any other forms are returned unmodified. str may be a comma- or semicolon-separated list of page ranges with/without single pages ]] local function hyphen_to_dash (str) if not is_set (str) then return str; end str = str:gsub ("(%(%(.-%)%))", function(m) return m:gsub(",", ","):gsub(";", ";") end) -- replace commas and semicolons in accept-as-written markup with similar unicode characters so they'll be ignored during the split str = str:gsub ('&[nm]dash;', {['&ndash;'] = '–', ['&mdash;'] = '—'}); -- replace &mdash; and &ndash; entities with their characters; semicolon mucks up the text.split str = str:gsub ('&#45;', '-'); -- replace HTML numeric entity with hyphen character str = str:gsub ('&nbsp;', ' '); -- replace &nbsp; entity with generic keyboard space character local out = {}; local list = mw.text.split (str, '%s*[,;]%s*'); -- split str at comma or semicolon separators if there are any local accept; -- boolean for _, item in ipairs (list) do -- for each item in the list item, accept = has_accept_as_written (item); -- remove accept-this-as-written markup when it wraps all of item if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[—–-]%s*%w*[%.%-]?%w+$') then -- if a hyphenated range or has endash or emdash separators if mw.ustring.match (item, '^%a+[%.%-]?%d+%s*[—–-]%s*%a+[%.%-]?%d+$') or -- letterdigit hyphen letterdigit (optional separator between letter and digit) mw.ustring.match (item, '^%d+[%.%-]?%a+%s*[—–-]%s*%d+[%.%-]?%a+$') or -- digitletter hyphen digitletter (optional separator between digit and letter) mw.ustring.match (item, '^%d+[%.%-]%d+%s*[—–-]%s*%d+[%.%-]%d+$') then -- digit separator digit hyphen digit separator digit item = mw.ustring.gsub (item, '(%w*[%.%-]?%w+)%s*[—–-]%s*(%w*[%.%-]?%w+)', '<span class="nowrap">%1 –</span> <span class="nowrap">%2</span>'); -- replace hyphen/dash, with spaced endash elseif mw.ustring.match (item, '^%d+%s*[—–-]%s*%d+$') or -- digit hyphen digit mw.ustring.match (item, '^%a+%s*[—–-]%s*%a+$') then -- letter hyphen letter item = mw.ustring.gsub (item, '(%w+)%s*[—–-]%s*(%w+)', '<span class="nowrap">%1–</span>%2'); -- replace hyphen/emdash with endash, remove extraneous space characters else -- item = mw.ustring.gsub (item, '%s*[—–-]%s*', '–'); -- disabled; here when 'unlike' items so return <item> as is end end table.insert (out, item); -- add the (possibly modified) item to the output table end local temp_str = ''; -- concatenate the output table into a comma separated string temp_str, accept = has_accept_as_written (table.concat (out, ', ')); -- remove accept-this-as-written markup when it wraps all of concatenated out if accept then temp_str = has_accept_as_written (str); -- when global markup removed, return original str; do it this way to suppress boolean second return value return temp_str:gsub(",", ","):gsub(";", ";"); else return temp_str:gsub(",", ","):gsub(";", ";"); -- else, return assembled temp_str end end --[=[-------------------------< M A K E _ W I K I L I N K >---------------------------------------------------- Makes a wikilink; when both link and display text is provided, returns a wikilink in the form [[L|D]]; if only link is provided (or link and display are the same), returns a wikilink in the form [[L]]; if neither are provided or link is omitted, returns an empty string. ]=] local function make_wikilink (link, display) if not is_set (link) then return '' end if is_set (display) and link ~= display then return table.concat ({'[[', link, '|', display, ']]'}); else return table.concat ({'[[', link, ']]'}); end end --[[--------------------------< S E T _ M E S S A G E >---------------------------------------------------------- Sets an error message using the ~/Configuration error_conditions{} table along with arguments supplied in the function call, inserts the resulting message in z.error_msgs_t{} sequence table, and returns the error message. <error_id> – key value for appropriate error handler in ~/Configuration error_conditions{} table <arguments> – may be a single string or a sequence table of multiple strings to be subsititued into error_conditions[error_id].message <raw> – boolean true – causes this function to return the error message not wrapped in visible-error, hidden-error span tag; returns error_conditions[error_id].hidden as a second return value does not add message to z.error_msgs_t sequence table false, nil – adds message wrapped in visible-error, hidden-error span tag to z.error_msgs_t returns the error message wrapped in visible-error, hidden-error span tag; there is no second return value <prefix> – string to be prepended to <message> -- TODO: remove support for these unused(?) arguments? <suffix> – string to be appended to <message> TODO: change z.error_cats_t and z.maint_cats_t to have the form cat_name = true? this to avoid dups without having to have an extra table ]] local added_maint_cats = {} -- list of maintenance categories that have been added to z.maint_cats_t; TODO: figure out how to delete this table local function set_message (error_id, arguments, raw, prefix, suffix) local error_state = cfg.error_conditions[error_id]; prefix = prefix or ''; suffix = suffix or ''; if error_state == nil then error (cfg.messages['undefined_error'] .. ': ' .. error_id); -- because missing error handler in Module:Citation/CS1/Configuration elseif is_set (error_state.category) then if error_state.message then -- when error_state.message defined, this is an error message table.insert (z.error_cats_t, error_state.category); else if not added_maint_cats[error_id] then added_maint_cats[error_id] = true; -- note that we've added this category table.insert (z.maint_cats_t, substitute (error_state.category, arguments)); -- make cat name then add to table end return; -- because no message, nothing more to do end end local message = substitute (error_state.message, arguments); message = table.concat ( { message, ' (', make_wikilink ( table.concat ( { cfg.messages['help page link'], '#', error_state.anchor }), cfg.messages['help page label']), ')' }); z.error_ids_t[error_id] = true; if z.error_ids_t['err_citation_missing_title'] and -- if missing-title error already noted in_array (error_id, {'err_bare_url_missing_title', 'err_trans_missing_title'}) then -- and this error is one of these return '', false; -- don't bother because one flavor of missing title is sufficient end message = table.concat ({prefix, message, suffix}); if true == raw then return message, error_state.hidden; -- return message not wrapped in visible-error, hidden-error span tag end message = error_comment (message, error_state.hidden); -- wrap message in visible-error, hidden-error span tag table.insert (z.error_msgs_t, message); -- add it to the messages sequence table return message; -- and done; return value generally not used but is used as a flag in various functions of ~/Identifiers end --[[-------------------------< I S _ A L I A S _ U S E D >----------------------------------------------------- This function is used by select_one() to determine if one of a list of alias parameters is in the argument list provided by the template. Input: args – pointer to the arguments table from calling template alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration index – for enumerated parameters, identifies which one enumerated – true/false flag used to choose how enumerated aliases are examined value – value associated with an alias that has previously been selected; nil if not yet selected selected – the alias that has previously been selected; nil if not yet selected error_list – list of aliases that are duplicates of the alias already selected Returns: value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected ]] local function is_alias_used (args, alias, index, enumerated, value, selected, error_list) if enumerated then -- is this a test for an enumerated parameters? alias = alias:gsub ('#', index); -- replace '#' with the value in index else alias = alias:gsub ('#', ''); -- remove '#' if it exists end if is_set (args[alias]) then -- alias is in the template's argument list if value ~= nil and selected ~= alias then -- if we have already selected one of the aliases local skip; for _, v in ipairs (error_list) do -- spin through the error list to see if we've added this alias if v == alias then skip = true; break; -- has been added so stop looking end end if not skip then -- has not been added so table.insert (error_list, alias); -- add error alias to the error list end else value = args[alias]; -- not yet selected an alias, so select this one selected = alias; end end return value, selected; -- return newly selected alias, or previously selected alias end --[[--------------------------< A D D _ M A I N T _ C A T >------------------------------------------------------ Adds a category to z.maint_cats_t using names from the configuration file with additional text if any. To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maint_cats_t. ]] local function add_maint_cat (key, arguments) if not added_maint_cats [key] then added_maint_cats [key] = true; -- note that we've added this category table.insert (z.maint_cats_t, substitute (cfg.maint_cats [key], arguments)); -- make name then add to table end end --[[--------------------------< A D D _ P R O P _ C A T >-------------------------------------------------------- Adds a category to z.prop_cats_t using names from the configuration file with additional text if any. foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages may be categorized but multiples of the same language are not categorized. added_prop_cats is a table declared in page scope variables above ]] local added_prop_cats = {}; -- list of property categories that have been added to z.prop_cats_t local function add_prop_cat (key, arguments, key_modifier) local key_modified = key .. ((key_modifier and key_modifier) or ''); -- modify <key> with <key_modifier> if present and not nil if not added_prop_cats [key_modified] then added_prop_cats [key_modified] = true; -- note that we've added this category table.insert (z.prop_cats_t, substitute (cfg.prop_cats [key], arguments)); -- make name then add to table table.insert (z.prop_keys_t, 'cs1-prop-' .. key); -- convert key to class for use in the citation's <cite> tag end end --[[--------------------------< S A F E _ F O R _ I T A L I C S >---------------------------------------------- Protects a string that will be wrapped in wiki italic markup '' ... '' Note: We cannot use <i> for italics, as the expected behavior for italics specified by ''...'' in the title is that they will be inverted (i.e. unitalicized) in the resulting references. In addition, <i> and '' tend to interact poorly under Mediawiki's HTML tidy. ]] local function safe_for_italics (str) if not is_set (str) then return str end if str:sub (1, 1) == "'" then str = "<span></span>" .. str; end if str:sub (-1, -1) == "'" then str = str .. "<span></span>"; end return str:gsub ('\n', ' '); -- Remove newlines as they break italics. end --[[--------------------------< W R A P _ S T Y L E >---------------------------------------------------------- Applies styling to various parameters. Supplied string is wrapped using a message_list configuration taking one argument; protects italic styled parameters. Additional text taken from citation_config.presentation - the reason this function is similar to but separate from wrap_msg(). ]] local function wrap_style (key, str) if not is_set (str) then return ""; elseif in_array (key, {'italic-title', 'trans-italic-title'}) then str = safe_for_italics (str); end return substitute (cfg.presentation[key], {str}); end --[[--------------------------< M A K E _ S E P _ L I S T >------------------------------------------------------------ make a separated list of items using provided separators. <sep_list> - typically '<comma><space>' <sep_list_pair> - typically '<space>and<space>' <sep_list_end> - typically '<comma><space>and<space>' or '<comma><space>&<space>' defaults to cfg.presentation['sep_list'], cfg.presentation['sep_list_pair'], and cfg.presentation['sep_list_end'] if <sep_list_end> is specified, <sep_list> and <sep_list_pair> must also be supplied ]] local function make_sep_list (count, list_seq, sep_list, sep_list_pair, sep_list_end) local list = ''; if not sep_list then -- set the defaults sep_list = cfg.presentation['sep_list']; sep_list_pair = cfg.presentation['sep_list_pair']; sep_list_end = cfg.presentation['sep_list_end']; end if 2 >= count then list = table.concat (list_seq, sep_list_pair); -- insert separator between two items; returns list_seq[1] then only one item elseif 2 < count then list = table.concat (list_seq, sep_list, 1, count - 1); -- concatenate all but last item with plain list separator list = table.concat ({list, list_seq[count]}, sep_list_end); -- concatenate last item onto end of <list> with final separator end return list; end --[[--------------------------< S E L E C T _ O N E >---------------------------------------------------------- Chooses one matching parameter from a list of parameters to consider. The list of parameters to consider is just names. For parameters that may be enumerated, the position of the numerator in the parameter name is identified by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'. Because enumerated parameter |<param>1= is an alias of |<param>= we must test for both possibilities. Generates an error if more than one match is present. ]] local function select_one (args, aliases_list, error_condition, index) local value = nil; -- the value assigned to the selected parameter local selected = ''; -- the name of the parameter we have chosen local error_list = {}; if index ~= nil then index = tostring(index); end for _, alias in ipairs (aliases_list) do -- for each alias in the aliases list if alias:match ('#') then -- if this alias can be enumerated if '1' == index then -- when index is 1 test for enumerated and non-enumerated aliases value, selected = is_alias_used (args, alias, index, false, value, selected, error_list); -- first test for non-enumerated alias end value, selected = is_alias_used (args, alias, index, true, value, selected, error_list); -- test for enumerated alias else value, selected = is_alias_used (args, alias, index, false, value, selected, error_list); -- test for non-enumerated alias end end if #error_list > 0 and 'none' ~= error_condition then -- for cases where this code is used outside of extract_names() for i, v in ipairs (error_list) do error_list[i] = wrap_style ('parameter', v); end table.insert (error_list, wrap_style ('parameter', selected)); set_message (error_condition, {make_sep_list (#error_list, error_list)}); end return value, selected; end --[=[-------------------------< R E M O V E _ W I K I _ L I N K >---------------------------------------------- Gets the display text from a wikilink like [[A|B]] or [[B]] gives B The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup). In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims whitespace from the label if str was wrapped in wikilink markup. Presumably, this is because without wikimarkup in str, there is no match in the initial gsub, the replacement function l() doesn't get called. ]=] local function remove_wiki_link (str) return (str:gsub ("%[%[([^%[%]]*)%]%]", function(l) return l:gsub ("^[^|]*|(.*)$", "%1" ):gsub ("^%s*(.-)%s*$", "%1"); end)); end --[=[-------------------------< I S _ W I K I L I N K >-------------------------------------------------------- Determines if str is a wikilink, extracts, and returns the wikilink type, link text, and display text parts. If str is a complex wikilink ([[L|D]]): returns wl_type 2 and D and L from [[L|D]]; if str is a simple wikilink ([[D]]) returns wl_type 1 and D from [[D]] and L as empty string; if not a wikilink: returns wl_type 0, str as D, and L as empty string. trims leading and trailing whitespace and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes). ]=] local function is_wikilink (str) local D, L local wl_type = 2; -- assume that str is a complex wikilink [[L|D]] if not str:match ('^%[%[[^%]]+%]%]$') then -- is str some sort of a wikilink (must have some sort of content) return 0, str, ''; -- not a wikilink; return wl_type as 0, str as D, and empty string as L end L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$'); -- get L and D from [[L|D]] if not is_set (D) then -- if no separate display D = str:match ('^%[%[([^%]]*)|*%]%]$'); -- get D from [[D]] or [[D|]] wl_type = 1; end D = mw.text.trim (D, '%s|'); -- trim white space and pipe characters return wl_type, D, L or ''; end --[[--------------------------< S T R I P _ A P O S T R O P H E _ M A R K U P >-------------------------------- Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata. This function strips common patterns of apostrophe markup. We presume that editors who have taken the time to markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind. Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was removed; returns the argument and nil when no markup removed ]] local function strip_apostrophe_markup (argument) if not is_set (argument) then return argument, nil; -- no argument, nothing to do end if nil == argument:find ( "''", 1, true ) then -- Is there at least one double apostrophe? If not, exit. return argument, nil; end local flag; while true do if argument:find ("'''''", 1, true) then -- bold italic (5) argument, flag = argument:gsub ("%'%'%'%'%'", ""); -- remove all instances of it elseif argument:find ("''''", 1, true) then -- italic start and end without content (4) argument, flag=argument:gsub ("%'%'%'%'", ""); elseif argument:find ("'''", 1, true) then -- bold (3) argument, flag=argument:gsub ("%'%'%'", ""); elseif argument:find ("''", 1, true) then -- italic (2) argument, flag = argument:gsub ("%'%'", ""); else break; end end return argument, flag; -- done end --[[--------------------------< S E T _ S E L E C T E D _ M O D U L E S >-------------------------------------- Sets local cfg table to same (live or sandbox) as that used by the other modules. ]] local function set_selected_modules (cfg_table_ptr) cfg = cfg_table_ptr; end --[[--------------------------< E X P O R T S >---------------------------------------------------------------- ]] return { add_maint_cat = add_maint_cat, -- exported functions add_prop_cat = add_prop_cat, error_comment = error_comment, has_accept_as_written = has_accept_as_written, hyphen_to_dash = hyphen_to_dash, in_array = in_array, is_set = is_set, is_wikilink = is_wikilink, make_sep_list = make_sep_list, make_wikilink = make_wikilink, remove_wiki_link = remove_wiki_link, safe_for_italics = safe_for_italics, select_one = select_one, set_message = set_message, set_selected_modules = set_selected_modules, strip_apostrophe_markup = strip_apostrophe_markup, substitute = substitute, wrap_style = wrap_style, z = z, -- exported table } 1rgyhapxi1dzuxmh3cqix2zrvvro8l2 سینگولاریتی 0 47302 390387 329309 2026-07-17T20:32:02Z HenryThe 27142 +لینک 390387 wikitext text/x-wiki {{کامپیوتری بازی جعبه|کا نوم=سینگولاریتی|title=Singularity (video game)|تنک‌کر=اکتیویژن|سازنده=ریون سافتور|موتور=Unreal Engine 3|پلتفورم=Microsoft Windows PlayStation 3 Xbox 360|عکس=Singularity_cover.jpg|director=Dan Vondrak|سایت=...|composer=چارلی کلاوسر، مایکل واندماکر}} '''سینگولاریتی''' ([[اینگلیسی زوون|اینگلیسی]] جه: ''Singularity'' ) اتا اول شخص [[ویدئو کاء|ویدئو کا]] نوم هسّه کا کومپانی رِیوِن سافت‌وِر (Raven Software) دله بسات بئی یه و سال 2010، اکتیوژن کومپانی (Activision) اینتا کا رهMicrosoft Windows، PlayStation 3، Xbox 360 وسه [[تنک‌کری|تنک]] هاکردنه. این ویدیو کا ره اپیک گیمز (Epic Games) گرافیکی ماتور جا کا ونه نوم آنریل انجین 3 (Unreal Engine 3) هسّه بساتنه. == گیم پلی == سینگولاریتی اتا اول شخص تیراندازی هسّه کا ترس عنصرئون هم دارنه. اتا دستگاه دره کا ونه نوم TMD هسه. کاکر اینتا دستگاه جا تونده [[توم]] ره دست بوره و توم دله یور و یِر بوره، آدم ئون یا اشیائونی که وینده ره تغییر هاده بستینکلا خراب بئی پل ره توم دله یِر بَوِره و وِره تغییر هاده به اون گدر که سالم بی یه، یا اون گدر که دِشمند ره وینه وره توم دله انّه یور بوره که ونه جا فقط [[استکا|هِسِکا]] بمونّه. اتی جائون هم دره که کاکر تونده TMD دستگاه ره بَوره اونجه تا ونه قِد ره ویشتر هاکنه. === مالتی پلیر === کاکرئون توندنه مالتی پلیر هم بازی هاکنن که دِ حالت دارنه. وشون یا همه سرباز نقش دارِنّه و چند تا تیم رسد بونه و همدیگر جا الجه کفنّه، یا اتا تیم سرباز نقش گیرنه و اتا تیم توشمار‌ نقش گیرنه و اِتی کا شرو بونه. == آسنی == کا آسنی اینتی شِروع بونه که اتا [[جزیره]] که ونه نوم کاتورگا-دِوازِّه ('''Katorga-12''') هسّه و [[شوروی]] وسه بی‌یه و اِسا هِچکس ونه دله دنی‌یه اتّا مغناطیسی پالس در کنّه کا باعث بونه اتا [[آمریکای متحده ایالات|آمریکایی]] جاسوسی مونگ‌مونا‌ (=ماهواره) آسیب بوینه. همینسه وشون شک کفنه و اتا تیم ره هلی‌کوپتر ره جا راهی کندنه تا بورن جزیره ره وررسی هاکنن. سربازئون تا برسینه اتی مغناطیسی پالس در بونه و وشون هلی‌کوپتر رقد شونه. اینجه کاکر اتا سرباز نقش کا ونه نوم ناتانیل رینکو هسّه ره شه دست گیرنه. == بساتن == Raven Software باته که سینگولاریتی بساتن خله مشکلات داشته و اتا کَش Activision که سینگولاریتی تنک‌کَر بی‌یه نزدیک بی‌یه دِرِسّی بزنه کا ره کنسل هاکنه.<ref>Fuller, Keith (March 3, 2014). [https://www.polygon.com/2014/3/3/5462994/singularity-two-years-to-make-a-mess-ten-months-to-clean-it-up "The Confessional: It took two years to cancel Singularity, and ten months to fix it"]. [[:en:Polygon_(website)|Polygon]]. [[:en:Vox_Media|Vox Media]]. [https://web.archive.org/web/20180520054029/https://www.polygon.com/2014/3/3/5462994/singularity-two-years-to-make-a-mess-ten-months-to-clean-it-up Archived] from the original on May 20, 2018. Retrieved February 25, 2018.</ref> ونه بساتن گدر رِیوِن سافت‌ور شه پرسنل ره کمتِر هاکرده و کا چن کش عقب دکته و تنک بَیِّنِ توم ارزا بَیّه. == تنک بَیِّن په == سینگولاریتی خله خار-خار نقد بئی‌ته و هر پلتفورمی کا ونه وسه تنک بیه موفق بی‌یه و ویدئو کا نقدکرئون وره خله خار نمره هدانه. <ref>[https://www.metacritic.com/game/singularity/critic-reviews/?platform=pc "Singularity for PC Reviews"]. [[:en:Metacritic|Metacritic]]. CBS Interactive. [https://web.archive.org/web/20180524094727/http://www.metacritic.com/game/pc/singularity Archived] from the original on May 24, 2018. Retrieved May 19, 2018.</ref><ref>[https://www.metacritic.com/game/singularity/critic-reviews/?platform=playstation-3 "Singularity for PlayStation 3 Reviews"]. Metacritic. CBS Interactive. [https://web.archive.org/web/20100816112408/http://www.metacritic.com/game/playstation-3/singularity Archived] from the original on August 16, 2010. Retrieved May 19, 2018.</ref><ref>[https://www.metacritic.com/game/singularity/critic-reviews/?platform=xbox-360 "Singularity for Xbox 360 Reviews"]. Metacritic. CBS Interactive. [https://web.archive.org/web/20100817183839/http://www.metacritic.com/game/xbox-360/singularity Archived] from the original on August 17, 2010. Retrieved July 31, 2010.</ref>ونه تنک‌کر کومپانی اکتیوژن، ونه بروتن جا که 400.000 نوسخه جه کم‌ته بی‌یه رضایت ناشته.<ref>Parfitt, Ben (August 6, 2010). [https://www.mcvuk.com/business/singularity-and-blur-fell-short "Singularity and Blur 'fell short'"]. [[:en:MCV_(magazine)|MCV]]. [[:en:NewBay_Media|NewBay Media]]. [https://web.archive.org/web/20100920233645/http://www.mcvuk.com/news/40308/Singularity-and-Blur-fell-short Archived] from the original on September 20, 2010. Retrieved May 19, 2018.</ref> == منبع == * 11 ارکه ما 1535 تبری، این ولگ [[:en:Singularity_(video_game)|اینگلیسی ویکی‌پدیا]] جه ترجمه بیّه. [[رج:کامپیوتری کائون]] 5cxtl6j8th7kx24z6k7xijdh1mrbfg5 فارکرای 0 47522 390372 327970 2026-07-17T16:05:07Z HenryThe 27142 +لینک +بروتن 390372 wikitext text/x-wiki {{صندخ/ویدئو کا|لوگو=Far Cry logo.svg}} '''فارکرای''' ([[اینگلیسی زوون|اینگلیسی]] جه: ''Far Cry'')، اتّا اول شخصِ تیراندازیِ ویدئوکائونِ [[فرانچایز]] هسّه، که همه ره هم [[یوبی سافت|یوبی‌سافت]] تنک هاکرده. یتِّمین سریِ کا ره [[کرایتِک]] کومپانی بساته تا ونه جه شه نرم‌افزار، [[کرای‌اِنجین]] ره که اولین کَش این کا وسّه به کار بورده ره عموم وسّه سراق هادن. یتِّمین [[فار کرای ۱|فار کرای]]، 2004 مارچِ مایِ گدر تنک بیّه. این توم به یور، یوبی‌سافت هین فرانچایزِ حق ره شه وسّه بئیته و کا ساجی ره شه کِرده و ونه [[یوبی‌سافت مونترالِ]] استودیو، بساتنِ ویشته کارئون ره انجام دائه. یوبی‌سافتِ بساتِ فارکرای کائون، [[دونیا ماتور]] ره جه بساته بَینه که کرای‌اِنجین ماتور هسّه که وره اَتی تغییر هدانه و بت‌تِر هاکردنه که اینتا ماتور جه وشون بَتون‌دِستنه که [[وا-جهون|وا-جهونِ]] گیم‌پلی بساجن. اِسا، فرانچایز، 6 تا اصلی کا و اتی فرعی دمباله دارنه. فارکرایِ کائون آسنی اینتی هسّه که کاکر ره اتا الخی موحیط دله اِلِنّه کا وه ونه کومک هاکنه که منطقه ره کا نِخار آدمئون دسِّ بِن دره در بیارِن و هم وه وِنه اِلخی حیوونون که ولار و وشای منطقه‌یِ دله دَره چرخ گیرنّه ره مِخوِر بوشه. فارکرایِ کائون مالتی پلیر دی دارنّه که اِلنه کاکرئون کایِ [[نخشه]] ره دس بَوِرن و دچی هاکنن. اینتا ویدئوکایِ سری ره، وِشون [[آنتاگونیست‌|آنتاگونیست‌ئون]] و وا-جهونِ گیم‌پلی وسّه ستایش هاکردنه اما کا نقدکرئون خلاقیت ناشتن و ترنه نَیِّن وسّه نِهِب بزونه. فارکرایِ کائون عموما موئَفِّق بی‌نه و دلوس بَینه، اینتا فرانچایزِ بروتن دی خار بی‌یه و خله کاکرئون وشون ره بخرینه. == بروتن == یوبی‌سافت گِزارش هدائه کا تا 2014 سال گدر؛ گردِ فارکرایِ فرانچایزِ بروتن، 20 میلیون نوسخه جا یور بورده.<ref name=":0">[https://web.archive.org/web/20140721012750/http://www.ubisoftgroup.com/en-us/about_ubisoft/facts_and_figures.aspx "Facts & Figures"]. [[:en:Ubisoft|Ubisoft]]. 2014. Archived from [http://www.ubisoftgroup.com/en-us/about_ubisoft/facts_and_figures.aspx the original] on July 21, 2014. Retrieved July 21, 2014.</ref> تا 2019 سپتامبر ما، این فرانچایز کائون بروتن، 50 میلیون نوسخه جا بَرسی‌ بی‌یه.<ref name=":0" /><ref>Jones, Ali (September 27, 2019). [https://www.pcgamesn.com/assassins-creed-sales "Assassin's Creed all-time sales top 140 million"]. [[:en:PCGamesN|PCGamesN]]. [https://web.archive.org/web/20190927144238/https://www.pcgamesn.com/assassins-creed-sales Archived] from the original on September 27, 2019. Retrieved September 27, 2019.</ref><ref>[https://www.ubisoftgroup.com/comsite_common/en-US/images/pressrelease_downloadablemm_20150212_050959_ubisoftq3fy15englishfinaltcm99193930.pdf "Ubisoft® reports third quarter 2014–15 sales"] (PDF). [[:en:Ubisoft|Ubisoft]]. February 13, 2015. [https://web.archive.org/web/20150213212843/https://www.ubisoftgroup.com/comsite_common/en-US/images/pressrelease_downloadablemm_20150212_050959_ubisoftq3fy15englishfinaltcm99193930.pdf Archived] (PDF) from the original on February 13, 2015. Retrieved February 13, 2015.</ref><ref>Ubisoft. [https://news.ubisoft.com/en-us/article/321550/far-cry-5-breaks-franchise-sales-records "Far Cry 5 Breaks Franchise Sales Records."] [https://web.archive.org/web/20190925104407/https://news.ubisoft.com/en-us/article/321550/far-cry-5-breaks-franchise-sales-records Archived] September 25, 2019, at the [[:en:Wayback_Machine|Wayback Machine]] April 4, 2018. "Far Cry 5 now represents the second biggest launch ever for a Ubisoft game, following only Tom Clancy's The Division, with $310M USD in consumer spending through the first week." $310m / ~$60 per copy = ~5.16 million copies sold in the first week.</ref> == منبع == {{په‌نویس}} * 4 ده مایِ 1535 تبری، این ولگ [[:en:Far_Cry|اینگلیسی ویکی‌پدیا]] جه ترجمه بیّه. [[رج:کامپیوتری کائون]] [[رج:ویدئوکا سری]] [[رج:یوبی‌سافت]] [[رج:دونیا ماتور]] nycm5tdv9u6pvwhbs7qcu7vyg68r6sy 390378 390372 2026-07-17T18:03:22Z محک 1023 صندخ دستی بشتمه 390378 wikitext text/x-wiki {{صندخ/ویدئو کا|لوگو=Far Cry logo.svg | title = Far Cry | image = Far Cry logo.svg | genre = [[تیراندازی اول‌شخص]] [[ اکشن-ماجراجویی کا]] | developer = {{Unbulleted indent list|[[کرای‌تک]] (2004)|[[یوبی‌سافت مونترآل]] (2005–2019)|[[یوبی‌سافت تورنتو]] (2018–present)}} | publisher = [[یوبی‌سافت]] | platforms = {{Unbulleted indent list|[[مایکروسافت ویندوز]]|[[ایکس‌باکس (کنسول)]]|[[ایکس‌باکس ۳۶۰]]|[[وی]]|[[بازی آرکید]]|[[پلی‌استیشن ۳]]|[[پلی‌استیشن ۴]]|[[ایکس‌باکس وان]]|[[گوگل استادیا]]|[[ایکس‌باکس سری اکس و سری اس]]|[[پلی‌استیشن ۵]]}} | first release version = ''[[فار کرای]]'' | first release date = 23 مارس 2004 | latest release version = ''[[فار کرای ۶]]'' | latest release date = 7 اکتبر 2021 }} '''فارکرای''' ([[اینگلیسی زوون|اینگلیسی]] جه: ''Far Cry'')، اتّا اول شخصِ تیراندازیِ ویدئوکائونِ [[فرانچایز]] هسّه، که همه ره هم [[یوبی سافت|یوبی‌سافت]] تنک هاکرده. یتِّمین سریِ کا ره [[کرایتِک]] کومپانی بساته تا ونه جه شه نرم‌افزار، [[کرای‌اِنجین]] ره که اولین کَش این کا وسّه به کار بورده ره عموم وسّه سراق هادن. یتِّمین [[فار کرای ۱|فار کرای]]، ۲۰۰۴ مارچِ مایِ گدر تنک بیّه. این توم به یور، یوبی‌سافت هین فرانچایزِ حق ره شه وسّه بئیته و کا ساجی ره شه کِرده و ونه [[یوبی‌سافت مونترالِ]] استودیو، بساتنِ ویشته کارئون ره انجام دائه. یوبی‌سافتِ بساتِ فارکرای کائون، [[دونیا ماتور]] ره جه بساته بَینه که کرای‌اِنجین ماتور هسّه که وره اَتی تغییر هدانه و بت‌تِر هاکردنه که اینتا ماتور جه وشون بَتون‌دِستنه که [[وا-جهون|وا-جهونِ]] گیم‌پلی بساجن. اِسا، فرانچایز، ۶تا اصلی کا و اتی فرعی دمباله دارنه. فارکرایِ کائون آسنی اینتی هسّه که کاکر ره اتا الخی موحیط دله اِلِنّه کا وه ونه کومک هاکنه که منطقه ره کا نِخار آدمئون دسِّ بِن دره در بیارِن و هم وه وِنه اِلخی حیوونون که ولار و وشای منطقه‌یِ دله دَره چرخ گیرنّه ره مِخوِر بوشه. فارکرایِ کائون مالتی پلیر دی دارنّه که اِلنه کاکرئون کایِ [[نخشه]] ره دس بَوِرن و دچی هاکنن. اینتا ویدئوکایِ سری ره، وِشون [[آنتاگونیست‌|آنتاگونیست‌ئون]] و وا-جهونِ گیم‌پلی وسّه ستایش هاکردنه اما کا نقدکرئون خلاقیت ناشتن و ترنه نَیِّن وسّه نِهِب بزونه. فارکرایِ کائون عموما موئَفِّق بی‌نه و دلوس بَینه، اینتا فرانچایزِ بروتن دی خار بی‌یه و خله کاکرئون وشون ره بخرینه. == بروتن == یوبی‌سافت گِزارش هدائه کا تا ۲۰۱۴ سال گدر؛ گردِ فارکرایِ فرانچایزِ بروتن، ۲۰ میلیون نوسخه جا یور بورده.<ref name=":0">[https://web.archive.org/web/20140721012750/http://www.ubisoftgroup.com/en-us/about_ubisoft/facts_and_figures.aspx "Facts & Figures"]. [[:یوبی‌سافت]]. 2014. Archived from [http://www.ubisoftgroup.com/en-us/about_ubisoft/facts_and_figures.aspx the original] on July 21, 2014. Retrieved July 21, 2014.</ref> تا 2019 سپتامبر ما، این فرانچایز کائون بروتن، 50 میلیون نوسخه جا بَرسی‌ بی‌یه.<ref name=":0" /><ref>Jones, Ali (September 27, 2019). [https://www.pcgamesn.com/assassins-creed-sales "Assassin's Creed all-time sales top 140 million"]. [[:پی‌سی‌گیمزان]]. [https://web.archive.org/web/20190927144238/https://www.pcgamesn.com/assassins-creed-sales Archived] from the original on September 27, 2019. Retrieved September 27, 2019.</ref><ref>[https://www.ubisoftgroup.com/comsite_common/en-US/images/pressrelease_downloadablemm_20150212_050959_ubisoftq3fy15englishfinaltcm99193930.pdf "Ubisoft® reports third quarter 2014–15 sales"] (PDF). [[:یوبی‌سافت]]. February 13, 2015. [https://web.archive.org/web/20150213212843/https://www.ubisoftgroup.com/comsite_common/en-US/images/pressrelease_downloadablemm_20150212_050959_ubisoftq3fy15englishfinaltcm99193930.pdf Archived] (PDF) from the original on February 13, 2015. Retrieved February 13, 2015.</ref><ref>Ubisoft. [https://news.ubisoft.com/en-us/article/321550/far-cry-5-breaks-franchise-sales-records "Far Cry 5 Breaks Franchise Sales Records."] [https://web.archive.org/web/20190925104407/https://news.ubisoft.com/en-us/article/321550/far-cry-5-breaks-franchise-sales-records Archived] September 25, 2019, at the [[:وی‌بک ماشین]] April 4, 2018. "Far Cry 5 now represents the second biggest launch ever for a Ubisoft game, following only Tom Clancy's The Division, with $310M USD in consumer spending through the first week." $310m / ~$60 per copy = ~5.16 million copies sold in the first week.</ref> == منبع == {{په‌نویس}} * 4 ده مایِ 1535 تبری، این ولگ [[:فار کرای]] جه ترجمه بیّه. [[رج:کامپیوتری کائون]] [[رج:ویدئوکا سری]] [[رج:یوبی‌سافت]] [[رج:دونیا ماتور]] n9pk65nbqgdhs58mb6uycvf19cprnml 390379 390378 2026-07-17T18:05:04Z محک 1023 390379 wikitext text/x-wiki {{صندخ/ویدئو کا|لوگو=Far Cry logo.svg | title = Far Cry | genre = [[تیر ووشائن اول‌شخص]] [[ اکشن-ماجراجویی کا]] | developer = {{Unbulleted indent list|[[کرای‌تک]] (2004)|[[یوبی‌سافت مونترآل]] (2005–2019)|[[یوبی‌سافت تورنتو]] (2018–present)}} | publisher = [[یوبی‌سافت]] | platforms = {{Unbulleted indent list|[[مایکروسافت ویندوز]]|[[ایکس‌باکس (کنسول)]]|[[ایکس‌باکس ۳۶۰]]|[[وی]]|[[بازی آرکید]]|[[پلی‌استیشن ۳]]|[[پلی‌استیشن ۴]]|[[ایکس‌باکس وان]]|[[گوگل استادیا]]|[[ایکس‌باکس سری اکس و سری اس]]|[[پلی‌استیشن ۵]]}} | first release version = ''[[فار کرای]]'' | first release date =۲۳ مارس ۲۰۰۴ | latest release version = ''[[فار کرای ۶]]'' | latest release date =۷ اکتبر ۲۰۲۱ }} '''فارکرای''' ([[اینگلیسی زوون|اینگلیسی]] جه: ''Far Cry'')، اتّا اول شخصِ تیراندازیِ ویدئوکائونِ [[فرانچایز]] هسّه، که همه ره هم [[یوبی سافت|یوبی‌سافت]] تنک هاکرده. یتِّمین سریِ کا ره [[کرایتِک]] کومپانی بساته تا ونه جه شه نرم‌افزار، [[کرای‌اِنجین]] ره که اولین کَش این کا وسّه به کار بورده ره عموم وسّه سراق هادن. یتِّمین [[فار کرای ۱|فار کرای]]، ۲۰۰۴ مارچِ مایِ گدر تنک بیّه. این توم به یور، یوبی‌سافت هین فرانچایزِ حق ره شه وسّه بئیته و کا ساجی ره شه کِرده و ونه [[یوبی‌سافت مونترالِ]] استودیو، بساتنِ ویشته کارئون ره انجام دائه. یوبی‌سافتِ بساتِ فارکرای کائون، [[دونیا ماتور]] ره جه بساته بَینه که کرای‌اِنجین ماتور هسّه که وره اَتی تغییر هدانه و بت‌تِر هاکردنه که اینتا ماتور جه وشون بَتون‌دِستنه که [[وا-جهون|وا-جهونِ]] گیم‌پلی بساجن. اِسا، فرانچایز، ۶تا اصلی کا و اتی فرعی دمباله دارنه. فارکرایِ کائون آسنی اینتی هسّه که کاکر ره اتا الخی موحیط دله اِلِنّه کا وه ونه کومک هاکنه که منطقه ره کا نِخار آدمئون دسِّ بِن دره در بیارِن و هم وه وِنه اِلخی حیوونون که ولار و وشای منطقه‌یِ دله دَره چرخ گیرنّه ره مِخوِر بوشه. فارکرایِ کائون مالتی پلیر دی دارنّه که اِلنه کاکرئون کایِ [[نخشه]] ره دس بَوِرن و دچی هاکنن. اینتا ویدئوکایِ سری ره، وِشون [[آنتاگونیست‌|آنتاگونیست‌ئون]] و وا-جهونِ گیم‌پلی وسّه ستایش هاکردنه اما کا نقدکرئون خلاقیت ناشتن و ترنه نَیِّن وسّه نِهِب بزونه. فارکرایِ کائون عموما موئَفِّق بی‌نه و دلوس بَینه، اینتا فرانچایزِ بروتن دی خار بی‌یه و خله کاکرئون وشون ره بخرینه. == بروتن == یوبی‌سافت گِزارش هدائه کا تا ۲۰۱۴ سال گدر؛ گردِ فارکرایِ فرانچایزِ بروتن، ۲۰ میلیون نوسخه جا یور بورده.<ref name=":0">[https://web.archive.org/web/20140721012750/http://www.ubisoftgroup.com/en-us/about_ubisoft/facts_and_figures.aspx "Facts & Figures"]. [[:یوبی‌سافت]]. 2014. Archived from [http://www.ubisoftgroup.com/en-us/about_ubisoft/facts_and_figures.aspx the original] on July 21, 2014. Retrieved July 21, 2014.</ref> تا 2019 سپتامبر ما، این فرانچایز کائون بروتن، 50 میلیون نوسخه جا بَرسی‌ بی‌یه.<ref name=":0" /><ref>Jones, Ali (September 27, 2019). [https://www.pcgamesn.com/assassins-creed-sales "Assassin's Creed all-time sales top 140 million"]. [[:پی‌سی‌گیمزان]]. [https://web.archive.org/web/20190927144238/https://www.pcgamesn.com/assassins-creed-sales Archived] from the original on September 27, 2019. Retrieved September 27, 2019.</ref><ref>[https://www.ubisoftgroup.com/comsite_common/en-US/images/pressrelease_downloadablemm_20150212_050959_ubisoftq3fy15englishfinaltcm99193930.pdf "Ubisoft® reports third quarter 2014–15 sales"] (PDF). [[:یوبی‌سافت]]. February 13, 2015. [https://web.archive.org/web/20150213212843/https://www.ubisoftgroup.com/comsite_common/en-US/images/pressrelease_downloadablemm_20150212_050959_ubisoftq3fy15englishfinaltcm99193930.pdf Archived] (PDF) from the original on February 13, 2015. Retrieved February 13, 2015.</ref><ref>Ubisoft. [https://news.ubisoft.com/en-us/article/321550/far-cry-5-breaks-franchise-sales-records "Far Cry 5 Breaks Franchise Sales Records."] [https://web.archive.org/web/20190925104407/https://news.ubisoft.com/en-us/article/321550/far-cry-5-breaks-franchise-sales-records Archived] September 25, 2019, at the [[:وی‌بک ماشین]] April 4, 2018. "Far Cry 5 now represents the second biggest launch ever for a Ubisoft game, following only Tom Clancy's The Division, with $310M USD in consumer spending through the first week." $310m / ~$60 per copy = ~5.16 million copies sold in the first week.</ref> == منبع == {{په‌نویس}} * 4 ده مایِ 1535 تبری، این ولگ [[:فار کرای]] جه ترجمه بیّه. [[رج:کامپیوتری کائون]] [[رج:ویدئوکا سری]] [[رج:یوبی‌سافت]] [[رج:دونیا ماتور]] nwtuj4o1kvldu4wnael0xuwqfnclhrj ماژول:WikidataIB 828 75585 390395 234530 2026-07-18T05:39:40Z محک 1023 محک صفحهٔ [[ماژول:WikidataB]] را بدون برجای‌گذاشتن تغییرمسیر به [[ماژول:WikidataIB]] منتقل کرد 234530 Scribunto text/plain -- Version: 2021-02-06 - معدلة محليًا -- Module to implement use of a blacklist and whitelist for infobox fields -- Can take a named parameter |qid which is the Wikidata ID for the article -- if not supplied, it will use the Wikidata ID associated with the current page. -- Fields in blacklist are never to be displayed, i.e. module must return nil in all circumstances -- Fields in whitelist return local value if it exists or the Wikidata value otherwise -- The name of the field that this function is called from is passed in named parameter |name -- The name is compulsory when blacklist or whitelist is used, -- so the module returns nil if it is not supplied. -- blacklist is passed in named parameter |suppressfields (or |spf) -- whitelist is passed in named parameter |fetchwikidata (or |fwd) local p = {} local cdate -- initialise as nil and only load _complex_date function if needed -- Module:Complex date is loaded lazily and has the following dependencies: -- Module:Calendar -- Module:ISOdate -- Module:DateI18n -- Module:I18n/complex date -- Module:Ordinal -- Module:I18n/ordinal -- Module:Yesno -- Module:Formatnum -- Module:Linguistic -- -- The following, taken from https://www.mediawiki.org/wiki/Wikibase/DataModel#Dates_and_times, -- is needed to use Module:Complex date which seemingly requires date precision as a string. -- It would work better if only the authors of the mediawiki page could spell 'millennium'. local dp = { [6] = "millennium", [7] = "century", [8] = "decade", [9] = "year", [10] = "month", [11] = "day", } local i18n = { ["errors"] = { ["property-not-found"] = "Property not found.", ["No property supplied"] = "No property supplied", ["entity-not-found"] = "Wikidata entity not found.", ["unknown-claim-type"] = "Unknown claim type.", ["unknown-entity-type"] = "Unknown entity type.", ["qualifier-not-found"] = "Qualifier not found.", ["site-not-found"] = "Wikimedia project not found.", ["labels-not-found"] = "No labels found.", ["descriptions-not-found"] = "No descriptions found.", ["aliases-not-found"] = "No aliases found.", ["unknown-datetime-format"] = "Unknown datetime format.", ["local-article-not-found"] = "Article is available on Wikidata, but not on Wikipedia", ["dab-page"] = " (dab)", }, ["months"] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }, ["century"] = "century", ["BC"] = "BC", ["BCE"] = "BCE", ["ordinal"] = { [1] = "st", [2] = "nd", [3] = "rd", ["default"] = "th" }, ["filespace"] = "File", ["Unknown"] = "Unknown", ["NaN"] = "Not a number", -- set the following to the name of a tracking category, -- e.g. "[[Category:Articles with missing Wikidata information]]", or "" to disable: ["missinginfocat"] = "[[Category:Articles with missing Wikidata information]]", ["editonwikidata"] = "Edit this on Wikidata", ["latestdatequalifier"] = function (date) return "before " .. date end, -- some languages, e.g. Bosnian use a period as a suffix after each number in a date ["datenumbersuffix"] = "", ["list separator"] = ", ", ["list separator-ar"] = "، ", ["multipliers"] = { [0] = "", [3] = " thousand", [6] = " million", [9] = " billion", [12] = " trillion", } } -- This allows an internationisation module to override the above table if 'en' ~= mw.getContentLanguage():getCode() then require("Module:i18n").loadI18n("Module:WikidataIB/i18n", i18n) end -- This piece of html implements a collapsible container. Check the classes exist on your wiki. local collapsediv = '<div class="mw-collapsible mw-collapsed" style="width:100%; overflow:auto;" data-expandtext="{{int:show}}" data-collapsetext="{{int:hide}}">' -- Some items should not be linked. -- Each wiki can create a list of those in Module:WikidataIB/nolinks -- It should return a table called itemsindex, containing true for each item not to be linked local donotlink = {} local nolinks_exists, nolinks = pcall(mw.loadData, "Module:WikidataIB/nolinks") if nolinks_exists then donotlink = nolinks.itemsindex end -- To satisfy Wikipedia:Manual of Style/Titles, certain types of items are italicised, and others are quoted. -- The submodule [[Module:WikidataIB/titleformats]] lists the entity-ids used in 'instance of' (P31), -- which allows this module to identify the values that should be formatted. -- WikidataIB/titleformats exports a table p.formats, which is indexed by entity-id, and contains the value " or '' local formats = {} local titleformats_exists, titleformats = pcall(mw.loadData, "Module:WikidataIB/titleformats") if titleformats_exists then formats = titleformats.formats end ------------------------------------------------------------------------------- -- Private functions ------------------------------------------------------------------------------- -- ------------------------------------------------------------------------------- -- makeOrdinal needs to be internationalised along with the above: -- takes cardinal number as a numeric and returns the ordinal as a string -- we need three exceptions in English for 1st, 2nd, 3rd, 21st, .. 31st, etc. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local makeOrdinal = function(cardinal) local ordsuffix = i18n.ordinal.default if cardinal % 10 == 1 then ordsuffix = i18n.ordinal[1] elseif cardinal % 10 == 2 then ordsuffix = i18n.ordinal[2] elseif cardinal % 10 == 3 then ordsuffix = i18n.ordinal[3] end -- In English, 1, 21, 31, etc. use 'st', but 11, 111, etc. use 'th' -- similarly for 12 and 13, etc. if (cardinal % 100 == 11) or (cardinal % 100 == 12) or (cardinal % 100 == 13) then ordsuffix = i18n.ordinal.default end return tostring(cardinal) .. ordsuffix end ------------------------------------------------------------------------------- -- findLang takes a "langcode" parameter if supplied and valid -- otherwise it tries to create it from the user's set language ({{int:lang}}) -- failing that it uses the wiki's content language. -- It returns a language object ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local findLang = function(langcode) local langobj langcode = mw.text.trim(langcode or "") if mw.language.isKnownLanguageTag(langcode) then langobj = mw.language.new( langcode ) else langcode = mw.getCurrentFrame():preprocess( '{{int:lang}}' ) if mw.language.isKnownLanguageTag(langcode) then langobj = mw.language.new( langcode ) else langobj = mw.language.getContentLanguage() end end return langobj end ------------------------------------------------------------------------------- -- _getItemLangCode takes a qid parameter (using the current page's qid if blank) -- If the item for that qid has property country (P17) it looks at the first preferred value -- If the country has an official language (P37), it looks at the first preferred value -- If that official language has a language code (P424), it returns the first preferred value -- Otherwise it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local _getItemLangCode = function(qid) qid = mw.text.trim(qid or ""):upper() if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return end local prop17 = mw.wikibase.getBestStatements(qid, "P17")[1] if not prop17 or prop17.mainsnak.snaktype ~= "value" then return end local qid17 = prop17.mainsnak.datavalue.value.id local prop37 = mw.wikibase.getBestStatements(qid17, "P37")[1] if not prop37 or prop37.mainsnak.snaktype ~= "value" then return end local qid37 = prop37.mainsnak.datavalue.value.id local prop424 = mw.wikibase.getBestStatements(qid37, "P424")[1] if not prop424 or prop424.mainsnak.snaktype ~= "value" then return end return prop424.mainsnak.datavalue.value end ------------------------------------------------------------------------------- -- roundto takes a number (x) -- and returns it rounded to (sf) significant figures ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local roundto = function(x, sf) if x == 0 then return 0 end local s = 1 if x < 0 then x = -x s = -1 end if sf < 1 then sf = 1 end local p = 10 ^ (math.floor(math.log10(x)) - sf + 1) x = math.floor(x / p + 0.5) * p * s -- if it's integral, cast to an integer: if x == math.floor(x) then x = math.floor(x) end return x end ------------------------------------------------------------------------------- -- decimalToDMS takes a decimal degrees (x) with precision (p) -- and returns degrees/minutes/seconds according to the precision ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local decimalToDMS = function(x, p) -- if p is not supplied, use a precision around 0.1 seconds if not tonumber(p) then p = 1e-4 end local d = math.floor(x) local ms = (x - d) * 60 if p > 0.5 then -- precision is > 1/2 a degree if ms > 30 then d = d + 1 end ms = 0 end local m = math.floor(ms) local s = (ms - m) * 60 if p > 0.008 then -- precision is > 1/2 a minute if s > 30 then m = m +1 end s = 0 elseif p > 0.00014 then -- precision is > 1/2 a second s = math.floor(s + 0.5) elseif p > 0.000014 then -- precision is > 1/20 second s = math.floor(10 * s + 0.5) / 10 elseif p > 0.0000014 then -- precision is > 1/200 second s = math.floor(100 * s + 0.5) / 100 else -- cap it at 3 dec places for now s = math.floor(1000 * s + 0.5) / 1000 end return d, m, s end ------------------------------------------------------------------------------- -- decimalPrecision takes a decimal (x) with precision (p) -- and returns x rounded approximately to the given precision -- precision should be between 1 and 1e-6, preferably a power of 10. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local decimalPrecision = function(x, p) local s = 1 if x < 0 then x = -x s = -1 end -- if p is not supplied, pick an arbitrary precision if not tonumber(p) then p = 1e-4 elseif p > 1 then p = 1 elseif p < 1e-6 then p = 1e-6 else p = 10 ^ math.floor(math.log10(p)) end x = math.floor(x / p + 0.5) * p * s -- if it's integral, cast to an integer: if x == math.floor(x) then x = math.floor(x) end -- if it's less than 1e-4, it will be in exponent form, so return a string with 6dp -- 9e-5 becomes 0.000090 if math.abs(x) < 1e-4 then x = string.format("%f", x) end return x end ------------------------------------------------------------------------------- -- formatDate takes a datetime of the usual format from mw.wikibase.entity:formatPropertyValues -- like "1 August 30 BCE" as parameter 1 -- and formats it according to the df (date format) and bc parameters -- df = ["dmy" / "mdy" / "y"] default will be "dmy" -- bc = ["BC" / "BCE"] default will be "BCE" ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local format_Date = function(datetime, dateformat, bc) local datetime = datetime or "1 August 30 BCE" -- in case of nil value -- chop off multiple vales and/or any hours, mins, etc. -- keep anything before punctuation - we just want a single date: local dateval = string.match( datetime, "[%w ]+") local dateformat = string.lower(dateformat or "dmy") -- default to dmy local bc = string.upper(bc or "") -- can't use nil for bc -- we only want to accept two possibilities: BC or default to BCE if bc == "BC" then bc = "&nbsp;" .. i18n["BC"] -- prepend a non-breaking space. else bc = "&nbsp;" .. i18n["BCE"] end local postchrist = true -- start by assuming no BCE local dateparts = {} for word in string.gmatch(dateval, "%w+") do if word == "BCE" or word == "BC" then -- *** internationalise later *** postchrist = false else -- we'll keep the parts that are not 'BCE' in a table dateparts[#dateparts + 1] = word end end if postchrist then bc = "" end -- set AD dates to no suffix *** internationalise later *** local sep = "&nbsp;" -- separator is nbsp local fdate = table.concat(dateparts, sep) -- set formatted date to same order as input -- if we have day month year, check dateformat if #dateparts == 3 then if dateformat == "y" then fdate = dateparts[3] elseif dateformat == "mdy" then fdate = dateparts[2] .. sep .. dateparts[1] .. "," .. sep .. dateparts[3] end elseif #dateparts == 2 and dateformat == "y" then fdate = dateparts[2] end return fdate .. bc end ------------------------------------------------------------------------------- -- dateFormat is the handler for properties that are of type "time" -- It takes timestamp, precision (6 to 11 per mediawiki), dateformat (y/dmy/mdy), BC format (BC/BCE), -- a plaindate switch (yes/no/adj) to en/disable "sourcing circumstances"/use adjectival form, -- any qualifiers for the property, the language, and any adjective to use like 'before'. -- It passes the date through the "complex date" function -- and returns a string with the internatonalised date formatted according to preferences. ------------------------------------------------------------------------------- -- Dependencies: findLang(); cdate(); dp[] ------------------------------------------------------------------------------- local dateFormat = function(timestamp, dprec, df, bcf, pd, qualifiers, lang, adj, model) -- output formatting according to preferences (y/dmy/mdy/ymd) df = (df or ""):lower() -- if ymd is required, return the part of the timestamp in YYYY-MM-DD form -- but apply Year zero#Astronomers fix: 1 BC = 0000; 2 BC = -0001; etc. if df == "ymd" then if timestamp:sub(1,1) == "+" then return timestamp:sub(2,11) else local yr = tonumber(timestamp:sub(2,5)) - 1 yr = ("000" .. yr):sub(-4) if yr ~= "0000" then yr = "-" .. yr end return yr .. timestamp:sub(6,11) end end -- A year can be stored like this: "+1872-00-00T00:00:00Z", -- which is processed here as if it were the day before "+1872-01-01T00:00:00Z", -- and that's the last day of 1871, so the year is wrong. -- So fix the month 0, day 0 timestamp to become 1 January instead: timestamp = timestamp:gsub("%-00%-00T", "-01-01T") -- just in case date precision is missing dprec = dprec or 11 -- override more precise dates if required dateformat is year alone: if df == "y" and dprec > 9 then dprec = 9 end -- complex date only deals with precisions from 6 to 11, so clip range dprec = dprec>11 and 11 or dprec dprec = dprec<6 and 6 or dprec -- BC format is "BC" or "BCE" bcf = (bcf or ""):upper() -- plaindate only needs the first letter (y/n/a) pd = (pd or ""):sub(1,1):lower() if pd == "" or pd == "n" or pd == "f" or pd == "0" then pd = false end -- in case language isn't passed lang = lang or findLang().code -- set adj as empty if nil adj = adj or "" -- extract the day, month, year from the timestamp local bc = timestamp:sub(1, 1)=="-" and "BC" or "" local year, month, day = timestamp:match("[+-](%d*)-(%d*)-(%d*)T") local iso = tonumber(year) -- if year is missing, let it throw an error -- this will adjust the date format to be compatible with cdate -- possible formats are Y, YY, YYY0, YYYY, YYYY-MM, YYYY-MM-DD if dprec == 6 then iso = math.floor( (iso - 1) / 1000 ) + 1 end if dprec == 7 then iso = math.floor( (iso - 1) / 100 ) + 1 end if dprec == 8 then iso = math.floor( iso / 10 ) .. "0" end if dprec == 10 then iso = year .. "-" .. month end if dprec == 11 then iso = year .. "-" .. month .. "-" .. day end -- add "circa" (Q5727902) from "sourcing circumstances" (P1480) local sc = not pd and qualifiers and qualifiers.P1480 if sc then for k1, v1 in pairs(sc) do if v1.datavalue and v1.datavalue.value.id == "Q5727902" then adj = "circa" break end end end -- deal with Julian dates: -- no point in saying that dates before 1582 are Julian - they are by default -- doesn't make sense for dates less precise than year -- we can suppress it by setting |plaindate, e.g. for use in constructing categories. local calendarmodel = "" if tonumber(year) > 1582 and dprec > 8 and not pd and model == "http://www.wikidata.org/entity/Q1985786" then calendarmodel = "julian" end if not cdate then cdate = require("Module:Complex date")._complex_date end local fdate = cdate(calendarmodel, adj, tostring(iso), dp[dprec], bc, "", "", "", "", lang, 1) -- this may have QuickStatements info appended to it in a div, so remove that fdate = fdate:gsub(' <div style="display: none;">[^<]*</div>', '') -- it may also be returned wrapped in a microformat, so remove that fdate = fdate:gsub("<[^>]*>", "") -- there may be leading zeros that we should remove fdate = fdate:gsub("^0*", "") -- if a plain date is required, then remove any links (like BC linked) if pd then fdate = fdate:gsub("%[%[.*|", ""):gsub("]]", "") end -- if 'circa', use the abbreviated form *** internationalise later *** fdate = fdate:gsub('circa ', '<abbr title="circa">c.</abbr>&nbsp;') -- deal with BC/BCE if bcf == "BCE" then fdate = fdate:gsub('BC', 'BCE') end -- deal with mdy format if df == "mdy" then fdate = fdate:gsub("(%d+) (%w+) (%d+)", "%2 %1, %3") end -- deal with adjectival form *** internationalise later *** if pd == "a" then fdate = fdate:gsub(' century', '-century') end return fdate end ------------------------------------------------------------------------------- -- parseParam takes a (string) parameter, e.g. from the list of frame arguments, -- and makes "false", "no", and "0" into the (boolean) false -- it makes the empty string and nil into the (boolean) value passed as default -- allowing the parameter to be true or false by default. -- It returns a boolean. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local parseParam = function(param, default) if type(param) == "boolean" then param = tostring(param) end if param and param ~= "" then param = param:lower() if (param == "false") or (param:sub(1,1) == "n") or (param == "0") then return false else return true end else return default end end ------------------------------------------------------------------------------- -- _getSitelink takes the qid of a Wikidata entity passed as |qid= -- It takes an optional parameter |wiki= to determine which wiki is to be checked for a sitelink -- If the parameter is blank, then it uses the local wiki. -- If there is a sitelink to an article available, it returns the plain text link to the article -- If there is no sitelink, it returns nil. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local _getSitelink = function(qid, wiki) qid = (qid or ""):upper() if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end wiki = wiki or "" local sitelink if wiki == "" then sitelink = mw.wikibase.getSitelink(qid) else sitelink = mw.wikibase.getSitelink(qid, wiki) end return sitelink end ------------------------------------------------------------------------------- -- _getCommonslink takes an optional qid of a Wikidata entity passed as |qid= -- It returns one of the following in order of preference: -- the Commons sitelink of the Wikidata entity - but not if onlycat=true and it's not a category; -- the Commons sitelink of the topic's main category of the Wikidata entity; -- the Commons category of the Wikidata entity - unless fallback=false. ------------------------------------------------------------------------------- -- Dependencies: _getSitelink(); parseParam() ------------------------------------------------------------------------------- local _getCommonslink = function(qid, onlycat, fallback) qid = (qid or ""):upper() if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end onlycat = parseParam(onlycat, false) if fallback == "" then fallback = nil end local sitelink = _getSitelink(qid, "commonswiki") if onlycat and sitelink and sitelink:sub(1,9) ~= "Category:" then sitelink = nil end if not sitelink then -- check for topic's main category local prop910 = mw.wikibase.getBestStatements(qid, "P910")[1] if prop910 then local tmcid = prop910.mainsnak.datavalue and prop910.mainsnak.datavalue.value.id sitelink = _getSitelink(tmcid, "commonswiki") end if not sitelink then -- check for list's main category local prop1754 = mw.wikibase.getBestStatements(qid, "P1754")[1] if prop1754 then local tmcid = prop1754.mainsnak.datavalue and prop1754.mainsnak.datavalue.value.id sitelink = _getSitelink(tmcid, "commonswiki") end end end if not sitelink and fallback then -- check for Commons category (string value) local prop373 = mw.wikibase.getBestStatements(qid, "P373")[1] if prop373 then sitelink = prop373.mainsnak.datavalue and prop373.mainsnak.datavalue.value if sitelink then sitelink = "Category:" .. sitelink end end end return sitelink end ------------------------------------------------------------------------------- -- The label in a Wikidata item is subject to vulnerabilities -- that an attacker might try to exploit. -- It needs to be 'sanitised' by removing any wikitext before use. -- If it doesn't exist, return the id for the item -- a second (boolean) value is also returned, value is true when the label exists ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local labelOrId = function(id, lang) if lang == "default" then lang = findLang().code end local label if lang then label = mw.wikibase.getLabelByLang(id, lang) else label = mw.wikibase.getLabel(id) end if label then return mw.text.nowiki(label), true else return id, false end end ------------------------------------------------------------------------------- -- linkedItem takes an entity-id and returns a string, linked if possible. -- This is the handler for "wikibase-item". Preferences: -- 1. Display linked disambiguated sitelink if it exists -- 2. Display linked label if it is a redirect -- 3. TBA: Display an inter-language link for the label if it exists other than in default language -- 4. Display unlinked label if it exists -- 5. Display entity-id for now to indicate a label could be provided -- dtxt is text to be used instead of label, or nil. -- shortname is boolean switch to use P1813 (short name) instead of label if true. -- lang is the current language code. -- uselbl is boolean switch to force display of the label instead of the sitelink (default: false) -- linkredir is boolean switch to allow linking to a redirect (default: false) -- formatvalue is boolean switch to allow formatting as italics or quoted (default: false) ------------------------------------------------------------------------------- -- Dependencies: labelOrId(); donotlink[] ------------------------------------------------------------------------------- local linkedItem = function(id, args) local lprefix = (args.lp or args.lprefix or args.linkprefix or ""):gsub('"', '') -- toughen against nil values passed local lpostfix = (args.lpostfix or ""):gsub('"', '') local prefix = (args.prefix or ""):gsub('"', '') local postfix = (args.postfix or ""):gsub('"', '') local dtxt = args.dtxt local shortname = args.shortname local lang = args.lang or "ar" -- fallback to default if missing local uselbl = args.uselabel or args.uselbl uselbl = parseParam(uselbl, true) local linkredir = args.linkredir linkredir = parseParam(linkredir, false) local formatvalue = args.formatvalue or args.fv formatvalue = parseParam(formatvalue, false) -- see if item might need italics or quotes local fmt = "" if next(formats) and formatvalue then for k, v in ipairs( mw.wikibase.getBestStatements(id, "P31") ) do if v.mainsnak.datavalue and formats[v.mainsnak.datavalue.value.id] then fmt = formats[v.mainsnak.datavalue.value.id] break -- pick the first match end end end local disp local sitelink = mw.wikibase.getSitelink(id) local label, islabel if dtxt then label, islabel = dtxt, true elseif shortname then -- see if there is a shortname in our language, and set label to it for k, v in ipairs( mw.wikibase.getBestStatements(id, "P1813") ) do if v.mainsnak.datavalue.value.language == lang then label, islabel = v.mainsnak.datavalue.value.text, true break end -- test for language match end -- loop through values of short name -- if we have no label set, then there was no shortname available if not islabel then label, islabel = labelOrId(id, args.lang) shortname = false end else label, islabel = labelOrId(id, args.lang) end if mw.site.siteName ~= "Wikimedia Commons" then if sitelink then if not (dtxt or shortname) then -- if sitelink and label are the same except for case, no need to process further if sitelink:lower() ~= label:lower() then -- strip any namespace or dab from the sitelink local pos = sitelink:find(":") or 0 local slink = sitelink if pos > 0 then local pfx = sitelink:sub(1,pos-1) if mw.site.namespaces[pfx] then -- that prefix is a valid namespace, so remove it slink = sitelink:sub(pos+1) end end -- remove stuff after commas or inside parentheses - ie. dabs slink = slink:gsub("%s%(.+%)$", ""):gsub(",.+$", "") -- if uselbl is false, use sitelink instead of label if not uselbl then -- use slink as display, preserving label case - find("^%u") is true for 1st char uppercase if label:find("^%u") then label = slink:gsub("^(%l)", string.upper) else label = slink:gsub("^(%u)", string.lower) end end end end if donotlink[label] then disp = prefix .. fmt .. label .. fmt .. postfix else disp = "[[" .. lprefix .. sitelink .. lpostfix .. "|" .. prefix .. fmt .. label .. fmt .. postfix .. "]]" end elseif islabel then -- no sitelink, label exists, so check if a redirect with that title exists, if linkredir is true -- display plain label by default disp = prefix .. fmt .. label .. fmt .. postfix if linkredir then local artitle = mw.title.new(label, 0) -- only nil if label has invalid chars if not donotlink[label] and artitle and artitle.redirectTarget then -- there's a redirect with the same title as the label, so let's link to that disp = "[[".. lprefix .. label .. lpostfix .. "|" .. prefix .. fmt .. label .. fmt .. postfix .. "]]" end end -- test if article title exists as redirect on current Wiki else -- no sitelink and no label, so return whatever was returned from labelOrId for now -- add tracking category [[Category:Articles with missing Wikidata information]] -- for enwiki, just return the tracking category if mw.wikibase.getGlobalSiteId() == "enwiki" then disp = i18n.missinginfocat else disp = prefix .. label .. postfix .. i18n.missinginfocat end end else local ccat = mw.wikibase.getBestStatements(id, "P373")[1] if ccat and ccat.mainsnak.datavalue then ccat = ccat.mainsnak.datavalue.value disp = "[[" .. lprefix .. "Category:" .. ccat .. lpostfix .. "|" .. prefix .. label .. postfix .. "]]" elseif sitelink then -- this asumes that if a sitelink exists, then a label also exists disp = "[[" .. lprefix .. sitelink .. lpostfix .. "|" .. prefix .. label .. postfix .. "]]" else -- no sitelink and no Commons cat, so return label from labelOrId for now disp = prefix .. label .. postfix end end return disp end ------------------------------------------------------------------------------- -- sourced takes a table representing a statement that may or may not have references -- it looks for a reference sourced to something not containing the word "wikipedia" -- it returns a boolean = true if it finds a sourced reference. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local sourced = function(claim) if claim.references then for kr, vr in pairs(claim.references) do local ref = mw.wikibase.renderSnaks(vr.snaks) if not ref:find("Wiki") then return true end end end end ------------------------------------------------------------------------------- -- setRanks takes a flag (parameter passed) that requests the values to return -- "b[est]" returns preferred if available, otherwise normal -- "p[referred]" returns preferred -- "n[ormal]" returns normal -- "d[eprecated]" returns deprecated -- multiple values are allowed, e.g. "preferred normal" (which is the default) -- "best" will override the other flags, and set p and n ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local setRanks = function(rank) rank = (rank or ""):lower() -- if nothing passed, return preferred and normal -- if rank == "" then rank = "p n" end local ranks = {} for w in string.gmatch(rank, "%a+") do w = w:sub(1,1) if w == "b" or w == "p" or w == "n" or w == "d" then ranks[w] = true end end -- check if "best" is requested or no ranks requested; and if so, set preferred and normal if ranks.b or not next(ranks) then ranks.p = true ranks.n = true end return ranks end ------------------------------------------------------------------------------- -- parseInput processes the Q-id , the blacklist and the whitelist -- if an input parameter is supplied, it returns that and ends the call. -- it returns (1) either the qid or nil indicating whether or not the call should continue -- and (2) a table containing all of the statements for the propertyID and relevant Qid -- if "best" ranks are requested, it returns those instead of all non-deprecated ranks ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local parseInput = function(frame, input_parm, property_id) -- There may be a local parameter supplied, if it's blank, set it to nil input_parm = mw.text.trim(input_parm or "") if input_parm == "" then input_parm = nil end -- return nil if Wikidata is not available if not mw.wikibase then return false, input_parm end local args = frame.args --#added block local refsnak = args.snak if refsnak == "" then refsnak = nil end -- can take a named parameter |qid which is the Wikidata ID for the article. -- if it's not supplied, use the id for the current page local qid = args.qid or "" --#Modified line if qid == "" and not refsnak then qid = mw.wikibase.getEntityIdForCurrentPage() end -- if there's no Wikidata item for the current page return nil --#Modified line if not qid and not refsnak then return false, input_parm end -- The blacklist is passed in named parameter |suppressfields local blacklist = args.suppressfields or args.spf or "" -- The whitelist is passed in named parameter |fetchwikidata local whitelist = args.fetchwikidata or args.fwd or "" if whitelist == "" then whitelist = "NONE" end -- The name of the field that this function is called from is passed in named parameter |name local fieldname = args.name or "" if blacklist ~= "" then -- The name is compulsory when blacklist is used, so return nil if it is not supplied if fieldname == "" then return false, nil end -- If this field is on the blacklist, then return nil if blacklist:find(fieldname) then return false, nil end end -- If we got this far then we're not on the blacklist -- The blacklist overrides any locally supplied parameter as well -- If a non-blank input parameter was supplied return it if input_parm then return false, input_parm end -- We can filter out non-valid properties if property_id:sub(1,1):upper() ~="P" or property_id == "P0" then return false, nil end -- Otherwise see if this field is on the whitelist: -- needs a bit more logic because find will return its second value = 0 if fieldname is "" -- but nil if fieldname not found on whitelist local _, found = whitelist:find(fieldname) found = ((found or 0) > 0) if whitelist ~= 'ALL' and (whitelist:upper() == "NONE" or not found) then return false, nil end -- See what's on Wikidata (the call always returns a table, but it may be empty): local props = {} if refsnak then props = refsnak[property_id] or {} end if not props[1] then if args.reqranks.b then props = mw.wikibase.getBestStatements(qid, property_id) else props = mw.wikibase.getAllStatements(qid, property_id) end end if props[1] then return qid, props end -- no property on Wikidata return false, nil end ------------------------------------------------------------------------------- -- createicon assembles the "Edit at Wikidata" pen icon. -- It returns a wikitext string inside a span class="penicon" -- if entityID is nil or empty, the ID associated with current page is used -- langcode and propertyID may be nil or empty ------------------------------------------------------------------------------- -- Dependencies: i18n[]; ------------------------------------------------------------------------------- local createicon = function(langcode, entityID, propertyID) langcode = langcode or "" if not entityID or entityID == "" then entityID= mw.wikibase.getEntityIdForCurrentPage() end propertyID = propertyID or "" local icon = "&nbsp;<span class='penicon autoconfirmed-show'>[[" -- "&nbsp;<span data-bridge-edit-flow='overwrite' class='penicon'>[[" -> enable Wikidata Bridge .. i18n["filespace"] .. ":OOjs UI icon edit-ltr-progressive.svg |frameless |text-top |10px |alt=" .. i18n["editonwikidata"] .. "|link=https://www.wikidata.org/wiki/" .. entityID if langcode ~= "" then icon = icon .. "?uselang=" .. langcode end if propertyID ~= "" then icon = icon .. "#" .. propertyID end icon = icon .. "|" .. i18n["editonwikidata"] .. "]]</span>" return icon end ------------------------------------------------------------------------------- -- assembleoutput takes the sequence table containing the property values -- and formats it according to switches given. It returns a string or nil. -- It uses the entityID (and optionally propertyID) to create a link in the pen icon. ------------------------------------------------------------------------------- -- Dependencies: parseParam(); ------------------------------------------------------------------------------- local assembleoutput = function(out, args, entityID, propertyID) -- sorted is a boolean passed to enable sorting of the values returned -- if nothing or an empty string is passed set it false -- if "false" or "no" or "0" is passed set it false local sorted = parseParam(args.sorted, false) -- noicon is a boolean passed to suppress the trailing "edit at Wikidata" icon -- for use when the value is processed further by the infobox -- if nothing or an empty string is passed set it false -- if "false" or "no" or "0" is passed set it false local noic = parseParam(args.noicon, false) -- list is the name of a template that a list of multiple values is passed through -- examples include "hlist" and "ubl" -- setting it to "prose" produces something like "1, 2, 3, and 4" local list = args.list or "" -- sep is a string that is used to separate multiple returned values -- if nothing or an empty string is passed set it to the default -- any double-quotes " are stripped out, so that spaces may be passed -- e.g. |sep=" - " local sepdefault = i18n["list separator"] local rtl_lang = {ar = true, fa = true, ur = true, ku = true, he = true, arc = true, dv = true, ha = true, khw = true, ks = true, ps = true, yi = true } if rtl_lang[args.lang] then sepdefault = i18n["list separator-ar"] end local separator = args.sep or "" separator = string.gsub(separator, '"', '') if separator == "" then separator = sepdefault end -- collapse is a number that determines the maximum number of returned values -- before the output is collapsed. -- Zero or not a number result in no collapsing (default becomes 0). local collapse = tonumber(args.collapse) or 0 -- replacetext (rt) is a string that is returned instead of any non-empty Wikidata value -- this is useful for tracking and debugging local replacetext = mw.text.trim(args.rt or args.replacetext or "") -- if there's anything to return, then return a list -- comma-separated by default, but may be specified by the sep parameter -- optionally specify a hlist or ubl or a prose list, etc. local strout if #out > 0 then if sorted then table.sort(out) end -- if there's something to display and a pen icon is wanted, add it the end of the last value local hasdisplay = false for i, v in ipairs(out) do if v ~= i18n.missinginfocat then hasdisplay = true break end end if not noic and hasdisplay then out[#out] = out[#out] .. createicon(args.langobj.code, entityID, propertyID) end if list == "" then strout = table.concat(out, separator) elseif list:lower() == "prose" then strout = mw.text.listToText( out ) else strout = mw.getCurrentFrame():expandTemplate{title = list, args = out} end if collapse >0 and #out > collapse then strout = collapsediv .. strout .. "</div>" end else strout = nil -- no items had valid reference end if replacetext ~= "" and strout then strout = replacetext end return strout end ------------------------------------------------------------------------------- -- rendersnak takes a table (propval) containing the information stored on one property value -- and returns the value as a string and its language if monolingual text. -- It handles data of type: -- wikibase-item -- time -- string, url, commonsMedia, external-id -- quantity -- globe-coordinate -- monolingualtext -- It also requires linked, the link/pre/postfixes, uabbr, and the arguments passed from frame. -- The optional filter parameter allows quantities to be be filtered by unit Qid. ------------------------------------------------------------------------------- -- Dependencies: parseParam(); labelOrId(); i18n[]; dateFormat(); -- roundto(); decimalPrecision(); decimalToDMS(); linkedItem(); ------------------------------------------------------------------------------- local rendersnak = function(propval, args, linked, lpre, lpost, pre, post, uabbr, filter) lpre = lpre or "" lpost = lpost or "" pre = pre or "" post = post or "" args.lang = args.lang or findLang().code -- allow values to display a fixed text instead of label local dtxt = args.displaytext or args.dt if dtxt == "" then dtxt = nil end -- switch to use display of short name (P1813) instead of label local shortname = args.shortname or args.sn shortname = parseParam(shortname, false) local snak = propval.mainsnak or propval local dtype = snak.datatype local dv = snak.datavalue dv = dv and dv.value -- value and monolingual text language code returned local val, mlt if propval.rank and not args.reqranks[propval.rank:sub(1, 1)] then -- val is nil: value has a rank that isn't requested ------------------------------------ elseif snak.snaktype == "somevalue" then -- value is unknown val = i18n["Unknown"] ------------------------------------ elseif snak.snaktype == "novalue" then -- value is none -- val = "No value" -- don't return anything ------------------------------------ elseif dtype == "wikibase-item" then -- data type is a wikibase item: -- it's wiki-linked value, so output as link if enabled and possible local qnumber = dv.id if linked then val = linkedItem(qnumber, args) else -- no link wanted so check for display-text, otherwise test for lang code local label, islabel if dtxt then label = dtxt else label, islabel = labelOrId(qnumber) local langlabel = mw.wikibase.getLabelByLang(qnumber, args.lang) if langlabel then label = mw.text.nowiki( langlabel ) end end val = pre .. label .. post end -- test for link required ------------------------------------ elseif dtype == "time" then -- data type is time: -- time is in timestamp format -- date precision is integer per mediawiki -- output formatting according to preferences (y/dmy/mdy) -- BC format as BC or BCE -- plaindate is passed to disable looking for "sourcing cirumstances" -- or to set the adjectival form -- qualifiers (if any) is a nested table or nil -- lang is given, or user language, or site language -- -- Here we can check whether args.df has a value -- If not, use code from Module:Sandbox/RexxS/Getdateformat to set it from templates like {{Use mdy dates}} val = dateFormat(dv.time, dv.precision, args.df, args.bc, args.pd, propval.qualifiers, args.lang, "", dv.calendarmodel) ------------------------------------ -- data types which are strings: elseif dtype == "commonsMedia" or dtype == "external-id" or dtype == "string" or dtype == "url" then -- commonsMedia or external-id or string or url -- all have mainsnak.datavalue.value as string if (lpre == "" or lpre == ":") and lpost == "" then -- don't link if no linkpre/postfix or linkprefix is just ":" val = pre .. dv .. post elseif dtype == "external-id" then val = "[" .. lpre .. dv .. lpost .. " " .. pre .. dv .. post .. "]" else val = "[[" .. lpre .. dv .. lpost .. "|" .. pre .. dv .. post .. "]]" end -- check for link requested (i.e. either linkprefix or linkpostfix exists) ------------------------------------ -- data types which are quantities: elseif dtype == "quantity" then -- quantities have mainsnak.datavalue.value.amount and mainsnak.datavalue.value.unit -- the unit is of the form http://www.wikidata.org/entity/Q829073 -- -- implement a switch to turn on/off numerical formatting later local fnum = true -- -- a switch to turn on/off conversions - only for en-wiki local conv = parseParam(args.conv or args.convert, false) -- if we have conversions, we won't have formatted numbers or scales if conv then uabbr = true fnum = false args.scale = "0" end -- -- a switch to turn on/off showing units, default is true local showunits = parseParam(args.su or args.showunits, true) -- -- convert amount to a number local amount = tonumber(dv.amount) or i18n["NaN"] -- -- scale factor for millions, billions, etc. local sc = tostring(args.scale or ""):sub(1,1):lower() local scale if sc == "a" then -- automatic scaling if amount > 1e15 then scale = 12 elseif amount > 1e12 then scale = 9 elseif amount > 1e9 then scale = 6 elseif amount > 1e6 then scale = 3 else scale = 0 end else scale = tonumber(args.scale) or 0 if scale < 0 or scale > 12 then scale = 0 end scale = math.floor(scale/3) * 3 end local factor = 10^scale amount = amount / factor -- ranges: local range = "" -- check if upper and/or lower bounds are given and significant local upb = tonumber(dv.upperBound) local lowb = tonumber(dv.lowerBound) if upb and lowb then -- differences rounded to 2 sig fig: local posdif = roundto(upb - amount, 2) / factor local negdif = roundto(amount - lowb, 2) / factor upb, lowb = amount + posdif, amount - negdif -- round scaled numbers to integers or 4 sig fig if (scale > 0 or sc == "a") then if amount < 1e4 then amount = roundto(amount, 4) else amount = math.floor(amount + 0.5) end end if fnum then amount = args.langobj:formatNum( amount ) end if posdif ~= negdif then -- non-symmetrical range = " +" .. posdif .. " -" .. negdif elseif posdif ~= 0 then -- symmetrical and non-zero range = " ±" .. posdif else -- otherwise range is zero, so leave it as "" end else -- round scaled numbers to integers or 4 sig fig if (scale > 0 or sc == "a") then if amount < 1e4 then amount = roundto(amount, 4) else amount = math.floor(amount + 0.5) end end if fnum then amount = args.langobj:formatNum( amount ) end end -- unit names and symbols: -- extract the qid in the form 'Qnnn' from the value.unit url -- and then fetch the label from that - or symbol if unitabbr is true local unit = "" local usep = "" local usym = "" local unitqid = string.match( dv.unit, "(Q%d+)" ) if filter and unitqid ~= filter then return nil end if unitqid and showunits then local uname = mw.wikibase.getLabelByLang(unitqid, args.lang) or "" if uname ~= "" then usep, unit = " ", uname end if uabbr then -- see if there's a unit symbol (P5061) local unitsymbols = mw.wikibase.getBestStatements(unitqid, "P5061") -- construct fallback table, add local lang and multiple languages local fbtbl = mw.language.getFallbacksFor( args.lang ) table.insert( fbtbl, 1, args.lang ) table.insert( fbtbl, 1, "mul" ) local found = false for idx1, us in ipairs(unitsymbols) do for idx2, fblang in ipairs(fbtbl) do if us.mainsnak.datavalue.value.language == fblang then usym = us.mainsnak.datavalue.value.text found = true break end if found then break end end -- loop through fallback table end -- loop through values of P5061 if found then usep, unit = "&nbsp;", usym end end end -- format display: if conv then if range == "" then val = mw.getCurrentFrame():expandTemplate{title = "cvt", args = {amount, unit}} else val = mw.getCurrentFrame():expandTemplate{title = "cvt", args = {lowb, "to", upb, unit}} end elseif unit == "$" or unit == "£" then val = unit .. amount .. range .. i18n.multipliers[scale] else val = amount .. range .. i18n.multipliers[scale] .. usep .. unit end ------------------------------------ -- datatypes which are global coordinates: elseif dtype == "globe-coordinate" then -- 'display' parameter defaults to "inline, title" *** unused for now *** -- local disp = args.display or "" -- if disp == "" then disp = "inline, title" end -- -- format parameter switches from deg/min/sec to decimal degrees -- default is deg/min/sec -- decimal degrees needs |format = dec local form = (args.format or ""):lower():sub(1,3) if form ~= "dec" then form = "dms" end -- not needed for now -- -- show parameter allows just the latitude, or just the longitude, or both -- to be returned as a signed decimal, ignoring the format parameter. local show = (args.show or ""):lower() if show ~= "longlat" then show = show:sub(1,3) end -- local lat, long, prec = dv.latitude, dv.longitude, dv.precision if show == "lat" then val = decimalPrecision(lat, prec) elseif show == "lon" then val = decimalPrecision(long, prec) elseif show == "longlat" then val = decimalPrecision(long, prec) .. ", " .. decimalPrecision(lat, prec) else local ns = "N" local ew = "E" if lat < 0 then ns = "S" lat = - lat end if long < 0 then ew = "W" long = - long end if form == "dec" then lat = decimalPrecision(lat, prec) long = decimalPrecision(long, prec) val = lat .. "°" .. ns .. " " .. long .. "°" .. ew else local latdeg, latmin, latsec = decimalToDMS(lat, prec) local longdeg, longmin, longsec = decimalToDMS(long, prec) if latsec == 0 and longsec == 0 then if latmin == 0 and longmin == 0 then val = latdeg .. "°" .. ns .. " " .. longdeg .. "°" .. ew else val = latdeg .. "°" .. latmin .. "′" .. ns .. " " val = val .. longdeg .. "°".. longmin .. "′" .. ew end else val = latdeg .. "°" .. latmin .. "′" .. latsec .. "″" .. ns .. " " val = val .. longdeg .. "°" .. longmin .. "′" .. longsec .. "″" .. ew end end end ------------------------------------ elseif dtype == "monolingualtext" then -- data type is Monolingual text: -- has mainsnak.datavalue.value as a table containing language/text pairs -- collect all the values in 'out' and languages in 'mlt' and process them later val = pre .. dv.text .. post mlt = dv.language ------------------------------------ else -- some other data type so write a specific handler val = "unknown data type: " .. dtype end -- of datatype/unknown value/sourced check return val, mlt end ------------------------------------------------------------------------------- -- propertyvalueandquals takes a property object, the arguments passed from frame, -- and a qualifier propertyID. -- It returns a sequence (table) of values representing the values of that property -- and qualifiers that match the qualifierID if supplied. ------------------------------------------------------------------------------- -- Dependencies: parseParam(); sourced(); labelOrId(); i18n.latestdatequalifier(); format_Date(); -- makeOrdinal(); roundto(); decimalPrecision(); decimalToDMS(); assembleoutput(); ------------------------------------------------------------------------------- local function propertyvalueandquals(objproperty, args, qualID) -- needs this style of declaration because it's re-entrant -- onlysourced is a boolean passed to return only values sourced to other than Wikipedia -- if nothing or an empty string is passed set it true local onlysrc = parseParam(args.onlysourced or args.osd, true) -- linked is a a boolean that enables the link to a local page via sitelink -- if nothing or an empty string is passed set it true local linked = parseParam(args.linked, true) -- prefix is a string that may be nil, empty (""), or a string of characters -- this is prefixed to each value -- useful when when multiple values are returned -- any double-quotes " are stripped out, so that spaces may be passed local prefix = (args.prefix or ""):gsub('"', '') -- postfix is a string that may be nil, empty (""), or a string of characters -- this is postfixed to each value -- useful when when multiple values are returned -- any double-quotes " are stripped out, so that spaces may be passed local postfix = (args.postfix or ""):gsub('"', '') -- linkprefix is a string that may be nil, empty (""), or a string of characters -- this creates a link and is then prefixed to each value -- useful when when multiple values are returned and indirect links are needed -- any double-quotes " are stripped out, so that spaces may be passed local lprefix = (args.linkprefix or args.lp or ""):gsub('"', '') -- linkpostfix is a string that may be nil, empty (""), or a string of characters -- this is postfixed to each value when linking is enabled with lprefix -- useful when when multiple values are returned -- any double-quotes " are stripped out, so that spaces may be passed local lpostfix = (args.linkpostfix or ""):gsub('"', '') -- wdlinks is a boolean passed to enable links to Wikidata when no article exists -- if nothing or an empty string is passed set it false local wdl = parseParam(args.wdlinks or args.wdl, false) -- unitabbr is a boolean passed to enable unit abbreviations for common units -- if nothing or an empty string is passed set it false local uabbr = parseParam(args.unitabbr or args.uabbr, false) -- qualsonly is a boolean passed to return just the qualifiers -- if nothing or an empty string is passed set it false local qualsonly = parseParam(args.qualsonly or args.qo, false) -- maxvals is a string that may be nil, empty (""), or a number -- this determines how many items may be returned when multiple values are available -- setting it = 1 is useful where the returned string is used within another call, e.g. image local maxvals = tonumber(args.maxvals) or 0 -- pd (plain date) is a string: yes/true/1 | no/false/0 | adj -- to disable/enable "sourcing cirumstances" or use adjectival form for the plain date local pd = args.plaindate or args.pd or "no" args.pd = pd -- allow qualifiers to have a different date format; default to year unless qualsonly is set args.qdf = args.qdf or args.qualifierdateformat or args.df or (not qualsonly and "y") local lang = args.lang or findLang().code -- qualID is a string list of wanted qualifiers or "ALL" qualID = qualID or "" -- capitalise list of wanted qualifiers and substitute "DATES" qualID = qualID:upper():gsub("DATES", "P580, P582") local allflag = (qualID == "ALL") -- create table of wanted qualifiers as key local qwanted = {} -- create sequence of wanted qualifiers local qorder = {} for q in mw.text.gsplit(qualID, "%p") do -- split at punctuation and iterate local qtrim = mw.text.trim(q) if qtrim ~= "" then qwanted[mw.text.trim(q)] = true qorder[#qorder+1] = qtrim end end -- qsep is the output separator for rendering qualifier list local qsep = (args.qsep or ""):gsub('"', '') -- qargs are the arguments to supply to assembleoutput() local qargs = { ["osd"] = "false", ["linked"] = tostring(linked), ["prefix"] = args.qprefix, ["postfix"] = args.qpostfix, ["linkprefix"] = args.qlinkprefix or args.qlp, ["linkpostfix"] = args.qlinkpostfix, ["wdl"] = "false", ["unitabbr"] = tostring(uabbr), ["maxvals"] = 0, ["sorted"] = tostring(args.qsorted), ["noicon"] = "true", ["list"] = args.qlist, ["sep"] = qsep, ["langobj"] = args.langobj, ["lang"] = args.langobj.code, ["df"] = args.qdf, ["sn"] = parseParam(args.qsn or args.qshortname, false), } -- all proper values of a Wikidata property will be the same type as the first -- qualifiers don't have a mainsnak, properties do --#Modified line local datatype = objproperty[1].datatype or (objproperty[1].mainsnak and objproperty[1].mainsnak.datatype) -- out[] holds the a list of returned values for this property -- mlt[] holds the language code if the datatype is monolingual text local out = {} local mlt = {} for k, v in ipairs(objproperty) do local hasvalue = true if (onlysrc and not sourced(v)) then -- no value: it isn't sourced when onlysourced=true hasvalue = false else local val, lcode = rendersnak(v, args, linked, lprefix, lpostfix, prefix, postfix, uabbr) if not val then hasvalue = false -- rank doesn't match elseif qualsonly and qualID then -- suppress value returned: only qualifiers are requested else out[#out+1], mlt[#out+1] = val, lcode end end -- See if qualifiers are to be returned: local snak = v.mainsnak or v if hasvalue and v.qualifiers and qualID ~= "" and snak.snaktype~="novalue" then -- collect all wanted qualifier values returned in qlist, indexed by propertyID local qlist = {} local timestart, timeend = "", "" -- loop through qualifiers for k1, v1 in pairs(v.qualifiers) do if allflag or qwanted[k1] then if k1 == "P1326" then local ts = v1[1].datavalue.value.time local dp = v1[1].datavalue.value.precision qlist[k1] = dateFormat(ts, dp, args.qdf, args.bc, pd, "", lang, "before") elseif k1 == "P1319" then local ts = v1[1].datavalue.value.time local dp = v1[1].datavalue.value.precision qlist[k1] = dateFormat(ts, dp, args.qdf, args.bc, pd, "", lang, "after") elseif k1 == "P580" then timestart = propertyvalueandquals(v1, qargs)[1] or "" -- treat only one start time as valid elseif k1 == "P582" then timeend = propertyvalueandquals(v1, qargs)[1] or "" -- treat only one end time as valid else local q = assembleoutput(propertyvalueandquals(v1, qargs), qargs) -- we already deal with circa via 'sourcing circumstances' if the datatype was time -- circa may be either linked or unlinked *** internationalise later *** if datatype ~= "time" or q ~= "circa" and not (type(q) == "string" and q:find("circa]]")) then qlist[k1] = q end end end -- of test for wanted end -- of loop through qualifiers -- set date separator local t = timestart .. timeend -- *** internationalise date separators later *** local dsep = "&ndash;" if t:find("%s") or t:find("&nbsp;") then dsep = " &ndash; " end -- set the order for the list of qualifiers returned; start time and end time go last if next(qlist) then local qlistout = {} if allflag then for k2, v2 in pairs(qlist) do qlistout[#qlistout+1] = v2 end else for i2, v2 in ipairs(qorder) do qlistout[#qlistout+1] = qlist[v2] end end if t ~= "" then qlistout[#qlistout+1] = timestart .. dsep .. timeend end local qstr = assembleoutput(qlistout, qargs) if qualsonly then out[#out+1] = qstr else out[#out] = out[#out] .. " (" .. qstr .. ")" end elseif t ~= "" then if qualsonly then if timestart == "" then out[#out+1] = timeend elseif timeend == "" then out[#out+1] = timestart else out[#out+1] = timestart .. dsep .. timeend end else out[#out] = out[#out] .. " (" .. timestart .. dsep .. timeend .. ")" end end end -- of test for qualifiers wanted if maxvals > 0 and #out >= maxvals then break end end -- of for each value loop -- we need to pick one value to return if the datatype was "monolingualtext" -- if there's only one value, use that -- otherwise look through the fallback languages for a match if datatype == "monolingualtext" and #out >1 then lang = mw.text.split( lang, '-', true )[1] local fbtbl = mw.language.getFallbacksFor( lang ) table.insert( fbtbl, 1, lang ) local bestval = "" local found = false for idx1, lang1 in ipairs(fbtbl) do for idx2, lang2 in ipairs(mlt) do if (lang1 == lang2) and not found then bestval = out[idx2] found = true break end end -- loop through values of property end -- loop through fallback languages if found then -- replace output table with a table containing the best value out = { bestval } else -- more than one value and none of them on the list of fallback languages -- sod it, just give them the first one out = { out[1] } end end return out end ------------------------------------------------------------------------------- -- Common code for p.getValueByQual and p.getValueByLang ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; assembleoutput; ------------------------------------------------------------------------------- local _getvaluebyqual = function(frame, qualID, checkvalue) -- The property ID that will have a qualifier is the first unnamed parameter local propertyID = mw.text.trim(frame.args[1] or "") if propertyID == "" then return "no property supplied" end if qualID == "" then return "no qualifier supplied" end -- onlysourced is a boolean passed to return property values -- only when property values are sourced to something other than Wikipedia -- if nothing or an empty string is passed set it true -- if "false" or "no" or 0 is passed set it false local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true) -- set the requested ranks flags frame.args.reqranks = setRanks(frame.args.rank) -- set a language object and code in the frame.args table frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code local args = frame.args -- check for locally supplied parameter in second unnamed parameter -- success means no local parameter and the property exists local qid, props = parseInput(frame, args[2], propertyID) local linked = parseParam(args.linked, true) local lpre = (args.linkprefix or args.lp or ""):gsub('"', '') local lpost = (args.linkpostfix or ""):gsub('"', '') local pre = (args.prefix or ""):gsub('"', '') local post = (args.postfix or ""):gsub('"', '') local uabbr = parseParam(args.unitabbr or args.uabbr, false) local filter = (args.unit or ""):upper() local maxvals = tonumber(args.maxvals) or 0 if filter == "" then filter = nil end if qid then local out = {} -- Scan through the values of the property -- we want something like property is "pronunciation audio (P443)" in propertyID -- with a qualifier like "language of work or name (P407)" in qualID -- whose value has the required ID, like "British English (Q7979)", in qval for k1, v1 in ipairs(props) do if v1.mainsnak.snaktype == "value" then -- check if it has the right qualifier local v1q = v1.qualifiers if v1q and v1q[qualID] then if onlysrc == false or sourced(v1) then -- if we've got this far, we have a (sourced) claim with qualifiers -- so see if matches the required value -- We'll only deal with wikibase-items and strings for now if v1q[qualID][1].datatype == "wikibase-item" then if checkvalue(v1q[qualID][1].datavalue.value.id) then out[#out + 1] = rendersnak(v1, args, linked, lpre, lpost, pre, post, uabbr, filter) end elseif v1q[qualID][1].datatype == "string" then if checkvalue(v1q[qualID][1].datavalue.value) then out[#out + 1] = rendersnak(v1, args, linked, lpre, lpost, pre, post, uabbr, filter) end end end -- of check for sourced end -- of check for matching required value and has qualifiers else return nil end -- of check for string if maxvals > 0 and #out >= maxvals then break end end -- of loop through values of propertyID return assembleoutput(out, frame.args, qid, propertyID) else return props -- either local parameter or nothing end -- of test for success return nil end ------------------------------------------------------------------------------- -- _location takes Q-id and follows P276 (location) -- or P131 (located in the administrative territorial entity) or P706 (located on terrain feature) -- from the initial item to higher level territories/locations until it reaches the highest. -- An optional boolean, 'first', determines whether the first item is returned (default: false). -- An optional boolean 'skip' toggles the display to skip to the last item (default: false). -- It returns a table containing the locations - linked where possible, except for the highest. ------------------------------------------------------------------------------- -- Dependencies: findLang(); labelOrId(); linkedItem ------------------------------------------------------------------------------- local _location = function(qid, first, skip) first = parseParam(first, false) skip = parseParam(skip, false) local locs = {"P276", "P131", "P706"} local out = {} local langcode = findLang():getCode() local finished = false local count = 0 local prevqid = "Q0" repeat local prop for i1, v1 in ipairs(locs) do local proptbl = mw.wikibase.getBestStatements(qid, v1) if #proptbl > 1 then -- there is more than one higher location local prevP131, prevP131id if prevqid ~= "Q0" then prevP131 = mw.wikibase.getBestStatements(prevqid, "P131")[1] prevP131id = prevP131 and prevP131.mainsnak.datavalue and prevP131.mainsnak.datavalue.value.id end for i2, v2 in ipairs(proptbl) do local parttbl = v2.qualifiers and v2.qualifiers.P518 if parttbl then -- this higher location has qualifier 'applies to part' (P518) for i3, v3 in ipairs(parttbl) do if v3.snaktype == "value" and v3.datavalue.value.id == prevqid then -- it has a value equal to the previous location prop = proptbl[i2] break end -- of test for matching last location end -- of loop through values of 'applies to part' else -- there's no qualifier 'applies to part' (P518) -- so check if the previous location had a P131 that matches this alternate if qid == prevP131id then prop = proptbl[i2] break end -- of test for matching previous P131 end end -- of loop through parent locations -- fallback to second value if match not found prop = prop or proptbl[2] elseif #proptbl > 0 then prop = proptbl[1] end if prop then break end end -- check if it's an instance of (P31) a country (Q6256) or sovereign state (Q3624078) -- and terminate the chain if it is local inst = mw.wikibase.getAllStatements(qid, "P31") if #inst > 0 then for k, v in ipairs(inst) do local instid = v.mainsnak.datavalue and v.mainsnak.datavalue.value.id -- stop if it's a country (or a country within the United Kingdom if skip is true) if instid == "Q6256" or instid == "Q3624078" or (skip and instid == "Q3336843") then prop = nil -- this will ensure this is treated as top-level location break end end end -- get the name of this location and update qid to point to the parent location if prop and prop.mainsnak.datavalue then if not skip or count == 0 then local args = { lprefix = ":" } out[#out+1] = linkedItem(qid, args) -- get a linked value if we can end qid, prevqid = prop.mainsnak.datavalue.value.id, qid else -- This is top-level location, so get short name except when this is the first item -- Use full label if there's no short name or this is the first item local prop1813 = mw.wikibase.getAllStatements(qid, "P1813") -- if there's a short name and this isn't the only item if prop1813[1] and (#out > 0)then local shortname -- short name is monolingual text, so look for match to the local language -- choose the shortest 'short name' in that language for k, v in pairs(prop1813) do if v.mainsnak.datavalue.value.language == langcode then local name = v.mainsnak.datavalue.value.text if (not shortname) or (#name < #shortname) then shortname = name end end end -- add the shortname if one is found, fallback to the label -- but skip it if it's "USA" if shortname ~= "USA" then out[#out+1] = shortname or labelOrId(qid) else if skip then out[#out+1] = "US" end end else -- no shortname, so just add the label local loc = labelOrId(qid) -- exceptions go here: if loc == "United States of America" then out[#out+1] = "United States" else out[#out+1] = loc end end finished = true end count = count + 1 until finished or count >= 10 -- limit to 10 levels to avoid infinite loops -- remove the first location if not required if not first then table.remove(out, 1) end -- we might have duplicate text for consecutive locations, so remove them if #out > 2 then local plain = {} for i, v in ipairs(out) do -- strip any links plain[i] = v:gsub("^%[%[[^|]*|", ""):gsub("]]$", "") end local idx = 2 repeat if plain[idx] == plain[idx-1] then -- duplicate found local removeidx = 0 if (plain[idx] ~= out[idx]) and (plain[idx-1] == out[idx-1]) then -- only second one is linked, so drop the first removeidx = idx - 1 elseif (plain[idx] == out[idx]) and (plain[idx-1] ~= out[idx-1]) then -- only first one is linked, so drop the second removeidx = idx else -- pick one removeidx = idx - (os.time()%2) end table.remove(out, removeidx) table.remove(plain, removeidx) else idx = idx +1 end until idx >= #out end return out end ------------------------------------------------------------------------------- -- _getsumofparts scans the property 'has part' (P527) for values matching a list. -- The list (args.vlist) consists of a string of Qids separated by spaces or any usual punctuation. -- If the matched values have a qualifer 'quantity' (P1114), those quantites are summed. -- The sum is returned as a number (i.e. 0 if none) -- a table of arguments is supplied implementing the usual parameters. ------------------------------------------------------------------------------- -- Dependencies: setRanks; parseParam; parseInput; sourced; assembleoutput; ------------------------------------------------------------------------------- local _getsumofparts = function(args) local vallist = (args.vlist or ""):upper() if vallist == "" then return end args.reqranks = setRanks(args.rank) local f = {} f.args = args local qid, props = parseInput(f, "", "P527") if not qid then return 0 end local onlysrc = parseParam(args.onlysourced or args.osd, true) local sum = 0 for k1, v1 in ipairs(props) do if (onlysrc == false or sourced(v1)) and v1.mainsnak.snaktype == "value" and v1.mainsnak.datavalue.type == "wikibase-entityid" and vallist:match( v1.mainsnak.datavalue.value.id ) and v1.qualifiers then local quals = v1.qualifiers["P1114"] if quals then for k2, v2 in ipairs(quals) do sum = sum + v2.datavalue.value.amount end end end end return sum end ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Public functions ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- _getValue makes the functionality of getValue available to other modules ------------------------------------------------------------------------------- -- Dependencies: setRanks; parseInput; propertyvalueandquals; assembleoutput; parseParam; sourced; -- labelOrId; i18n.latestdatequalifier; format_Date; makeOrdinal; roundto; decimalPrecision; decimalToDMS; ------------------------------------------------------------------------------- p._getValue = function(args) -- parameter sets for commonly used groups of parameters local paraset = tonumber(args.ps or args.parameterset or 0) if paraset == 1 then -- a common setting args.rank = "best" args.fetchwikidata = "ALL" args.onlysourced = "no" args.noicon = "true" elseif paraset == 2 then -- equivalent to raw args.rank = "best" args.fetchwikidata = "ALL" args.onlysourced = "no" args.noicon = "true" args.linked = "no" args.pd = "true" elseif paraset == 3 then -- third set goes here end -- implement eid parameter local eid = args.eid if eid == "" then return nil elseif eid then args.qid = eid end local propertyID = mw.text.trim(args[1] or "") args.reqranks = setRanks(args.rank) -- replacetext (rt) is a string that is returned instead of any non-empty Wikidata value -- this is useful for tracking and debugging, so we set fetchwikidata=ALL to fill the whitelist local replacetext = mw.text.trim(args.rt or args.replacetext or "") if replacetext ~= "" then args.fetchwikidata = "ALL" end local f = {} f.args = args local entityid, props = parseInput(f, f.args[2], propertyID) if not entityid then return props -- either the input parameter or nothing end -- qual is a string containing the property ID of the qualifier(s) to be returned -- if qual == "ALL" then all qualifiers returned -- if qual == "DATES" then qualifiers P580 (start time) and P582 (end time) returned -- if nothing or an empty string is passed set it nil -> no qualifiers returned local qualID = mw.text.trim(args.qual or ""):upper() if qualID == "" then qualID = nil end -- set a language object and code in the args table args.langobj = findLang(args.lang) args.lang = args.langobj.code -- table 'out' stores the return value(s): local out = propertyvalueandquals(props, args, qualID) -- format the table of values and return it as a string: return assembleoutput(out, args, entityid, propertyID) end --#Modified function p._getValueFromSnaks = function(args) local propertyID = mw.text.trim(args[1] or "") -- replacetext (rt) is a string that is returned instead of any non-empty Wikidata value -- this is useful for tracking and debugging, so we set fetchwikidata=ALL to fill the whitelist local replacetext = mw.text.trim(args.rt or args.replacetext or "") if replacetext ~= "" then args.fetchwikidata = "ALL" end local props local f = {} f.args = args local refsnak = args.snak if refsnak == "" then refsnak = nil end if refsnak then props = refsnak[propertyID] or {} end if not props[1] then return nil end -- set a language object and code in the args table args.langobj = findLang(args.lang) args.lang = args.langobj.code -- table 'out' stores the return value(s): local out = propertyvalueandquals(props, args) -- format the table of values and return it as a string: return assembleoutput(out, args, nil, propertyID) end ------------------------------------------------------------------------------- -- getValue is used to get the value(s) of a property -- The property ID is passed as the first unnamed parameter and is required. -- A locally supplied parameter may optionaly be supplied as the second unnamed parameter. -- The function will now also return qualifiers if parameter qual is supplied ------------------------------------------------------------------------------- -- Dependencies: _getValue; setRanks; parseInput; propertyvalueandquals; assembleoutput; parseParam; sourced; -- labelOrId; i18n.latestdatequalifier; format_Date; makeOrdinal; roundto; decimalPrecision; decimalToDMS; ------------------------------------------------------------------------------- p.getValue = function(frame) local args= frame.args if not args[1] then args = frame:getParent().args if not args[1] then return i18n.errors["No property supplied"] end end return p._getValue(args) end ------------------------------------------------------------------------------- -- getPreferredValue is used to get a value, -- (or a comma separated list of them if multiple values exist). -- If preferred ranks are set, it will return those values, otherwise values with normal ranks -- now redundant to getValue with |rank=best ------------------------------------------------------------------------------- -- Dependencies: p.getValue; setRanks; parseInput; propertyvalueandquals; assembleoutput; -- parseParam; sourced; labelOrId; i18n.latestdatequalifier; format_Date; -- makeOrdinal; roundto; decimalPrecision; decimalToDMS; ------------------------------------------------------------------------------- p.getPreferredValue = function(frame) frame.args.rank = "best" return p.getValue(frame) end ------------------------------------------------------------------------------- -- getCoords is used to get coordinates for display in an infobox -- whitelist and blacklist are implemented -- optional 'display' parameter is allowed, defaults to nil - was "inline, title" ------------------------------------------------------------------------------- -- Dependencies: setRanks(); parseInput(); decimalPrecision(); ------------------------------------------------------------------------------- p.getCoords = function(frame) local propertyID = "P625" -- if there is a 'display' parameter supplied, use it -- otherwise default to nothing local disp = frame.args.display or "" if disp == "" then disp = nil -- default to not supplying display parameter, was "inline, title" end -- there may be a format parameter to switch from deg/min/sec to decimal degrees -- default is deg/min/sec -- decimal degrees needs |format = dec local form = (frame.args.format or ""):lower():sub(1,3) if form ~= "dec" then form = "dms" end -- just deal with best values frame.args.reqranks = setRanks("best") local qid, props = parseInput(frame, frame.args[1], propertyID) if not qid then return props -- either local parameter or nothing else local dv = props[1].mainsnak.datavalue.value local lat, long, prec = dv.latitude, dv.longitude, dv.precision lat = decimalPrecision(lat, prec) long = decimalPrecision(long, prec) local lat_long = { lat, long } lat_long["display"] = disp lat_long["format"] = form -- invoke template Coord with the values stored in the table return frame:expandTemplate{title = 'coord', args = lat_long} end end ------------------------------------------------------------------------------- -- getQualifierValue is used to get a formatted value of a qualifier -- -- The call needs: a property (the unnamed parameter or 1=) -- a target value for that property (pval=) -- a qualifier for that target value (qual=) -- The usual whitelisting and blacklisting of the property is implemented -- The boolean onlysourced= parameter can be set to return nothing -- when the property is unsourced (or only sourced to Wikipedia) ------------------------------------------------------------------------------- -- Dependencies: parseParam(); setRanks(); parseInput(); sourced(); -- propertyvalueandquals(); assembleoutput(); -- labelOrId(); i18n.latestdatequalifier(); format_Date(); -- findLang(); makeOrdinal(); roundto(); decimalPrecision(); decimalToDMS(); ------------------------------------------------------------------------------- p.getQualifierValue = function(frame) -- The property ID that will have a qualifier is the first unnamed parameter local propertyID = mw.text.trim(frame.args[1] or "") -- The value of the property we want to match whose qualifier value is to be returned -- is passed in named parameter |pval= local propvalue = frame.args.pval -- The property ID of the qualifier -- whose value is to be returned is passed in named parameter |qual= local qualifierID = frame.args.qual -- A filter can be set like this: filter=P642==Q22674854 local filter, fprop, fval local ftable = mw.text.split(frame.args.filter or "", "==") if ftable[2] then fprop = mw.text.trim(ftable[1]) fval = mw.text.trim(ftable[2]) filter = true end -- onlysourced is a boolean passed to return qualifiers -- only when property values are sourced to something other than Wikipedia -- if nothing or an empty string is passed set it true -- if "false" or "no" or 0 is passed set it false local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true) -- set a language object and language code in the frame.args table frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code -- set the requested ranks flags frame.args.reqranks = setRanks(frame.args.rank) -- check for locally supplied parameter in second unnamed parameter -- success means no local parameter and the property exists local qid, props = parseInput(frame, frame.args[2], propertyID) if qid then local out = {} -- Scan through the values of the property -- we want something like property is P793, significant event (in propertyID) -- whose value is something like Q385378, construction (in propvalue) -- then we can return the value(s) of a qualifier such as P580, start time (in qualifierID) for k1, v1 in pairs(props) do if v1.mainsnak.snaktype == "value" and v1.mainsnak.datavalue.type == "wikibase-entityid" then -- It's a wiki-linked value, so check if it's the target (in propvalue) and if it has qualifiers if v1.mainsnak.datavalue.value.id == propvalue and v1.qualifiers then if onlysrc == false or sourced(v1) then -- if we've got this far, we have a (sourced) claim with qualifiers -- which matches the target, so apply the filter and find the value(s) of the qualifier we want if not filter or (v1.qualifiers[fprop] and v1.qualifiers[fprop][1].datavalue.value.id == fval) then local quals = v1.qualifiers[qualifierID] if quals then -- can't reference qualifer, so set onlysourced = "no" (args are strings, not boolean) local qargs = frame.args qargs.onlysourced = "no" local vals = propertyvalueandquals(quals, qargs, qid) for k, v in ipairs(vals) do out[#out + 1] = v end end end end -- of check for sourced end -- of check for matching required value and has qualifiers end -- of check for wikibase entity end -- of loop through values of propertyID return assembleoutput(out, frame.args, qid, propertyID) else return props -- either local parameter or nothing end -- of test for success return nil end ------------------------------------------------------------------------------- -- getSumOfParts scans the property 'has part' (P527) for values matching a list. -- The list is passed in parameter vlist. -- It consists of a string of Qids separated by spaces or any usual punctuation. -- If the matched values have a qualifier 'quantity' (P1114), those quantities are summed. -- The sum is returned as a number or nothing if zero. ------------------------------------------------------------------------------- -- Dependencies: _getsumofparts; ------------------------------------------------------------------------------- p.getSumOfParts = function(frame) local sum = _getsumofparts(frame.args) if sum == 0 then return end return sum end ------------------------------------------------------------------------------- -- getValueByQual gets the value of a property which has a qualifier with a given entity value -- The call needs: -- a property ID (the unnamed parameter or 1=Pxxx) -- the ID of a qualifier for that property (qualID=Pyyy) -- either the Wikibase-entity ID of a value for that qualifier (qvalue=Qzzz) -- or a string value for that qualifier (qvalue=abc123) -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: _getvaluebyqual; parseParam; setRanks; parseInput; sourced; -- assembleoutput; ------------------------------------------------------------------------------- p.getValueByQual = function(frame) local qualID = frame.args.qualID -- The Q-id of the value for the qualifier we want to match is in named parameter |qvalue= local qval = frame.args.qvalue or "" if qval == "" then return "no qualifier value supplied" end local function checkQID(id) return id == qval end return _getvaluebyqual(frame, qualID, checkQID) end ------------------------------------------------------------------------------- -- getValueByLang gets the value of a property which has a qualifier P407 -- ("language of work or name") whose value has the given language code -- The call needs: -- a property ID (the unnamed parameter or 1=Pxxx) -- the MediaWiki language code to match the language (lang=xx[-yy]) -- (if no code is supplied, it uses the default language) -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: _getvaluebyqual; parseParam; setRanks; parseInput; sourced; assembleoutput; ------------------------------------------------------------------------------- p.getValueByLang = function(frame) -- The language code for the qualifier we want to match is in named parameter |lang= local langcode = findLang(frame.args.lang).code local function checkLanguage(id) -- id should represent a language like "British English (Q7979)" -- it should have string property "Wikimedia language code (P424)" -- qlcode will be a table: local qlcode = mw.wikibase.getBestStatements(id, "P424") if (#qlcode > 0) and (qlcode[1].mainsnak.datavalue.value == langcode) then return true end end return _getvaluebyqual(frame, "P407", checkLanguage) end ------------------------------------------------------------------------------- -- getValueByRefSource gets the value of a property which has a reference "stated in" (P248) -- whose value has the given entity-ID. -- The call needs: -- a property ID (the unnamed parameter or 1=Pxxx) -- the entity ID of a value to match where the reference is stated in (match=Qzzz) -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p.getValueByRefSource = function(frame) -- The property ID that we want to check is the first unnamed parameter local propertyID = mw.text.trim(frame.args[1] or ""):upper() if propertyID == "" then return "no property supplied" end -- The Q-id of the value we want to match is in named parameter |qvalue= local qval = (frame.args.match or ""):upper() if qval == "" then qval = "Q21540096" end local unit = (frame.args.unit or ""):upper() if unit == "" then unit = "Q4917" end local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true) -- set the requested ranks flags frame.args.reqranks = setRanks(frame.args.rank) -- set a language object and code in the frame.args table frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code local linked = parseParam(frame.args.linked, true) local uabbr = parseParam(frame.args.uabbr or frame.args.unitabbr, false) -- qid not nil means no local parameter and the property exists local qid, props = parseInput(frame, frame.args[2], propertyID) if qid then local out = {} local mlt= {} for k1, v1 in ipairs(props) do if onlysrc == false or sourced(v1) then if v1.references then for k2, v2 in ipairs(v1.references) do if v2.snaks.P248 then for k3, v3 in ipairs(v2.snaks.P248) do if v3.datavalue.value.id == qval then out[#out+1], mlt[#out+1] = rendersnak(v1, frame.args, linked, "", "", "", "", uabbr, unit) if not mlt[#out] then -- we only need one match per property value -- unless datatype was monolingual text break end end -- of test for match end -- of loop through values "stated in" end -- of test that "stated in" exists end -- of loop through references end -- of test that references exist end -- of test for sourced end -- of loop through values of propertyID if #mlt > 0 then local langcode = frame.args.lang langcode = mw.text.split( langcode, '-', true )[1] local fbtbl = mw.language.getFallbacksFor( langcode ) table.insert( fbtbl, 1, langcode ) local bestval = "" local found = false for idx1, lang1 in ipairs(fbtbl) do for idx2, lang2 in ipairs(mlt) do if (lang1 == lang2) and not found then bestval = out[idx2] found = true break end end -- loop through values of property end -- loop through fallback languages if found then -- replace output table with a table containing the best value out = { bestval } else -- more than one value and none of them on the list of fallback languages -- sod it, just give them the first one out = { out[1] } end end return assembleoutput(out, frame.args, qid, propertyID) else return props -- no property or local parameter supplied end -- of test for success end ------------------------------------------------------------------------------- -- getPropertyIDs takes most of the usual parameters. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented. -- It returns the Entity-IDs (Qids) of the values of a property if it is a Wikibase-Entity. -- Otherwise it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p._getPropertyIDs = function(args) args.reqranks = setRanks(args.rank) args.langobj = findLang(args.lang) args.lang = args.langobj.code -- change default for noicon to true args.noicon = tostring(parseParam(args.noicon or "", true)) local f = {} f.args = args local pid = mw.text.trim(args[1] or ""):upper() -- get the qid and table of claims for the property, or nothing and the local value passed local qid, props = parseInput(f, args[2], pid) if not qid then return props end if not props[1] then return nil end local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 local out = {} for i, v in ipairs(props) do local snak = v.mainsnak if ( snak.datatype == "wikibase-item" ) and ( v.rank and args.reqranks[v.rank:sub(1, 1)] ) and ( snak.snaktype == "value" ) and ( sourced(v) or not onlysrc ) then out[#out+1] = snak.datavalue.value.id end if maxvals > 0 and #out >= maxvals then break end end return assembleoutput(out, args, qid, pid) end p.getPropertyIDs = function(frame) local args = frame.args return p._getPropertyIDs(args) end ------------------------------------------------------------------------------- -- getQualifierIDs takes most of the usual parameters. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented. -- It takes a property-id as the first unnamed parameter, and an optional parameter qlist -- which is a list of qualifier property-ids to search for (default is "ALL") -- It returns the Entity-IDs (Qids) of the values of a property if it is a Wikibase-Entity. -- Otherwise it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p.getQualifierIDs = function(frame) local args = frame.args args.reqranks = setRanks(args.rank) args.langobj = findLang(args.lang) args.lang = args.langobj.code -- change default for noicon to true args.noicon = tostring(parseParam(args.noicon or "", true)) local f = {} f.args = args local pid = mw.text.trim(args[1] or ""):upper() -- get the qid and table of claims for the property, or nothing and the local value passed local qid, props = parseInput(f, args[2], pid) if not qid then return props end if not props[1] then return nil end -- get the other parameters local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 local qlist = args.qlist or "" if qlist == "" then qlist = "ALL" end qlist = qlist:gsub("[%p%s]+", " ") .. " " local out = {} for i, v in ipairs(props) do local snak = v.mainsnak if ( v.rank and args.reqranks[v.rank:sub(1, 1)] ) and ( snak.snaktype == "value" ) and ( sourced(v) or not onlysrc ) then if v.qualifiers then for k1, v1 in pairs(v.qualifiers) do if qlist == "ALL " or qlist:match(k1 .. " ") then for i2, v2 in ipairs(v1) do if v2.datatype == "wikibase-item" and v2.snaktype == "value" then out[#out+1] = v2.datavalue.value.id end -- of test that id exists end -- of loop through qualifier values end -- of test for kq in qlist end -- of loop through qualifiers end -- of test for qualifiers end -- of test for rank value, sourced, and value exists if maxvals > 0 and #out >= maxvals then break end end -- of loop through property values return assembleoutput(out, args, qid, pid) end ------------------------------------------------------------------------------- -- getPropOfProp takes two propertyIDs: prop1 and prop2 (as well as the usual parameters) -- If the value(s) of prop1 are of type "wikibase-item" then it returns the value(s) of prop2 -- of each of those wikibase-items. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p._getPropOfProp = function(args) -- parameter sets for commonly used groups of parameters local paraset = tonumber(args.ps or args.parameterset or 0) if paraset == 1 then -- a common setting args.rank = "best" args.fetchwikidata = "ALL" args.onlysourced = "no" args.noicon = "true" elseif paraset == 2 then -- equivalent to raw args.rank = "best" args.fetchwikidata = "ALL" args.onlysourced = "no" args.noicon = "true" args.linked = "no" args.pd = "true" elseif paraset == 3 then -- third set goes here end args.reqranks = setRanks(args.rank) args.langobj = findLang(args.lang) args.lang = args.langobj.code local pid1 = args.prop1 or args.pid1 or "" local pid2 = args.prop2 or args.pid2 or "" if pid1 == "" or pid2 == "" then return nil end local f = {} f.args = args local qid1, statements1 = parseInput(f, args[1], pid1) -- parseInput nulls empty args[1] and returns args[1] if nothing on Wikidata if not qid1 then return statements1 end -- otherwise it returns the qid and a table for the statement local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 local qualID = mw.text.trim(args.qual or ""):upper() if qualID == "" then qualID = nil end local out = {} for k, v in ipairs(statements1) do if not onlysrc or sourced(v) then local snak = v.mainsnak if snak.datatype == "wikibase-item" and snak.snaktype == "value" then local qid2 = snak.datavalue.value.id local statements2 = {} if args.reqranks.b then statements2 = mw.wikibase.getBestStatements(qid2, pid2) else statements2 = mw.wikibase.getAllStatements(qid2, pid2) end if statements2[1] then local out2 = propertyvalueandquals(statements2, args, qualID) out[#out+1] = assembleoutput(out2, args, qid2, pid2) end end -- of test for valid property1 value end -- of test for sourced if maxvals > 0 and #out >= maxvals then break end end -- of loop through values of property1 return assembleoutput(out, args, qid1, pid1) end p.getPropOfProp = function(frame) local args= frame.args if not args.prop1 and not args.pid1 then args = frame:getParent().args if not args.prop1 and not args.pid1 then return i18n.errors["No property supplied"] end end return p._getPropOfProp(args) end ------------------------------------------------------------------------------- -- getAwardCat takes most of the usual parameters. If the item has values of P166 (award received), -- then it examines each of those awards for P2517 (category for recipients of this award). -- If it exists, it returns the corresponding category, -- with the item's P734 (family name) as sort key, or no sort key if there is no family name. -- The sort key may be overridden by the parameter |sortkey (alias |sk). -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p.getAwardCat = function(frame) frame.args.reqranks = setRanks(frame.args.rank) frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code local args = frame.args args.sep = " " local pid1 = args.prop1 or "P166" local pid2 = args.prop2 or "P2517" if pid1 == "" or pid2 == "" then return nil end -- locally supplied value: local localval = mw.text.trim(args[1] or "") local qid1, statements1 = parseInput(frame, localval, pid1) if not qid1 then return localval end -- linkprefix (strip quotes) local lp = (args.linkprefix or args.lp or ""):gsub('"', '') -- sort key (strip quotes, hyphens and periods): local sk = (args.sortkey or args.sk or ""):gsub('["-.]', '') -- family name: local famname = "" if sk == "" then local p734 = mw.wikibase.getBestStatements(qid1, "P734")[1] local p734id = p734 and p734.mainsnak.snaktype == "value" and p734.mainsnak.datavalue.value.id or "" famname = mw.wikibase.getSitelink(p734id) or "" -- strip namespace and disambigation local pos = famname:find(":") or 0 famname = famname:sub(pos+1):gsub("%s%(.+%)$", "") if famname == "" then local lbl = mw.wikibase.getLabel(p734id) famname = lbl and mw.text.nowiki(lbl) or "" end end local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 local qualID = mw.text.trim(args.qual or ""):upper() if qualID == "" then qualID = nil end local out = {} for k, v in ipairs(statements1) do if not onlysrc or sourced(v) then local snak = v.mainsnak if snak.datatype == "wikibase-item" and snak.snaktype == "value" then local qid2 = snak.datavalue.value.id local statements2 = {} if args.reqranks.b then statements2 = mw.wikibase.getBestStatements(qid2, pid2) else statements2 = mw.wikibase.getAllStatements(qid2, pid2) end if statements2[1] and statements2[1].mainsnak.snaktype == "value" then local qid3 = statements2[1].mainsnak.datavalue.value.id local sitelink = mw.wikibase.getSitelink(qid3) -- if there's no local sitelink, create the sitelink from English label if not sitelink then local lbl = mw.wikibase.getLabelByLang(qid3, "en") if lbl then if lbl:sub(1,9) == "Category:" then sitelink = mw.text.nowiki(lbl) else sitelink = "Category:" .. mw.text.nowiki(lbl) end end end if sitelink then if sk ~= "" then out[#out+1] = "[[" .. lp .. sitelink .. "|" .. sk .. "]]" elseif famname ~= "" then out[#out+1] = "[[" .. lp .. sitelink .. "|" .. famname .. "]]" else out[#out+1] = "[[" .. lp .. sitelink .. "]]" end -- of check for sort keys end -- of test for sitelink end -- of test for category end -- of test for wikibase item has a value end -- of test for sourced if maxvals > 0 and #out >= maxvals then break end end -- of loop through values of property1 return assembleoutput(out, args, qid1, pid1) end ------------------------------------------------------------------------------- -- getIntersectCat takes most of the usual parameters. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented -- It takes two properties, |prop1 and |prop2 (e.g. occupation and country of citizenship) -- Each property's value is a wiki-base entity -- For each value of the first parameter (ranks implemented) it fetches the value's main category -- and then each value of the second parameter (possibly substituting a simpler description) -- then it returns all of the categories representing the intersection of those properties, -- (e.g. Category:Actors from Canada). A joining term may be supplied (e.g. |join=from). -- The item's P734 (family name) is the sort key, or no sort key if there is no family name. -- The sort key may be overridden by the parameter |sortkey (alias |sk). ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p.getIntersectCat = function(frame) frame.args.reqranks = setRanks(frame.args.rank) frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code local args = frame.args args.sep = " " args.linked = "no" local pid1 = args.prop1 or "P106" local pid2 = args.prop2 or "P27" if pid1 == "" or pid2 == "" then return nil end local qid, statements1 = parseInput(frame, "", pid1) if not qid then return nil end local qid, statements2 = parseInput(frame, "", pid2) if not qid then return nil end -- topics like countries may have different names in categories from their label in Wikidata local subs_exists, subs = pcall(mw.loadData, "Module:WikidataIB/subs") local join = args.join or "" local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 -- linkprefix (strip quotes) local lp = (args.linkprefix or args.lp or ""):gsub('"', '') -- sort key (strip quotes, hyphens and periods): local sk = (args.sortkey or args.sk or ""):gsub('["-.]', '') -- family name: local famname = "" if sk == "" then local p734 = mw.wikibase.getBestStatements(qid, "P734")[1] local p734id = p734 and p734.mainsnak.snaktype == "value" and p734.mainsnak.datavalue.value.id or "" famname = mw.wikibase.getSitelink(p734id) or "" -- strip namespace and disambigation local pos = famname:find(":") or 0 famname = famname:sub(pos+1):gsub("%s%(.+%)$", "") if famname == "" then local lbl = mw.wikibase.getLabel(p734id) famname = lbl and mw.text.nowiki(lbl) or "" end end local cat1 = {} for k, v in ipairs(statements1) do if not onlysrc or sourced(v) then -- get the ID representing the value of the property local pvalID = (v.mainsnak.snaktype == "value") and v.mainsnak.datavalue.value.id if pvalID then -- get the topic's main category (P910) for that entity local p910 = mw.wikibase.getBestStatements(pvalID, "P910")[1] if p910 and p910.mainsnak.snaktype == "value" then local tmcID = p910.mainsnak.datavalue.value.id -- use sitelink or the English label for the cat local cat = mw.wikibase.getSitelink(tmcID) if not cat then local lbl = mw.wikibase.getLabelByLang(tmcID, "en") if lbl then if lbl:sub(1,9) == "Category:" then cat = mw.text.nowiki(lbl) else cat = "Category:" .. mw.text.nowiki(lbl) end end end cat1[#cat1+1] = cat end -- of test for topic's main category exists end -- of test for property has vaild value end -- of test for sourced if maxvals > 0 and #cat1 >= maxvals then break end end local cat2 = {} for k, v in ipairs(statements2) do if not onlysrc or sourced(v) then local cat = rendersnak(v, args) if subs[cat] then cat = subs[cat] end cat2[#cat2+1] = cat end if maxvals > 0 and #cat2 >= maxvals then break end end local out = {} for k1, v1 in ipairs(cat1) do for k2, v2 in ipairs(cat2) do if sk ~= "" then out[#out+1] = "[[" .. lp .. v1 .. " " .. join .. " " .. v2 .. "|" .. sk .. "]]" elseif famname ~= "" then out[#out+1] = "[[" .. lp .. v1 .. " " .. join .. " " .. v2 .. "|" .. famname .. "]]" else out[#out+1] = "[[" .. lp .. v1 .. " " .. join .. " " .. v2 .. "]]" end -- of check for sort keys end end args.noicon = "true" return assembleoutput(out, args, qid, pid1) end ------------------------------------------------------------------------------- -- qualsToTable takes most of the usual parameters. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented. -- A qid may be given, and the first unnamed parameter is the property ID, which is of type wikibase item. -- It takes a list of qualifier property IDs as |quals= -- For a given qid and property, it creates the rows of an html table, -- each row being a value of the property (optionally only if the property matches the value in |pval= ) -- each cell being the first value of the qualifier corresponding to the list in |quals ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; ------------------------------------------------------------------------------- p.qualsToTable = function(frame) local args = frame.args local quals = args.quals or "" if quals == "" then return "" end args.reqranks = setRanks(args.rank) local propertyID = mw.text.trim(args[1] or "") local f = {} f.args = args local entityid, props = parseInput(f, "", propertyID) if not entityid then return "" end args.langobj = findLang(args.lang) args.lang = args.langobj.code local pval = args.pval or "" local qplist = mw.text.split(quals, "%p") -- split at punctuation and make a sequential table for i, v in ipairs(qplist) do qplist[i] = mw.text.trim(v):upper() -- remove whitespace and capitalise end local col1 = args.firstcol or "" if col1 ~= "" then col1 = col1 .. "</td><td>" end local emptycell = args.emptycell or "&nbsp;" -- construct a 2-D array of qualifier values in qvals local qvals = {} for i, v in ipairs(props) do local skip = false if pval ~= "" then local pid = v.mainsnak.datavalue and v.mainsnak.datavalue.value.id if pid ~= pval then skip = true end end if not skip then local qval = {} local vqualifiers = v.qualifiers or {} -- go through list of wanted qualifier properties for i1, v1 in ipairs(qplist) do -- check for that property ID in the statement's qualifiers local qv, qtype if vqualifiers[v1] then qtype = vqualifiers[v1][1].datatype if qtype == "time" then if vqualifiers[v1][1].snaktype == "value" then qv = mw.wikibase.renderSnak(vqualifiers[v1][1]) qv = frame:expandTemplate{title="dts", args={qv}} else qv = "?" end elseif qtype == "url" then if vqualifiers[v1][1].snaktype == "value" then qv = mw.wikibase.renderSnak(vqualifiers[v1][1]) local display = mw.ustring.match( mw.uri.decode(qv, "WIKI"), "([%w ]+)$" ) if display then qv = "[" .. qv .. " " .. display .. "]" end end else qv = mw.wikibase.formatValue(vqualifiers[v1][1]) end end -- record either the value or a placeholder qval[i1] = qv or emptycell end -- of loop through list of qualifiers -- add the list of qualifier values as a "row" in the main list qvals[#qvals+1] = qval end end -- of for each value loop local out = {} for i, v in ipairs(qvals) do out[i] = "<tr><td>" .. col1 .. table.concat(qvals[i], "</td><td>") .. "</td></tr>" end return table.concat(out, "\n") end ------------------------------------------------------------------------------- -- getGlobe takes an optional qid of a Wikidata entity passed as |qid= -- otherwise it uses the linked item for the current page. -- If returns the Qid of the globe used in P625 (coordinate location), -- or nil if there isn't one. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getGlobe = function(frame) local qid = frame.args.qid or frame.args[1] or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end local coords = mw.wikibase.getBestStatements(qid, "P625")[1] local globeid if coords and coords.mainsnak.snaktype == "value" then globeid = coords.mainsnak.datavalue.value.globe:match("(Q%d+)") end return globeid end ------------------------------------------------------------------------------- -- getCommonsLink takes an optional qid of a Wikidata entity passed as |qid= -- It returns one of the following in order of preference: -- the Commons sitelink of the linked Wikidata item; -- the Commons sitelink of the topic's main category of the linked Wikidata item; ------------------------------------------------------------------------------- -- Dependencies: _getCommonslink(); _getSitelink(); parseParam() ------------------------------------------------------------------------------- p.getCommonsLink = function(frame) local oc = frame.args.onlycat or frame.args.onlycategories local fb = parseParam(frame.args.fallback or frame.args.fb, true) return _getCommonslink(frame.args.qid, oc, fb) end ------------------------------------------------------------------------------- -- getSitelink takes the qid of a Wikidata entity passed as |qid= -- It takes an optional parameter |wiki= to determine which wiki is to be checked for a sitelink -- If the parameter is blank, then it uses the local wiki. -- If there is a sitelink to an article available, it returns the plain text link to the article -- If there is no sitelink, it returns nil. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getSiteLink = function(frame) return _getSitelink(frame.args.qid, frame.args.wiki or mw.text.trim(frame.args[1] or "")) end ------------------------------------------------------------------------------- -- getLink has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= -- If there is a sitelink to an article on the local Wiki, it returns a link to the article -- with the Wikidata label as the displayed text. -- If there is no sitelink, it returns the label as plain text. -- If there is no label in the local language, it displays the qid instead. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getLink = function(frame) local itemID = mw.text.trim(frame.args[1] or frame.args.qid or "") if itemID == "" then return end local sitelink = mw.wikibase.getSitelink(itemID) local label = labelOrId(itemID) if sitelink then return "[[:" .. sitelink .. "|" .. label .. "]]" else return label end end ------------------------------------------------------------------------------- -- getLabel has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= -- It returns the Wikidata label for the local language as plain text. -- If there is no label in the local language, it displays the qid instead. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getLabel = function(frame) local itemID = mw.text.trim(frame.args[1] or frame.args.qid or "") if itemID == "" then return end local lang = frame.args.lang or "" if lang == "" then lang = nil end local label = labelOrId(itemID, lang) return label end ------------------------------------------------------------------------------- -- label has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= -- if no qid is supplied, it uses the qid associated with the current page. -- It returns the Wikidata label for the local language as plain text. -- If there is no label in the local language, it returns nil. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.label = function(frame) local qid = mw.text.trim(frame.args[1] or frame.args.qid or "") if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return end local lang = frame.args.lang or "" if lang == "" then lang = nil end local label, success = labelOrId(qid, lang) if success then return label end end ------------------------------------------------------------------------------- -- getAT (Article Title) -- has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= -- If there is a sitelink to an article on the local Wiki, it returns the sitelink as plain text. -- If there is no sitelink or qid supplied, it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAT = function(frame) local itemID = mw.text.trim(frame.args[1] or frame.args.qid or "") if itemID == "" then return end return mw.wikibase.getSitelink(itemID) end ------------------------------------------------------------------------------- -- getDescription has the qid of a Wikidata entity passed as |qid= -- (it defaults to the associated qid of the current article if omitted) -- and a local parameter passed as the first unnamed parameter. -- Any local parameter passed (other than "Wikidata" or "none") becomes the return value. -- It returns the article description for the Wikidata entity if the local parameter is "Wikidata". -- Nothing is returned if the description doesn't exist or "none" is passed as the local parameter. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getDescription = function(frame) local desc = mw.text.trim(frame.args[1] or "") local itemID = mw.text.trim(frame.args.qid or "") if itemID == "" then itemID = nil end if desc:lower() == 'wikidata' then return mw.wikibase.getDescription(itemID) elseif desc:lower() == 'none' then return nil else return desc end end ------------------------------------------------------------------------------- -- getAliases has the qid of a Wikidata entity passed as |qid= -- (it defaults to the associated qid of the current article if omitted) -- and a local parameter passed as the first unnamed parameter. -- It implements blacklisting and whitelisting with a field name of "alias" by default. -- Any local parameter passed becomes the return value. -- Otherwise it returns the aliases for the Wikidata entity with the usual list options. -- Nothing is returned if the aliases do not exist. ------------------------------------------------------------------------------- -- Dependencies: findLang(); assembleoutput() ------------------------------------------------------------------------------- p.getAliases = function(frame) local args = frame.args local fieldname = args.name or "" if fieldname == "" then fieldname = "alias" end local blacklist = args.suppressfields or args.spf or "" if blacklist:find(fieldname) then return nil end local localval = mw.text.trim(args[1] or "") if localval ~= "" then return localval end local whitelist = args.fetchwikidata or args.fwd or "" if whitelist == "" then whitelist = "NONE" end if not (whitelist == 'ALL' or whitelist:find(fieldname)) then return nil end local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid or not mw.wikibase.entityExists(qid) then return nil end local aliases = mw.wikibase.getEntity(qid).aliases if not aliases then return nil end args.langobj = findLang(args.lang) local langcode = args.langobj.code args.lang = langcode local out = {} for k1, v1 in pairs(aliases) do if v1[1].language == langcode then for k1, v2 in ipairs(v1) do out[#out+1] = v2.value end break end end return assembleoutput(out, args, qid) end ------------------------------------------------------------------------------- -- pageId returns the page id (entity ID, Qnnn) of the current page -- returns nothing if the page is not connected to Wikidata ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.pageId = function(frame) return mw.wikibase.getEntityIdForCurrentPage() end ------------------------------------------------------------------------------- -- formatDate is a wrapper to export the private function format_Date ------------------------------------------------------------------------------- -- Dependencies: format_Date(); ------------------------------------------------------------------------------- p.formatDate = function(frame) return format_Date(frame.args[1], frame.args.df, frame.args.bc) end ------------------------------------------------------------------------------- -- location is a wrapper to export the private function _location -- it takes the entity-id as qid or the first unnamed parameter -- optional boolean parameter first toggles the display of the first item -- optional boolean parameter skip toggles the display to skip to the last item -- parameter debug=<y/n> (default 'n') adds error msg if not a location ------------------------------------------------------------------------------- -- Dependencies: _location(); ------------------------------------------------------------------------------- p.location = function(frame) local debug = (frame.args.debug or ""):sub(1, 1):lower() if debug == "" then debug = "n" end local qid = mw.text.trim(frame.args.qid or frame.args[1] or ""):upper() if qid == "" then qid=mw.wikibase.getEntityIdForCurrentPage() end if not qid then if debug ~= "n" then return i18n.errors["entity-not-found"] else return nil end end local first = mw.text.trim(frame.args.first or "") local skip = mw.text.trim(frame.args.skip or "") return table.concat( _location(qid, first, skip), ", " ) end ------------------------------------------------------------------------------- -- checkBlacklist implements a test to check whether a named field is allowed -- returns true if the field is not blacklisted (i.e. allowed) -- returns false if the field is blacklisted (i.e. disallowed) -- {{#if:{{#invoke:WikidataIB |checkBlacklist |name=Joe |suppressfields=Dave; Joe; Fred}} | not blacklisted | blacklisted}} -- displays "blacklisted" -- {{#if:{{#invoke:WikidataIB |checkBlacklist |name=Jim |suppressfields=Dave; Joe; Fred}} | not blacklisted | blacklisted}} -- displays "not blacklisted" ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.checkBlacklist = function(frame) local blacklist = frame.args.suppressfields or frame.args.spf or "" local fieldname = frame.args.name or "" if blacklist ~= "" and fieldname ~= "" then if blacklist:find(fieldname) then return false else return true end else -- one of the fields is missing: let's call that "not on the list" return true end end ------------------------------------------------------------------------------- -- emptyor returns nil if its first unnamed argument is just punctuation, whitespace or html tags -- otherwise it returns the argument unchanged (including leading/trailing space). -- If the argument may contain "=", then it must be called explicitly: -- |1=arg -- (In that case, leading and trailing spaces are trimmed) -- It finds use in infoboxes where it can replace tests like: -- {{#if: {{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}} | <span class="xxx">{{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}}</span> | }} -- with a form that uses just a single call to Wikidata: -- {{#invoke |WikidataIB |emptyor |1= <span class="xxx">{{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}}</span> }} ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.emptyor = function(frame) local s = frame.args[1] or "" if s == "" then return nil end local sx = s:gsub("%s", ""):gsub("<[^>]*>", ""):gsub("%p", "") if sx == "" then return nil else return s end end ------------------------------------------------------------------------------- -- labelorid is a public function to expose the output of labelOrId() -- Pass the Q-number as |qid= or as an unnamed parameter. -- It returns the Wikidata label for that entity or the qid if no label exists. ------------------------------------------------------------------------------- -- Dependencies: labelOrId ------------------------------------------------------------------------------- p.labelorid = function(frame) return (labelOrId(frame.args.qid or frame.args[1])) end ------------------------------------------------------------------------------- -- getLang returns the MediaWiki language code of the current content. -- If optional parameter |style=full, it returns the language name. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getLang = function(frame) local style = (frame.args.style or ""):lower() local langcode = mw.language.getContentLanguage().code if style == "full" then return mw.language.fetchLanguageName( langcode ) end return langcode end ------------------------------------------------------------------------------- -- getItemLangCode takes a qid parameter (using the current page's qid if blank) -- If the item for that qid has property country (P17) it looks at the first preferred value -- If the country has an official language (P37), it looks at the first preferred value -- If that official language has a language code (P424), it returns the first preferred value -- Otherwise it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: _getItemLangCode() ------------------------------------------------------------------------------- p.getItemLangCode = function(frame) return _getItemLangCode(frame.args.qid or frame.args[1]) end ------------------------------------------------------------------------------- -- findLanguage exports the local findLang() function -- It takes an optional language code and returns, in order of preference: -- the code if a known language; -- the user's language, if set; -- the server's content language. ------------------------------------------------------------------------------- -- Dependencies: findLang ------------------------------------------------------------------------------- p.findLanguage = function(frame) return findLang(frame.args.lang or frame.args[1]).code end ------------------------------------------------------------------------------- -- getQid returns the qid, if supplied -- failing that, the Wikidata entity ID of the "category's main topic (P301)", if it exists -- failing that, the Wikidata entity ID associated with the current page, if it exists -- otherwise, nothing ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getQid = function(frame) local qid = (frame.args.qid or ""):upper() -- check if a qid was passed; if so, return it: if qid ~= "" then return qid end -- check if there's a "category's main topic (P301)": qid = mw.wikibase.getEntityIdForCurrentPage() if qid then local prop301 = mw.wikibase.getBestStatements(qid, "P301") if prop301[1] then local mctid = prop301[1].mainsnak.datavalue.value.id if mctid then return mctid end end end -- otherwise return the page qid (if any) return qid end ------------------------------------------------------------------------------- -- followQid takes four optional parameters: qid, props, list and all. -- If qid is not given, it uses the qid for the connected page -- or returns nil if there isn't one. -- props is a list of properties, separated by punctuation. -- If props is given, the Wikidata item for the qid is examined for each property in turn. -- If that property contains a value that is another Wikibase-item, that item's qid is returned, -- and the search terminates, unless |all=y when all of the qids are returned, separated by spaces. -- If |list= is set to a template, the qids are passed as arguments to the template. -- If props is not given, the qid is returned. ------------------------------------------------------------------------------- -- Dependencies: parseParam() ------------------------------------------------------------------------------- p._followQid = function(args) local qid = (args.qid or ""):upper() local all = parseParam(args.all, false) local list = args.list or "" if list == "" then list = nil end if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end local out = {} local props = (args.props or ""):upper() if props ~= "" then for p in mw.text.gsplit(props, "%p") do -- split at punctuation and iterate p = mw.text.trim(p) for i, v in ipairs( mw.wikibase.getBestStatements(qid, p) ) do local linkedid = v.mainsnak.datavalue and v.mainsnak.datavalue.value.id if linkedid then if all then out[#out+1] = linkedid else return linkedid end -- test for all or just the first one found end -- test for value exists for that property end -- loop through values of property to follow end -- loop through list of properties to follow end if #out > 0 then local ret = "" if list then ret = mw.getCurrentFrame():expandTemplate{title = list, args = out} else ret = table.concat(out, " ") end return ret else return qid end end p.followQid = function(frame) return p._followQid(frame.args) end ------------------------------------------------------------------------------- -- globalSiteID returns the globalSiteID for the current wiki -- e.g. returns "enwiki" for the English Wikipedia, "enwikisource" for English Wikisource, etc. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.globalSiteID = function(frame) return mw.wikibase.getGlobalSiteId() end ------------------------------------------------------------------------------- -- siteID returns the root of the globalSiteID -- e.g. "en" for "enwiki", "enwikisource", etc. -- treats "en-gb" as "en", etc. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.siteID = function(frame) local txtlang = frame:preprocess( "{{int:lang}}" ) or "" -- This deals with specific exceptions: be-tarask -> be-x-old if txtlang == "be-tarask" then return "be_x_old" end local pos = txtlang:find("-") local ret = "" if pos then ret = txtlang:sub(1, pos-1) else ret = txtlang end return ret end ------------------------------------------------------------------------------- -- projID returns the code used to link to the reader's language's project -- e.g "en" for [[:en:WikidataIB]] -- treats "en-gb" as "en", etc. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.projID = function(frame) local txtlang = frame:preprocess( "{{int:lang}}" ) or "" -- This deals with specific exceptions: be-tarask -> be-x-old if txtlang == "be-tarask" then return "be-x-old" end local pos = txtlang:find("-") local ret = "" if pos then ret = txtlang:sub(1, pos-1) else ret = txtlang end return ret end ------------------------------------------------------------------------------- -- formatNumber formats a number according to the the supplied language code ("|lang=") -- or the default language if not supplied. -- The number is the first unnamed parameter or "|num=" ------------------------------------------------------------------------------- -- Dependencies: findLang() ------------------------------------------------------------------------------- p.formatNumber = function(frame) local lang local num = tonumber(frame.args[1] or frame.args.num) or 0 lang = findLang(frame.args.lang) return lang:formatNum( num ) end ------------------------------------------------------------------------------- -- examine dumps the property (the unnamed parameter or pid) -- from the item given by the parameter 'qid' (or the other unnamed parameter) -- or from the item corresponding to the current page if qid is not supplied. -- e.g. {{#invoke:WikidataIB |examine |pid=P26 |qid=Q42}} -- or {{#invoke:WikidataIB |examine |P26 |Q42}} or any combination of these -- or {{#invoke:WikidataIB |examine |P26}} for the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.examine = function( frame ) local args if frame.args[1] or frame.args.pid or frame.args.qid then args = frame.args else args = frame:getParent().args end local par = {} local pid = (args.pid or ""):upper() local qid = (args.qid or ""):upper() par[1] = mw.text.trim( args[1] or "" ):upper() par[2] = mw.text.trim( args[2] or "" ):upper() table.sort(par) if par[2]:sub(1,1) == "P" then par[1], par[2] = par[2], par[1] end if pid == "" then pid = par[1] end if qid == "" then qid = par[2] end local q1 = qid:sub(1,1) if pid:sub(1,1) ~= "P" then return "No property supplied" end if q1 ~= "Q" and q1 ~= "M" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return "No item for this page" end return "<pre>" .. mw.dumpObject( mw.wikibase.getAllStatements( qid, pid ) ) .. "</pre>" end ------------------------------------------------------------------------------- -- checkvalue looks for 'val' as a wikibase-item value of a property (the unnamed parameter or pid) -- from the item given by the parameter 'qid' -- or from the Wikidata item associated with the current page if qid is not supplied. -- It only checks ranks that are requested (preferred and normal by default) -- If property is not supplied, then P31 (instance of) is assumed. -- It returns val if found or nothing if not found. -- e.g. {{#invoke:WikidataIB |checkvalue |val=Q5 |pid=P31 |qid=Q42}} -- or {{#invoke:WikidataIB |checkvalue |val=Q5 |P31 |qid=Q42}} -- or {{#invoke:WikidataIB |checkvalue |val=Q5 |qid=Q42}} -- or {{#invoke:WikidataIB |checkvalue |val=Q5 |P31}} for the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.checkvalue = function( frame ) local args if frame.args.val then args = frame.args else args = frame:getParent().args end local val = args.val if not val then return nil end local pid = mw.text.trim(args.pid or args[1] or "P31"):upper() local qid = (args.qid or ""):upper() if pid:sub(1,1) ~= "P" then return nil end if qid:sub(1,1) ~= "Q" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end local ranks = setRanks(args.rank) local stats = {} if ranks.b then stats = mw.wikibase.getBestStatements(qid, pid) else stats = mw.wikibase.getAllStatements( qid, pid ) end if not stats[1] then return nil end if stats[1].mainsnak.datatype == "wikibase-item" then for k, v in pairs( stats ) do local ms = v.mainsnak if ranks[v.rank:sub(1,1)] and ms.snaktype == "value" and ms.datavalue.value.id == val then return val end end end return nil end ------------------------------------------------------------------------------- -- url2 takes a parameter url= that is a proper url and formats it for use in an infobox. -- If no parameter is supplied, it returns nothing. -- This is the equivalent of Template:URL -- but it keeps the "edit at Wikidata" pen icon out of the microformat. -- Usually it will take its url parameter directly from a Wikidata call: -- e.g. {{#invoke:WikidataIB |url2 |url={{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no}} }} ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.url2 = function(frame) local txt = frame.args.url or "" if txt == "" then return nil end -- extract any icon local url, icon = txt:match("(.+)&nbsp;(.+)") -- make sure there's at least a space at the end url = (url or txt) .. " " icon = icon or "" -- extract any protocol like https:// local prot = url:match("(https*://).+[ \"\']") -- extract address local addr = "" if prot then addr = url:match("https*://(.+)[ \"\']") or " " else prot = "//" addr = url:match("[^%p%s]+%.(.+)[ \"\']") or " " end -- strip trailing / from end of domain-only url and add <wbr/> before . and / local disp, n = addr:gsub( "^([^/]+)/$", "%1" ):gsub("%/", "<wbr/>/"):gsub("%.", "<wbr/>.") return '<span class="url">[' .. prot .. addr .. " " .. disp .. "]</span>&nbsp;" .. icon end ------------------------------------------------------------------------------- -- getWebsite fetches the Official website (P856) and formats it for use in an infobox. -- This is similar to Template:Official website but with a url displayed, -- and it adds the "edit at Wikidata" pen icon beyond the microformat if enabled. -- A local value will override the Wikidata value. "NONE" returns nothing. -- e.g. {{#invoke:WikidataIB |getWebsite |qid= |noicon= |lang= |url= }} ------------------------------------------------------------------------------- -- Dependencies: findLang(); parseParam(); ------------------------------------------------------------------------------- p.getWebsite = function(frame) local url = frame.args.url or "" if url:upper() == "NONE" then return nil end local qid = frame.args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end local urls = {} local quals = {} if url == "" then local prop856 = mw.wikibase.getBestStatements(qid, "P856") for k, v in pairs(prop856) do if v.mainsnak.snaktype == "value" then urls[#urls+1] = v.mainsnak.datavalue.value if v.qualifiers and v.qualifiers["P1065"] then -- just take the first archive url (P1065) local au = v.qualifiers["P1065"][1] if au.snaktype == "value" then quals[#urls] = au.datavalue.value end -- test for archive url having a value end -- test for qualifers end -- test for website having a value end -- loop through website(s) else urls[1] = url end if #urls == 0 then return nil end local out = {} for i, u in ipairs(urls) do local link = quals[i] or u local prot, addr = u:match("(http[s]*://)(.+)") addr = addr or u local disp, n = addr:gsub("%.", "<wbr/>%.") out[#out+1] = '<span class="url">[' .. link .. " " .. disp .. "]</span>" end local langcode = findLang(frame.args.lang).code local noicon = parseParam(frame.args.noicon, false) if url == "" and not noicon then out[#out] = out[#out] .. createicon(langcode, qid, "P856") end local ret = "" if #out > 1 then ret = mw.getCurrentFrame():expandTemplate{title = "ubl", args = out} else ret = out[1] end return ret end ------------------------------------------------------------------------------- -- getAllLabels fetches the set of labels and formats it for display as wikitext. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllLabels = function(frame) local args = frame.args or frame:getParent().args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local labels = mw.wikibase.getEntity(qid).labels if not labels then return i18n["labels-not-found"] end local out = {} for k, v in pairs(labels) do out[#out+1] = v.value .. " (" .. v.language .. ")" end return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- getAllDescriptions fetches the set of descriptions and formats it for display as wikitext. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllDescriptions = function(frame) local args = frame.args or frame:getParent().args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local descriptions = mw.wikibase.getEntity(qid).descriptions if not descriptions then return i18n["descriptions-not-found"] end local out = {} for k, v in pairs(descriptions) do out[#out+1] = v.value .. " (" .. v.language .. ")" end return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- getAllAliases fetches the set of aliases and formats it for display as wikitext. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllAliases = function(frame) local args = frame.args or frame:getParent().args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local aliases = mw.wikibase.getEntity(qid).aliases if not aliases then return i18n["aliases-not-found"] end local out = {} for k1, v1 in pairs(aliases) do local lang = v1[1].language local val = {} for k1, v2 in ipairs(v1) do val[#val+1] = v2.value end out[#out+1] = table.concat(val, ", ") .. " (" .. lang .. ")" end return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- showNoLinks displays the article titles that should not be linked. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.showNoLinks = function(frame) local out = {} for k, v in pairs(donotlink) do out[#out+1] = k end table.sort( out ) return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- checkValidity checks whether the first unnamed parameter represents a valid entity-id, -- that is, something like Q1235 or P123. -- It returns the strings "true" or "false". -- Change false to nil to return "true" or "" (easier to test with #if:). ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- function p.checkValidity(frame) local id = mw.text.trim(frame.args[1] or "") if mw.wikibase.isValidEntityId(id) then return true else return false end end ------------------------------------------------------------------------------- -- getEntityFromTitle returns the Entity-ID (Q-number) for a given title. -- Modification of Module:ResolveEntityId -- The title is the first unnamed parameter. -- The site parameter determines the site/language for the title. Defaults to current wiki. -- The showdab parameter determines whether dab pages should return the Q-number or nil. Defaults to true. -- Returns the Q-number or nil if it does not exist. ------------------------------------------------------------------------------- -- Dependencies: parseParam ------------------------------------------------------------------------------- function p.getEntityFromTitle(frame) local args=frame.args if not args[1] then args=frame:getParent().args end if not args[1] then return nil end local title = mw.text.trim(args[1]) local site = args.site or "" local showdab = parseParam(args.showdab, true) local qid = mw.wikibase.getEntityIdForTitle(title, site) if qid then local prop31 = mw.wikibase.getBestStatements(qid, "P31")[1] if not showdab and prop31 and prop31.mainsnak.datavalue.value.id == "Q4167410" then return nil else return qid end end end ------------------------------------------------------------------------------- -- getDatePrecision returns the number representing the precision of the first best date value -- for the given property. -- It takes the qid and property ID -- The meanings are given at https://www.mediawiki.org/wiki/Wikibase/DataModel#Dates_and_times -- 0 = 1 billion years .. 6 = millennium, 7 = century, 8 = decade, 9 = year, 10 = month, 11 = day -- Returns 0 (or the second unnamed parameter) if the Wikidata does not exist. ------------------------------------------------------------------------------- -- Dependencies: parseParam; sourced; ------------------------------------------------------------------------------- function p.getDatePrecision(frame) local args=frame.args if not args[1] then args=frame:getParent().args end local default = tonumber(args[2] or args.default) or 0 local prop = mw.text.trim(args[1] or "") if prop == "" then return default end local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return default end local onlysrc = parseParam(args.onlysourced or args.osd, true) local stat = mw.wikibase.getBestStatements(qid, prop) for i, v in ipairs(stat) do local prec = (onlysrc == false or sourced(v)) and v.mainsnak.datavalue and v.mainsnak.datavalue.value and v.mainsnak.datavalue.value.precision if prec then return prec end end return default end return p ------------------------------------------------------------------------------- -- List of exported functions ------------------------------------------------------------------------------- --[[ _getValue getValue getPreferredValue getCoords getQualifierValue getSumOfParts getValueByQual getValueByLang getValueByRefSource getPropertyIDs getQualifierIDs getPropOfProp getAwardCat getIntersectCat getGlobe getCommonsLink getSiteLink getLink getLabel label getAT getDescription getAliases pageId formatDate location checkBlacklist emptyor labelorid getLang getItemLangCode findLanguage getQID followQid globalSiteID siteID projID formatNumber examine checkvalue url2 getWebsite getAllLabels getAllDescriptions getAllAliases showNoLinks checkValidity getEntityFromTitle getDatePrecision --]] ------------------------------------------------------------------------------- eobwr534ab6am34lvqnxsnxucj0ssx6 390396 390395 2026-07-18T05:46:57Z محک 1023 آپدیت 390396 Scribunto text/plain -- Version: 2023-07-10 - معدلة محليًا -- Module to implement use of a blacklist and whitelist for infobox fields -- Can take a named parameter |qid which is the Wikidata ID for the article -- if not supplied, it will use the Wikidata ID associated with the current page. -- Fields in blacklist are never to be displayed, i.e. module must return nil in all circumstances -- Fields in whitelist return local value if it exists or the Wikidata value otherwise -- The name of the field that this function is called from is passed in named parameter |name -- The name is compulsory when blacklist or whitelist is used, -- so the module returns nil if it is not supplied. -- blacklist is passed in named parameter |suppressfields (or |spf) -- whitelist is passed in named parameter |fetchwikidata (or |fwd) require("strict") local p = {} local cdate -- initialise as nil and only load _complex_date function if needed -- Module:Complex date is loaded lazily and has the following dependencies: -- Module:Calendar -- Module:ISOdate -- Module:DateI18n -- Module:I18n/complex date -- Module:Ordinal -- Module:I18n/ordinal -- Module:Yesno -- Module:Formatnum -- Module:Linguistic -- -- The following, taken from https://www.mediawiki.org/wiki/Wikibase/DataModel#Dates_and_times, -- is needed to use Module:Complex date which seemingly requires date precision as a string. -- It would work better if only the authors of the mediawiki page could spell 'millennium'. local dp = { [6] = "millennium", [7] = "century", [8] = "decade", [9] = "year", [10] = "month", [11] = "day", } local i18n = { ["errors"] = { ["property-not-found"] = "خاصیه پیدا نی‌یه.", ["No property supplied"] = "خاصیه تأمین نوه", ["entity-not-found"] = "مدخل ویکی دیتا دله پیدا نی‌یه.", ["unknown-claim-type"] = "اینتی ادعا نشناسمبی.", ["unknown-entity-type"] = "اینتی مدخل نشناسمبی.", ["qualifier-not-found"] = "هوجی‌کر پیدا نی‌یه.", ["site-not-found"] = "سایت پیدا نی‌یه.", ["labels-not-found"] = "برچسب پیدا نی‌یه.", ["descriptions-not-found"] = "توضیحات پیدا نی‌یه.", ["aliases-not-found"] = "جایگزین پیدا نی‌یه.", ["unknown-datetime-format"] = "وقت و زمون فورمت خرابه.", ["local-article-not-found"] = "محلی مقاله پیدا نی‌یه", ["dab-page"] = " (توضیح)" }, ["months"] = { "ژانویه", "فوریه", "مارس", "آوریل", "مه", "ژوئن", "ژوئیه", "آگوست", "سپتامبر", "اکتبر", "نوامبر", "دسامبر" }, ["century"] = "century", ["BC"] = "BC", ["BCE"] = "BCE", ["ordinal"] = { [1] = "", [2] = "", [3] = "", ["default"] = "" }, ["filespace"] = "File", ["Unknown"] = "Unknown", ["NaN"] = "Not a number", -- set the following to the name of a tracking category, -- e.g. "[[رج:Articles with missing Wikidata information]]", or "" to disable: ["missinginfocat"] = "[[رج:Articles with missing Wikidata information]]", ["editonwikidata"] = "Edit this on Wikidata", ["latestdatequalifier"] = function (date) return "before " .. date end, -- some languages, e.g. Bosnian use a period as a suffix after each number in a date ["datenumbersuffix"] = "", ["list separator"] = ", ", ["list separator-ar"] = "، ", ["multipliers"] = { [0] = "", [3] = " thousand", [6] = " million", [9] = " billion", [12] = " trillion", } } -- This allows an internationisation module to override the above table if 'en' ~= mw.getContentLanguage():getCode() then require("Module:i18n").loadI18n("Module:WikidataIB/i18n", i18n) end -- This piece of html implements a collapsible container. Check the classes exist on your wiki. local collapsediv = '<div class="mw-collapsible mw-collapsed" style="width:100%; overflow:auto;" data-expandtext="{{int:show}}" data-collapsetext="{{int:hide}}">' -- Some items should not be linked. -- Each wiki can create a list of those in Module:WikidataIB/nolinks -- It should return a table called itemsindex, containing true for each item not to be linked local donotlink = {} local nolinks_exists, nolinks = pcall(mw.loadData, "Module:WikidataIB/nolinks") if nolinks_exists then donotlink = nolinks.itemsindex end -- To satisfy Wikipedia:Manual of Style/Titles, certain types of items are italicised, and others are quoted. -- The submodule [[Module:WikidataIB/titleformats]] lists the entity-ids used in 'instance of' (P31), -- which allows this module to identify the values that should be formatted. -- WikidataIB/titleformats exports a table p.formats, which is indexed by entity-id, and contains the value " or '' local formats = {} local titleformats_exists, titleformats = pcall(mw.loadData, "Module:WikidataIB/titleformats") if titleformats_exists then formats = titleformats.formats end ------------------------------------------------------------------------------- -- Private functions ------------------------------------------------------------------------------- -- ------------------------------------------------------------------------------- -- makeOrdinal needs to be internationalised along with the above: -- takes cardinal number as a numeric and returns the ordinal as a string -- we need three exceptions in English for 1st, 2nd, 3rd, 21st, .. 31st, etc. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local makeOrdinal = function(cardinal) local ordsuffix = i18n.ordinal.default if cardinal % 10 == 1 then ordsuffix = i18n.ordinal[1] elseif cardinal % 10 == 2 then ordsuffix = i18n.ordinal[2] elseif cardinal % 10 == 3 then ordsuffix = i18n.ordinal[3] end -- In English, 1, 21, 31, etc. use 'st', but 11, 111, etc. use 'th' -- similarly for 12 and 13, etc. if (cardinal % 100 == 11) or (cardinal % 100 == 12) or (cardinal % 100 == 13) then ordsuffix = i18n.ordinal.default end return tostring(cardinal) .. ordsuffix end ------------------------------------------------------------------------------- -- findLang takes a "langcode" parameter if supplied and valid -- otherwise it tries to create it from the user's set language ({{int:lang}}) -- failing that it uses the wiki's content language. -- It returns a language object ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local findLang = function(langcode) local langobj langcode = mw.text.trim(langcode or "") if mw.language.isKnownLanguageTag(langcode) then langobj = mw.language.new( langcode ) else langcode = mw.getCurrentFrame():callParserFunction('int', {'lang'}) if mw.language.isKnownLanguageTag(langcode) then langobj = mw.language.new( langcode ) else langobj = mw.language.getContentLanguage() end end return langobj end ------------------------------------------------------------------------------- -- _getItemLangCode takes a qid parameter (using the current page's qid if blank) -- If the item for that qid has property country (P17) it looks at the first preferred value -- If the country has an official language (P37), it looks at the first preferred value -- If that official language has a language code (P424), it returns the first preferred value -- Otherwise it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local _getItemLangCode = function(qid) qid = mw.text.trim(qid or ""):upper() if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return end local prop17 = mw.wikibase.getBestStatements(qid, "P17")[1] if not prop17 or prop17.mainsnak.snaktype ~= "value" then return end local qid17 = prop17.mainsnak.datavalue.value.id local prop37 = mw.wikibase.getBestStatements(qid17, "P37")[1] if not prop37 or prop37.mainsnak.snaktype ~= "value" then return end local qid37 = prop37.mainsnak.datavalue.value.id local prop424 = mw.wikibase.getBestStatements(qid37, "P424")[1] if not prop424 or prop424.mainsnak.snaktype ~= "value" then return end return prop424.mainsnak.datavalue.value end ------------------------------------------------------------------------------- -- roundto takes a number (x) -- and returns it rounded to (sf) significant figures ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local roundto = function(x, sf) if x == 0 then return 0 end local s = 1 if x < 0 then x = -x s = -1 end if sf < 1 then sf = 1 end local p = 10 ^ (math.floor(math.log10(x)) - sf + 1) x = math.floor(x / p + 0.5) * p * s -- if it's integral, cast to an integer: if x == math.floor(x) then x = math.floor(x) end return x end ------------------------------------------------------------------------------- -- decimalToDMS takes a decimal degrees (x) with precision (p) -- and returns degrees/minutes/seconds according to the precision ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local decimalToDMS = function(x, p) -- if p is not supplied, use a precision around 0.1 seconds if not tonumber(p) then p = 1e-4 end local d = math.floor(x) local ms = (x - d) * 60 if p > 0.5 then -- precision is > 1/2 a degree if ms > 30 then d = d + 1 end ms = 0 end local m = math.floor(ms) local s = (ms - m) * 60 if p > 0.008 then -- precision is > 1/2 a minute if s > 30 then m = m +1 end s = 0 elseif p > 0.00014 then -- precision is > 1/2 a second s = math.floor(s + 0.5) elseif p > 0.000014 then -- precision is > 1/20 second s = math.floor(10 * s + 0.5) / 10 elseif p > 0.0000014 then -- precision is > 1/200 second s = math.floor(100 * s + 0.5) / 100 else -- cap it at 3 dec places for now s = math.floor(1000 * s + 0.5) / 1000 end return d, m, s end ------------------------------------------------------------------------------- -- decimalPrecision takes a decimal (x) with precision (p) -- and returns x rounded approximately to the given precision -- precision should be between 1 and 1e-6, preferably a power of 10. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local decimalPrecision = function(x, p) local s = 1 if x < 0 then x = -x s = -1 end -- if p is not supplied, pick an arbitrary precision if not tonumber(p) then p = 1e-4 elseif p > 1 then p = 1 elseif p < 1e-6 then p = 1e-6 else p = 10 ^ math.floor(math.log10(p)) end x = math.floor(x / p + 0.5) * p * s -- if it's integral, cast to an integer: if x == math.floor(x) then x = math.floor(x) end -- if it's less than 1e-4, it will be in exponent form, so return a string with 6dp -- 9e-5 becomes 0.000090 if math.abs(x) < 1e-4 then x = string.format("%f", x) end return x end ------------------------------------------------------------------------------- -- formatDate takes a datetime of the usual format from mw.wikibase.entity:formatPropertyValues -- like "1 August 30 BCE" as parameter 1 -- and formats it according to the df (date format) and bc parameters -- df = ["dmy" / "mdy" / "y"] default will be "dmy" -- bc = ["BC" / "BCE"] default will be "BCE" ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local format_Date = function(datetime, dateformat, bc) local datetime = datetime or "1 August 30 BCE" -- in case of nil value -- chop off multiple vales and/or any hours, mins, etc. -- keep anything before punctuation - we just want a single date: local dateval = string.match( datetime, "[%w ]+") local dateformat = string.lower(dateformat or "dmy") -- default to dmy local bc = string.upper(bc or "") -- can't use nil for bc -- we only want to accept two possibilities: BC or default to BCE if bc == "BC" then bc = "&nbsp;" .. i18n["BC"] -- prepend a non-breaking space. else bc = "&nbsp;" .. i18n["BCE"] end local postchrist = true -- start by assuming no BCE local dateparts = {} for word in string.gmatch(dateval, "%w+") do if word == "BCE" or word == "BC" then -- *** internationalise later *** postchrist = false else -- we'll keep the parts that are not 'BCE' in a table dateparts[#dateparts + 1] = word end end if postchrist then bc = "" end -- set AD dates to no suffix *** internationalise later *** local sep = "&nbsp;" -- separator is nbsp local fdate = table.concat(dateparts, sep) -- set formatted date to same order as input -- if we have day month year, check dateformat if #dateparts == 3 then if dateformat == "y" then fdate = dateparts[3] elseif dateformat == "mdy" then fdate = dateparts[2] .. sep .. dateparts[1] .. "," .. sep .. dateparts[3] end elseif #dateparts == 2 and dateformat == "y" then fdate = dateparts[2] end return fdate .. bc end ------------------------------------------------------------------------------- -- dateFormat is the handler for properties that are of type "time" -- It takes timestamp, precision (6 to 11 per mediawiki), dateformat (y/dmy/mdy), BC format (BC/BCE), -- a plaindate switch (yes/no/adj) to en/disable "sourcing circumstances"/use adjectival form, -- any qualifiers for the property, the language, and any adjective to use like 'before'. -- It passes the date through the "complex date" function -- and returns a string with the internatonalised date formatted according to preferences. ------------------------------------------------------------------------------- -- Dependencies: findLang(); cdate(); dp[] ------------------------------------------------------------------------------- local dateFormat = function(timestamp, dprec, df, bcf, pd, qualifiers, lang, adj, model) -- output formatting according to preferences (y/dmy/mdy/ymd) df = (df or ""):lower() -- if ymd is required, return the part of the timestamp in YYYY-MM-DD form -- but apply Year zero#Astronomers fix: 1 BC = 0000; 2 BC = -0001; etc. if df == "ymd" then if timestamp:sub(1,1) == "+" then return timestamp:sub(2,11) else local yr = tonumber(timestamp:sub(2,5)) - 1 yr = ("000" .. yr):sub(-4) if yr ~= "0000" then yr = "-" .. yr end return yr .. timestamp:sub(6,11) end end -- A year can be stored like this: "+1872-00-00T00:00:00Z", -- which is processed here as if it were the day before "+1872-01-01T00:00:00Z", -- and that's the last day of 1871, so the year is wrong. -- So fix the month 0, day 0 timestamp to become 1 January instead: timestamp = timestamp:gsub("%-00%-00T", "-01-01T") -- just in case date precision is missing dprec = dprec or 11 -- override more precise dates if required dateformat is year alone: if df == "y" and dprec > 9 then dprec = 9 end -- complex date only deals with precisions from 6 to 11, so clip range dprec = dprec>11 and 11 or dprec dprec = dprec<6 and 6 or dprec -- BC format is "BC" or "BCE" bcf = (bcf or ""):upper() -- plaindate only needs the first letter (y/n/a) pd = (pd or ""):sub(1,1):lower() if pd == "" or pd == "n" or pd == "f" or pd == "0" then pd = false end -- in case language isn't passed lang = lang or findLang().code -- set adj as empty if nil adj = adj or "" -- extract the day, month, year from the timestamp local bc = timestamp:sub(1, 1)=="-" and "BC" or "" local year, month, day = timestamp:match("[+-](%d*)-(%d*)-(%d*)T") local iso = tonumber(year) -- if year is missing, let it throw an error -- this will adjust the date format to be compatible with cdate -- possible formats are Y, YY, YYY0, YYYY, YYYY-MM, YYYY-MM-DD if dprec == 6 then iso = math.floor( (iso - 1) / 1000 ) + 1 end if dprec == 7 then iso = math.floor( (iso - 1) / 100 ) + 1 end if dprec == 8 then iso = math.floor( iso / 10 ) .. "0" end if dprec == 10 then iso = year .. "-" .. month end if dprec == 11 then iso = year .. "-" .. month .. "-" .. day end -- add "circa" (Q5727902) from "sourcing circumstances" (P1480) local sc = not pd and qualifiers and qualifiers.P1480 if sc then for k1, v1 in pairs(sc) do if v1.datavalue and v1.datavalue.value.id == "Q5727902" then adj = "circa" break end end end -- deal with Julian dates: -- no point in saying that dates before 1582 are Julian - they are by default -- doesn't make sense for dates less precise than year -- we can suppress it by setting |plaindate, e.g. for use in constructing categories. local calendarmodel = "" if tonumber(year) > 1582 and dprec > 8 and not pd and model == "http://www.wikidata.org/entity/Q1985786" then calendarmodel = "julian" end if not cdate then cdate = require("Module:Complex date")._complex_date end local fdate = cdate(calendarmodel, adj, tostring(iso), dp[dprec], bc, "", "", "", "", lang, 1) -- this may have QuickStatements info appended to it in a div, so remove that fdate = fdate:gsub(' <div style="display: none;">[^<]*</div>', '') -- it may also be returned wrapped in a microformat, so remove that fdate = fdate:gsub("<[^>]*>", "") -- there may be leading zeros that we should remove fdate = fdate:gsub("^0*", "") -- if a plain date is required, then remove any links (like BC linked) if pd then fdate = fdate:gsub("%[%[.*|", ""):gsub("]]", "") end -- if 'circa', use the abbreviated form *** internationalise later *** fdate = fdate:gsub('circa ', '<abbr title="circa">c.</abbr>&nbsp;') -- deal with BC/BCE if bcf == "BCE" then fdate = fdate:gsub('BC', 'BCE') end -- deal with mdy format if df == "mdy" then fdate = fdate:gsub("(%d+) (%w+) (%d+)", "%2 %1, %3") end -- deal with adjectival form *** internationalise later *** if pd == "a" then fdate = fdate:gsub(' century', '-century') end return fdate end ------------------------------------------------------------------------------- -- parseParam takes a (string) parameter, e.g. from the list of frame arguments, -- and makes "false", "no", and "0" into the (boolean) false -- it makes the empty string and nil into the (boolean) value passed as default -- allowing the parameter to be true or false by default. -- It returns a boolean. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local parseParam = function(param, default) if type(param) == "boolean" then param = tostring(param) end if param and param ~= "" then param = param:lower() if (param == "false") or (param:sub(1,1) == "n") or (param == "0") then return false else return true end else return default end end ------------------------------------------------------------------------------- -- _getSitelink takes the qid of a Wikidata entity passed as |qid= -- It takes an optional parameter |wiki= to determine which wiki is to be checked for a sitelink -- If the parameter is blank, then it uses the local wiki. -- If there is a sitelink to an article available, it returns the plain text link to the article -- If there is no sitelink, it returns nil. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local _getSitelink = function(qid, wiki) qid = (qid or ""):upper() if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end wiki = wiki or "" local sitelink if wiki == "" then sitelink = mw.wikibase.getSitelink(qid) else sitelink = mw.wikibase.getSitelink(qid, wiki) end return sitelink end ------------------------------------------------------------------------------- -- _getCommonslink takes an optional qid of a Wikidata entity passed as |qid= -- It returns one of the following in order of preference: -- the Commons sitelink of the Wikidata entity - but not if onlycat=true and it's not a category; -- the Commons sitelink of the topic's main category of the Wikidata entity; -- the Commons category of the Wikidata entity - unless fallback=false. ------------------------------------------------------------------------------- -- Dependencies: _getSitelink(); parseParam() ------------------------------------------------------------------------------- local _getCommonslink = function(qid, onlycat, fallback) qid = (qid or ""):upper() if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end onlycat = parseParam(onlycat, false) if fallback == "" then fallback = nil end local sitelink = _getSitelink(qid, "commonswiki") if onlycat and sitelink and sitelink:sub(1,9) ~= "Category:" then sitelink = nil end if not sitelink then -- check for topic's main category local prop910 = mw.wikibase.getBestStatements(qid, "P910")[1] if prop910 then local tmcid = prop910.mainsnak.datavalue and prop910.mainsnak.datavalue.value.id sitelink = _getSitelink(tmcid, "commonswiki") end if not sitelink then -- check for list's main category local prop1754 = mw.wikibase.getBestStatements(qid, "P1754")[1] if prop1754 then local tmcid = prop1754.mainsnak.datavalue and prop1754.mainsnak.datavalue.value.id sitelink = _getSitelink(tmcid, "commonswiki") end end end if not sitelink and fallback then -- check for Commons category (string value) local prop373 = mw.wikibase.getBestStatements(qid, "P373")[1] if prop373 then sitelink = prop373.mainsnak.datavalue and prop373.mainsnak.datavalue.value if sitelink then sitelink = "Category:" .. sitelink end end end return sitelink end ------------------------------------------------------------------------------- -- The label in a Wikidata item is subject to vulnerabilities -- that an attacker might try to exploit. -- It needs to be 'sanitised' by removing any wikitext before use. -- If it doesn't exist, return the id for the item -- a second (boolean) value is also returned, value is true when the label exists ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local labelOrId = function(id, lang) if lang == "default" then lang = findLang().code end local label if lang then label = mw.wikibase.getLabelByLang(id, lang) end if not label then local trylang = {"ar","en","fr"} local triedlang = lang for _,lang in pairs(trylang) do if triedlang ~= lang then label = mw.wikibase.getLabelByLang(id, lang) if label ~= "" then break; end end end end if label then return mw.text.nowiki(label), true else return id, false end end ------------------------------------------------------------------------------- -- linkedItem takes an entity-id and returns a string, linked if possible. -- This is the handler for "wikibase-item". Preferences: -- 1. Display linked disambiguated sitelink if it exists -- 2. Display linked label if it is a redirect -- 3. TBA: Display an inter-language link for the label if it exists other than in default language -- 4. Display unlinked label if it exists -- 5. Display entity-id for now to indicate a label could be provided -- dtxt is text to be used instead of label, or nil. -- shortname is boolean switch to use P1813 (short name) instead of label if true. -- lang is the current language code. -- uselbl is boolean switch to force display of the label instead of the sitelink (default: false) -- linkredir is boolean switch to allow linking to a redirect (default: false) -- formatvalue is boolean switch to allow formatting as italics or quoted (default: false) ------------------------------------------------------------------------------- -- Dependencies: labelOrId(); donotlink[] ------------------------------------------------------------------------------- local linkedItem = function(id, args) local lprefix = (args.lp or args.lprefix or args.linkprefix or ""):gsub('"', '') -- toughen against nil values passed local lpostfix = (args.lpostfix or ""):gsub('"', '') local prefix = (args.prefix or ""):gsub('"', '') local postfix = (args.postfix or ""):gsub('"', '') local dtxt = args.dtxt local shortname = args.shortname or args.sn --#Modifed line local lang = args.lang or "ar" -- fallback to default if missing local uselbl = args.uselabel or args.uselbl --#Modifed line uselbl = parseParam(uselbl, true) local linkredir = args.linkredir linkredir = parseParam(linkredir, false) local formatvalue = args.formatvalue or args.fv formatvalue = parseParam(formatvalue, false) -- see if item might need italics or quotes local fmt = "" if next(formats) and formatvalue then for k, v in ipairs( mw.wikibase.getBestStatements(id, "P31") ) do if v.mainsnak.datavalue and formats[v.mainsnak.datavalue.value.id] then fmt = formats[v.mainsnak.datavalue.value.id] break -- pick the first match end end end local disp local sitelink = mw.wikibase.getSitelink(id) local label, islabel if dtxt then label, islabel = dtxt, true elseif shortname then -- see if there is a shortname in our language, and set label to it for k, v in ipairs( mw.wikibase.getBestStatements(id, "P1813") ) do if v.mainsnak.datavalue.value.language == lang then label, islabel = v.mainsnak.datavalue.value.text, true break end -- test for language match end -- loop through values of short name -- if we have no label set, then there was no shortname available if not islabel then --#Modifed line label, islabel = labelOrId(id, args.lang) shortname = false end else --#Modifed line label, islabel = labelOrId(id, args.lang) end if mw.site.siteName ~= "Wikimedia Commons" then if sitelink then if not (dtxt or shortname) then -- if sitelink and label are the same except for case, no need to process further if sitelink:lower() ~= label:lower() then -- strip any namespace or dab from the sitelink local pos = sitelink:find(":") or 0 local slink = sitelink if pos > 0 then local pfx = sitelink:sub(1,pos-1) if mw.site.namespaces[pfx] then -- that prefix is a valid namespace, so remove it slink = sitelink:sub(pos+1) end end -- remove stuff after commas or inside parentheses - ie. dabs slink = slink:gsub("%s%(.+%)$", ""):gsub(",.+$", "") -- if uselbl is false, use sitelink instead of label if not uselbl then -- use slink as display, preserving label case - find("^%u") is true for 1st char uppercase if label:find("^%u") then label = slink:gsub("^(%l)", string.upper) else label = slink:gsub("^(%u)", string.lower) end end end end if donotlink[label] then disp = prefix .. fmt .. label .. fmt .. postfix else disp = "[[" .. lprefix .. sitelink .. lpostfix .. "|" .. prefix .. fmt .. label .. fmt .. postfix .. "]]" end elseif islabel then -- no sitelink, label exists, so check if a redirect with that title exists, if linkredir is true -- display plain label by default disp = prefix .. fmt .. label .. fmt .. postfix if linkredir then local artitle = mw.title.new(label, 0) -- only nil if label has invalid chars if not donotlink[label] and artitle and artitle.redirectTarget then -- there's a redirect with the same title as the label, so let's link to that disp = "[[".. lprefix .. label .. lpostfix .. "|" .. prefix .. fmt .. label .. fmt .. postfix .. "]]" end end -- test if article title exists as redirect on current Wiki else -- no sitelink and no label, so return whatever was returned from labelOrId for now -- add tracking category [[تصنيف:Articles with missing Wikidata information]] -- for enwiki, just return the tracking category if mw.wikibase.getGlobalSiteId() == "enwiki" then disp = i18n.missinginfocat else disp = prefix .. label .. postfix .. i18n.missinginfocat end end else local ccat = mw.wikibase.getBestStatements(id, "P373")[1] if ccat and ccat.mainsnak.datavalue then ccat = ccat.mainsnak.datavalue.value disp = "[[" .. lprefix .. "Category:" .. ccat .. lpostfix .. "|" .. prefix .. label .. postfix .. "]]" elseif sitelink then -- this asumes that if a sitelink exists, then a label also exists disp = "[[" .. lprefix .. sitelink .. lpostfix .. "|" .. prefix .. label .. postfix .. "]]" else -- no sitelink and no Commons cat, so return label from labelOrId for now disp = prefix .. label .. postfix end end return disp end ------------------------------------------------------------------------------- -- sourced takes a table representing a statement that may or may not have references -- it looks for a reference sourced to something not containing the word "wikipedia" -- it returns a boolean = true if it finds a sourced reference. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local sourced = function(claim) if claim.references then for kr, vr in pairs(claim.references) do local ref = mw.wikibase.renderSnaks(vr.snaks) if not ref:find("Wiki") then return true end end end end ------------------------------------------------------------------------------- -- setRanks takes a flag (parameter passed) that requests the values to return -- "b[est]" returns preferred if available, otherwise normal -- "p[referred]" returns preferred -- "n[ormal]" returns normal -- "d[eprecated]" returns deprecated -- multiple values are allowed, e.g. "preferred normal" (which is the default) -- "best" will override the other flags, and set p and n ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local setRanks = function(rank) rank = (rank or ""):lower() -- if nothing passed, return preferred and normal -- if rank == "" then rank = "p n" end local ranks = {} for w in string.gmatch(rank, "%a+") do w = w:sub(1,1) if w == "b" or w == "p" or w == "n" or w == "d" then ranks[w] = true end end -- check if "best" is requested or no ranks requested; and if so, set preferred and normal if ranks.b or not next(ranks) then ranks.p = true ranks.n = true end return ranks end ------------------------------------------------------------------------------- -- parseInput processes the Q-id , the blacklist and the whitelist -- if an input parameter is supplied, it returns that and ends the call. -- it returns (1) either the qid or nil indicating whether or not the call should continue -- and (2) a table containing all of the statements for the propertyID and relevant Qid -- if "best" ranks are requested, it returns those instead of all non-deprecated ranks ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- local parseInput = function(frame, input_parm, property_id) -- There may be a local parameter supplied, if it's blank, set it to nil input_parm = mw.text.trim(input_parm or "") if input_parm == "" then input_parm = nil end -- return nil if Wikidata is not available if not mw.wikibase then return false, input_parm end local args = frame.args --#added block local refsnak = args.snak if refsnak == "" then refsnak = nil end -- can take a named parameter |qid which is the Wikidata ID for the article. -- if it's not supplied, use the id for the current page local qid = args.qid or "" --#Modified line if qid == "" and not refsnak then qid = mw.wikibase.getEntityIdForCurrentPage() end -- if there's no Wikidata item for the current page return nil --#Modified line if not qid and not refsnak then return false, input_parm end -- The blacklist is passed in named parameter |suppressfields local blacklist = args.suppressfields or args.spf or "" -- The whitelist is passed in named parameter |fetchwikidata local whitelist = args.fetchwikidata or args.fwd or "" if whitelist == "" then whitelist = "NONE" end -- The name of the field that this function is called from is passed in named parameter |name local fieldname = args.name or "" if blacklist ~= "" then -- The name is compulsory when blacklist is used, so return nil if it is not supplied if fieldname == "" then return false, nil end -- If this field is on the blacklist, then return nil if blacklist:find(fieldname) then return false, nil end end -- If we got this far then we're not on the blacklist -- The blacklist overrides any locally supplied parameter as well -- If a non-blank input parameter was supplied return it if input_parm then return false, input_parm end -- We can filter out non-valid properties if property_id:sub(1,1):upper() ~="P" or property_id == "P0" then return false, nil end -- Otherwise see if this field is on the whitelist: -- needs a bit more logic because find will return its second value = 0 if fieldname is "" -- but nil if fieldname not found on whitelist local _, found = whitelist:find(fieldname) found = ((found or 0) > 0) if whitelist ~= 'ALL' and (whitelist:upper() == "NONE" or not found) then return false, nil end -- See what's on Wikidata (the call always returns a table, but it may be empty): local props = {} if refsnak then props = refsnak[property_id] or {} end if not props[1] then if args.reqranks.b then props = mw.wikibase.getBestStatements(qid, property_id) else props = mw.wikibase.getAllStatements(qid, property_id) end end if props[1] then return qid, props end -- no property on Wikidata return false, nil end ------------------------------------------------------------------------------- -- createicon assembles the "Edit at Wikidata" pen icon. -- It returns a wikitext string inside a span class="penicon" -- if entityID is nil or empty, the ID associated with current page is used -- langcode and propertyID may be nil or empty ------------------------------------------------------------------------------- -- Dependencies: i18n[]; ------------------------------------------------------------------------------- local createicon = function(langcode, entityID, propertyID) langcode = langcode or "" if not entityID or entityID == "" then entityID= mw.wikibase.getEntityIdForCurrentPage() end propertyID = propertyID or "" local icon = "&nbsp;<span class='penicon autoconfirmed-show'>[[" -- "&nbsp;<span data-bridge-edit-flow='overwrite' class='penicon'>[[" -> enable Wikidata Bridge .. i18n["filespace"] .. ":OOjs UI icon edit-ltr-progressive.svg |frameless |text-top |10px |alt=" .. i18n["editonwikidata"] .. "|link=https://www.wikidata.org/wiki/" .. entityID if langcode ~= "" then icon = icon .. "?uselang=" .. langcode end if propertyID ~= "" then icon = icon .. "#" .. propertyID end icon = icon .. "|" .. i18n["editonwikidata"] .. "]]</span>" return icon end ------------------------------------------------------------------------------- -- assembleoutput takes the sequence table containing the property values -- and formats it according to switches given. It returns a string or nil. -- It uses the entityID (and optionally propertyID) to create a link in the pen icon. ------------------------------------------------------------------------------- -- Dependencies: parseParam(); ------------------------------------------------------------------------------- local assembleoutput = function(out, args, entityID, propertyID) -- sorted is a boolean passed to enable sorting of the values returned -- if nothing or an empty string is passed set it false -- if "false" or "no" or "0" is passed set it false local sorted = parseParam(args.sorted, false) -- noicon is a boolean passed to suppress the trailing "edit at Wikidata" icon -- for use when the value is processed further by the infobox -- if nothing or an empty string is passed set it false -- if "false" or "no" or "0" is passed set it false local noic = parseParam(args.noicon, false) -- list is the name of a template that a list of multiple values is passed through -- examples include "hlist" and "ubl" -- setting it to "prose" produces something like "1, 2, 3, and 4" local list = args.list or "" -- sep is a string that is used to separate multiple returned values -- if nothing or an empty string is passed set it to the default -- any double-quotes " are stripped out, so that spaces may be passed -- e.g. |sep=" - " local sepdefault = i18n["list separator"] --#Added Block local rtl_lang = {ar = true, fa = true, ur = true, ku = true, he = true, arc = true, dv = true, ha = true, khw = true, ks = true, ps = true, yi = true } if rtl_lang[args.lang] then sepdefault = i18n["list separator-ar"] end local separator = args.sep or "" separator = string.gsub(separator, '"', '') if separator == "" then separator = sepdefault end -- collapse is a number that determines the maximum number of returned values -- before the output is collapsed. -- Zero or not a number result in no collapsing (default becomes 0). local collapse = tonumber(args.collapse) or 0 -- replacetext (rt) is a string that is returned instead of any non-empty Wikidata value -- this is useful for tracking and debugging local replacetext = mw.text.trim(args.rt or args.replacetext or "") -- if there's anything to return, then return a list -- comma-separated by default, but may be specified by the sep parameter -- optionally specify a hlist or ubl or a prose list, etc. local strout if #out > 0 then if sorted then table.sort(out) end -- if there's something to display and a pen icon is wanted, add it the end of the last value local hasdisplay = false for i, v in ipairs(out) do if v ~= i18n.missinginfocat then hasdisplay = true break end end if not noic and hasdisplay then out[#out] = out[#out] .. createicon(args.langobj.code, entityID, propertyID) end if list == "" then strout = table.concat(out, separator) elseif list:lower() == "prose" then strout = mw.text.listToText( out ) else strout = mw.getCurrentFrame():expandTemplate{title = list, args = out} end if collapse >0 and #out > collapse then strout = collapsediv .. strout .. "</div>" end else strout = nil -- no items had valid reference end if replacetext ~= "" and strout then strout = replacetext end return strout end ------------------------------------------------------------------------------- -- rendersnak takes a table (propval) containing the information stored on one property value -- and returns the value as a string and its language if monolingual text. -- It handles data of type: -- wikibase-item -- time -- string, url, commonsMedia, external-id -- quantity -- globe-coordinate -- monolingualtext -- It also requires linked, the link/pre/postfixes, uabbr, and the arguments passed from frame. -- The optional filter parameter allows quantities to be be filtered by unit Qid. ------------------------------------------------------------------------------- -- Dependencies: parseParam(); labelOrId(); i18n[]; dateFormat(); -- roundto(); decimalPrecision(); decimalToDMS(); linkedItem(); ------------------------------------------------------------------------------- local rendersnak = function(propval, args, linked, lpre, lpost, pre, post, uabbr, filter) lpre = lpre or "" lpost = lpost or "" pre = pre or "" post = post or "" args.lang = args.lang or findLang().code -- allow values to display a fixed text instead of label local dtxt = args.displaytext or args.dt if dtxt == "" then dtxt = nil end -- switch to use display of short name (P1813) instead of label local shortname = args.shortname or args.sn shortname = parseParam(shortname, false) local snak = propval.mainsnak or propval local dtype = snak.datatype local dv = snak.datavalue dv = dv and dv.value -- value and monolingual text language code returned local val, mlt if propval.rank and not args.reqranks[propval.rank:sub(1, 1)] then -- val is nil: value has a rank that isn't requested ------------------------------------ elseif snak.snaktype == "somevalue" then -- value is unknown val = i18n["Unknown"] ------------------------------------ elseif snak.snaktype == "novalue" then -- value is none -- val = "No value" -- don't return anything ------------------------------------ elseif dtype == "wikibase-item" then -- data type is a wikibase item: -- it's wiki-linked value, so output as link if enabled and possible local qnumber = dv.id if linked then val = linkedItem(qnumber, args) else -- no link wanted so check for display-text, otherwise test for lang code local label, islabel if dtxt then label = dtxt else label, islabel = labelOrId(qnumber) local langlabel = mw.wikibase.getLabelByLang(qnumber, args.lang) if langlabel then label = mw.text.nowiki( langlabel ) end end val = pre .. label .. post end -- test for link required ------------------------------------ elseif dtype == "time" then -- data type is time: -- time is in timestamp format -- date precision is integer per mediawiki -- output formatting according to preferences (y/dmy/mdy) -- BC format as BC or BCE -- plaindate is passed to disable looking for "sourcing cirumstances" -- or to set the adjectival form -- qualifiers (if any) is a nested table or nil -- lang is given, or user language, or site language -- -- Here we can check whether args.df has a value -- If not, use code from Module:Sandbox/RexxS/Getdateformat to set it from templates like {{Use mdy dates}} val = dateFormat(dv.time, dv.precision, args.df, args.bc, args.pd, propval.qualifiers, args.lang, "", dv.calendarmodel) ------------------------------------ -- data types which are strings: elseif dtype == "commonsMedia" or dtype == "external-id" or dtype == "string" or dtype == "url" then -- commonsMedia or external-id or string or url -- all have mainsnak.datavalue.value as string if (lpre == "" or lpre == ":") and lpost == "" then -- don't link if no linkpre/postfix or linkprefix is just ":" val = pre .. dv .. post elseif dtype == "external-id" then val = "[" .. lpre .. dv .. lpost .. " " .. pre .. dv .. post .. "]" else val = "[[" .. lpre .. dv .. lpost .. "|" .. pre .. dv .. post .. "]]" end -- check for link requested (i.e. either linkprefix or linkpostfix exists) ------------------------------------ -- data types which are quantities: elseif dtype == "quantity" then -- quantities have mainsnak.datavalue.value.amount and mainsnak.datavalue.value.unit -- the unit is of the form http://www.wikidata.org/entity/Q829073 -- -- implement a switch to turn on/off numerical formatting later local fnum = true -- -- a switch to turn on/off conversions - only for en-wiki local conv = parseParam(args.conv or args.convert, false) -- if we have conversions, we won't have formatted numbers or scales if conv then uabbr = true fnum = false args.scale = "0" end -- -- a switch to turn on/off showing units, default is true local showunits = parseParam(args.su or args.showunits, true) -- -- convert amount to a number local amount = tonumber(dv.amount) or i18n["NaN"] -- -- scale factor for millions, billions, etc. local sc = tostring(args.scale or ""):sub(1,1):lower() local scale if sc == "a" then -- automatic scaling if amount > 1e15 then scale = 12 elseif amount > 1e12 then scale = 9 elseif amount > 1e9 then scale = 6 elseif amount > 1e6 then scale = 3 else scale = 0 end else scale = tonumber(args.scale) or 0 if scale < 0 or scale > 12 then scale = 0 end scale = math.floor(scale/3) * 3 end local factor = 10^scale amount = amount / factor -- ranges: local range = "" -- check if upper and/or lower bounds are given and significant local upb = tonumber(dv.upperBound) local lowb = tonumber(dv.lowerBound) if upb and lowb then -- differences rounded to 2 sig fig: local posdif = roundto(upb - amount, 2) / factor local negdif = roundto(amount - lowb, 2) / factor upb, lowb = amount + posdif, amount - negdif -- round scaled numbers to integers or 4 sig fig if (scale > 0 or sc == "a") then if amount < 1e4 then amount = roundto(amount, 4) else amount = math.floor(amount + 0.5) end end if fnum then amount = args.langobj:formatNum( amount ) end if posdif ~= negdif then -- non-symmetrical range = " +" .. posdif .. " -" .. negdif elseif posdif ~= 0 then -- symmetrical and non-zero range = " ±" .. posdif else -- otherwise range is zero, so leave it as "" end else -- round scaled numbers to integers or 4 sig fig if (scale > 0 or sc == "a") then if amount < 1e4 then amount = roundto(amount, 4) else amount = math.floor(amount + 0.5) end end if fnum then amount = args.langobj:formatNum( amount ) end end -- unit names and symbols: -- extract the qid in the form 'Qnnn' from the value.unit url -- and then fetch the label from that - or symbol if unitabbr is true local unit = "" local usep = "" local usym = "" local unitqid = string.match( dv.unit, "(Q%d+)" ) if filter and unitqid ~= filter then return nil end if unitqid and showunits then local uname = mw.wikibase.getLabelByLang(unitqid, args.lang) or "" if uname ~= "" then usep, unit = " ", uname end if uabbr then -- see if there's a unit symbol (P5061) local unitsymbols = mw.wikibase.getBestStatements(unitqid, "P5061") -- construct fallback table, add local lang and multiple languages local fbtbl = mw.language.getFallbacksFor( args.lang ) table.insert( fbtbl, 1, args.lang ) table.insert( fbtbl, 1, "mul" ) local found = false for idx1, us in ipairs(unitsymbols) do for idx2, fblang in ipairs(fbtbl) do if us.mainsnak.datavalue.value.language == fblang then usym = us.mainsnak.datavalue.value.text found = true break end if found then break end end -- loop through fallback table end -- loop through values of P5061 if found then usep, unit = "&nbsp;", usym end end end -- format display: if conv then if range == "" then val = mw.getCurrentFrame():expandTemplate{title = "cvt", args = {amount, unit}} else val = mw.getCurrentFrame():expandTemplate{title = "cvt", args = {lowb, "to", upb, unit}} end elseif unit == "$" or unit == "£" then val = unit .. amount .. range .. i18n.multipliers[scale] else val = amount .. range .. i18n.multipliers[scale] .. usep .. unit end ------------------------------------ -- datatypes which are global coordinates: elseif dtype == "globe-coordinate" then -- 'display' parameter defaults to "inline, title" *** unused for now *** -- local disp = args.display or "" -- if disp == "" then disp = "inline, title" end -- -- format parameter switches from deg/min/sec to decimal degrees -- default is deg/min/sec -- decimal degrees needs |format = dec local form = (args.format or ""):lower():sub(1,3) if form ~= "dec" then form = "dms" end -- not needed for now -- -- show parameter allows just the latitude, or just the longitude, or both -- to be returned as a signed decimal, ignoring the format parameter. local show = (args.show or ""):lower() if show ~= "longlat" then show = show:sub(1,3) end -- local lat, long, prec = dv.latitude, dv.longitude, dv.precision if show == "lat" then val = decimalPrecision(lat, prec) elseif show == "lon" then val = decimalPrecision(long, prec) elseif show == "longlat" then val = decimalPrecision(long, prec) .. ", " .. decimalPrecision(lat, prec) else local ns = "N" local ew = "E" if lat < 0 then ns = "S" lat = - lat end if long < 0 then ew = "W" long = - long end if form == "dec" then lat = decimalPrecision(lat, prec) long = decimalPrecision(long, prec) val = lat .. "°" .. ns .. " " .. long .. "°" .. ew else local latdeg, latmin, latsec = decimalToDMS(lat, prec) local longdeg, longmin, longsec = decimalToDMS(long, prec) if latsec == 0 and longsec == 0 then if latmin == 0 and longmin == 0 then val = latdeg .. "°" .. ns .. " " .. longdeg .. "°" .. ew else val = latdeg .. "°" .. latmin .. "′" .. ns .. " " val = val .. longdeg .. "°".. longmin .. "′" .. ew end else val = latdeg .. "°" .. latmin .. "′" .. latsec .. "″" .. ns .. " " val = val .. longdeg .. "°" .. longmin .. "′" .. longsec .. "″" .. ew end end end ------------------------------------ elseif dtype == "monolingualtext" then -- data type is Monolingual text: -- has mainsnak.datavalue.value as a table containing language/text pairs -- collect all the values in 'out' and languages in 'mlt' and process them later val = pre .. dv.text .. post mlt = dv.language ------------------------------------ else -- some other data type so write a specific handler val = "unknown data type: " .. dtype end -- of datatype/unknown value/sourced check return val, mlt end ------------------------------------------------------------------------------- -- propertyvalueandquals takes a property object, the arguments passed from frame, -- and a qualifier propertyID. -- It returns a sequence (table) of values representing the values of that property -- and qualifiers that match the qualifierID if supplied. ------------------------------------------------------------------------------- -- Dependencies: parseParam(); sourced(); labelOrId(); i18n.latestdatequalifier(); format_Date(); -- makeOrdinal(); roundto(); decimalPrecision(); decimalToDMS(); assembleoutput(); ------------------------------------------------------------------------------- local function propertyvalueandquals(objproperty, args, qualID) -- needs this style of declaration because it's re-entrant -- onlysourced is a boolean passed to return only values sourced to other than Wikipedia -- if nothing or an empty string is passed set it true local onlysrc = parseParam(args.onlysourced or args.osd, true) -- linked is a a boolean that enables the link to a local page via sitelink -- if nothing or an empty string is passed set it true local linked = parseParam(args.linked, true) -- prefix is a string that may be nil, empty (""), or a string of characters -- this is prefixed to each value -- useful when when multiple values are returned -- any double-quotes " are stripped out, so that spaces may be passed local prefix = (args.prefix or ""):gsub('"', '') -- postfix is a string that may be nil, empty (""), or a string of characters -- this is postfixed to each value -- useful when when multiple values are returned -- any double-quotes " are stripped out, so that spaces may be passed local postfix = (args.postfix or ""):gsub('"', '') -- linkprefix is a string that may be nil, empty (""), or a string of characters -- this creates a link and is then prefixed to each value -- useful when when multiple values are returned and indirect links are needed -- any double-quotes " are stripped out, so that spaces may be passed local lprefix = (args.linkprefix or args.lp or ""):gsub('"', '') -- linkpostfix is a string that may be nil, empty (""), or a string of characters -- this is postfixed to each value when linking is enabled with lprefix -- useful when when multiple values are returned -- any double-quotes " are stripped out, so that spaces may be passed local lpostfix = (args.linkpostfix or ""):gsub('"', '') -- wdlinks is a boolean passed to enable links to Wikidata when no article exists -- if nothing or an empty string is passed set it false local wdl = parseParam(args.wdlinks or args.wdl, false) -- unitabbr is a boolean passed to enable unit abbreviations for common units -- if nothing or an empty string is passed set it false local uabbr = parseParam(args.unitabbr or args.uabbr, false) -- qualsonly is a boolean passed to return just the qualifiers -- if nothing or an empty string is passed set it false local qualsonly = parseParam(args.qualsonly or args.qo, false) -- maxvals is a string that may be nil, empty (""), or a number -- this determines how many items may be returned when multiple values are available -- setting it = 1 is useful where the returned string is used within another call, e.g. image local maxvals = tonumber(args.maxvals) or 0 -- pd (plain date) is a string: yes/true/1 | no/false/0 | adj -- to disable/enable "sourcing cirumstances" or use adjectival form for the plain date local pd = args.plaindate or args.pd or "no" args.pd = pd -- allow qualifiers to have a different date format; default to year unless qualsonly is set args.qdf = args.qdf or args.qualifierdateformat or args.df or (not qualsonly and "y") local lang = args.lang or findLang().code -- qualID is a string list of wanted qualifiers or "ALL" qualID = qualID or "" -- capitalise list of wanted qualifiers and substitute "DATES" qualID = qualID:upper():gsub("DATES", "P580, P582") local allflag = (qualID == "ALL") -- create table of wanted qualifiers as key local qwanted = {} -- create sequence of wanted qualifiers local qorder = {} for q in mw.text.gsplit(qualID, "%p") do -- split at punctuation and iterate local qtrim = mw.text.trim(q) if qtrim ~= "" then qwanted[mw.text.trim(q)] = true qorder[#qorder+1] = qtrim end end -- qsep is the output separator for rendering qualifier list local qsep = (args.qsep or ""):gsub('"', '') -- qargs are the arguments to supply to assembleoutput() local qargs = { ["osd"] = "false", ["linked"] = tostring(linked), ["prefix"] = args.qprefix, ["postfix"] = args.qpostfix, ["linkprefix"] = args.qlinkprefix or args.qlp, ["linkpostfix"] = args.qlinkpostfix, ["wdl"] = "false", ["unitabbr"] = tostring(uabbr), ["maxvals"] = 0, ["sorted"] = tostring(args.qsorted), ["noicon"] = "true", ["list"] = args.qlist, ["sep"] = qsep, ["langobj"] = args.langobj, ["lang"] = args.langobj.code, ["df"] = args.qdf, ["sn"] = parseParam(args.qsn or args.qshortname, false), } -- all proper values of a Wikidata property will be the same type as the first -- qualifiers don't have a mainsnak, properties do --#Modified line local datatype = objproperty[1].datatype or (objproperty[1].mainsnak and objproperty[1].mainsnak.datatype) -- out[] holds the a list of returned values for this property -- mlt[] holds the language code if the datatype is monolingual text local out = {} local mlt = {} for k, v in ipairs(objproperty) do local hasvalue = true if (onlysrc and not sourced(v)) then -- no value: it isn't sourced when onlysourced=true hasvalue = false else local val, lcode = rendersnak(v, args, linked, lprefix, lpostfix, prefix, postfix, uabbr) if not val then hasvalue = false -- rank doesn't match elseif qualsonly and qualID then -- suppress value returned: only qualifiers are requested else out[#out+1], mlt[#out+1] = val, lcode end end -- See if qualifiers are to be returned: local snak = v.mainsnak or v if hasvalue and v.qualifiers and qualID ~= "" and snak.snaktype~="novalue" then -- collect all wanted qualifier values returned in qlist, indexed by propertyID local qlist = {} local timestart, timeend = "", "" -- loop through qualifiers for k1, v1 in pairs(v.qualifiers) do if allflag or qwanted[k1] then if k1 == "P1326" then local ts = v1[1].datavalue.value.time local dp = v1[1].datavalue.value.precision qlist[k1] = dateFormat(ts, dp, args.qdf, args.bc, pd, "", lang, "before") elseif k1 == "P1319" then local ts = v1[1].datavalue.value.time local dp = v1[1].datavalue.value.precision qlist[k1] = dateFormat(ts, dp, args.qdf, args.bc, pd, "", lang, "after") elseif k1 == "P580" then timestart = propertyvalueandquals(v1, qargs)[1] or "" -- treat only one start time as valid elseif k1 == "P582" then timeend = propertyvalueandquals(v1, qargs)[1] or "" -- treat only one end time as valid else local q = assembleoutput(propertyvalueandquals(v1, qargs), qargs) -- we already deal with circa via 'sourcing circumstances' if the datatype was time -- circa may be either linked or unlinked *** internationalise later *** if datatype ~= "time" or q ~= "circa" and not (type(q) == "string" and q:find("circa]]")) then qlist[k1] = q end end end -- of test for wanted end -- of loop through qualifiers -- set date separator local t = timestart .. timeend -- *** internationalise date separators later *** local dsep = "&ndash;" if t:find("%s") or t:find("&nbsp;") then dsep = " &ndash; " end -- set the order for the list of qualifiers returned; start time and end time go last if next(qlist) then local qlistout = {} if allflag then for k2, v2 in pairs(qlist) do qlistout[#qlistout+1] = v2 end else for i2, v2 in ipairs(qorder) do qlistout[#qlistout+1] = qlist[v2] end end if t ~= "" then qlistout[#qlistout+1] = timestart .. dsep .. timeend end local qstr = assembleoutput(qlistout, qargs) if qualsonly then out[#out+1] = qstr else out[#out] = out[#out] .. " (" .. qstr .. ")" end elseif t ~= "" then if qualsonly then if timestart == "" then out[#out+1] = timeend elseif timeend == "" then out[#out+1] = timestart else out[#out+1] = timestart .. dsep .. timeend end else out[#out] = out[#out] .. " (" .. timestart .. dsep .. timeend .. ")" end end end -- of test for qualifiers wanted if maxvals > 0 and #out >= maxvals then break end end -- of for each value loop -- we need to pick one value to return if the datatype was "monolingualtext" -- if there's only one value, use that -- otherwise look through the fallback languages for a match if datatype == "monolingualtext" and #out >1 then lang = mw.text.split( lang, '-', true )[1] local fbtbl = mw.language.getFallbacksFor( lang ) table.insert( fbtbl, 1, lang ) local bestval = "" local found = false for idx1, lang1 in ipairs(fbtbl) do for idx2, lang2 in ipairs(mlt) do if (lang1 == lang2) and not found then bestval = out[idx2] found = true break end end -- loop through values of property end -- loop through fallback languages if found then -- replace output table with a table containing the best value out = { bestval } else -- more than one value and none of them on the list of fallback languages -- sod it, just give them the first one out = { out[1] } end end return out end ------------------------------------------------------------------------------- -- Common code for p.getValueByQual and p.getValueByLang ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; assembleoutput; ------------------------------------------------------------------------------- local _getvaluebyqual = function(frame, qualID, checkvalue) -- The property ID that will have a qualifier is the first unnamed parameter local propertyID = mw.text.trim(frame.args[1] or "") if propertyID == "" then return "no property supplied" end if qualID == "" then return "no qualifier supplied" end -- onlysourced is a boolean passed to return property values -- only when property values are sourced to something other than Wikipedia -- if nothing or an empty string is passed set it true -- if "false" or "no" or 0 is passed set it false local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true) -- set the requested ranks flags frame.args.reqranks = setRanks(frame.args.rank) -- set a language object and code in the frame.args table frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code local args = frame.args -- check for locally supplied parameter in second unnamed parameter -- success means no local parameter and the property exists local qid, props = parseInput(frame, args[2], propertyID) local linked = parseParam(args.linked, true) local lpre = (args.linkprefix or args.lp or ""):gsub('"', '') local lpost = (args.linkpostfix or ""):gsub('"', '') local pre = (args.prefix or ""):gsub('"', '') local post = (args.postfix or ""):gsub('"', '') local uabbr = parseParam(args.unitabbr or args.uabbr, false) local filter = (args.unit or ""):upper() local maxvals = tonumber(args.maxvals) or 0 if filter == "" then filter = nil end if qid then local out = {} -- Scan through the values of the property -- we want something like property is "pronunciation audio (P443)" in propertyID -- with a qualifier like "language of work or name (P407)" in qualID -- whose value has the required ID, like "British English (Q7979)", in qval for k1, v1 in ipairs(props) do if v1.mainsnak.snaktype == "value" then -- check if it has the right qualifier local v1q = v1.qualifiers if v1q and v1q[qualID] then if onlysrc == false or sourced(v1) then -- if we've got this far, we have a (sourced) claim with qualifiers -- so see if matches the required value -- We'll only deal with wikibase-items and strings for now if v1q[qualID][1].datatype == "wikibase-item" then if checkvalue(v1q[qualID][1].datavalue.value.id) then out[#out + 1] = rendersnak(v1, args, linked, lpre, lpost, pre, post, uabbr, filter) end elseif v1q[qualID][1].datatype == "string" then if checkvalue(v1q[qualID][1].datavalue.value) then out[#out + 1] = rendersnak(v1, args, linked, lpre, lpost, pre, post, uabbr, filter) end end end -- of check for sourced end -- of check for matching required value and has qualifiers else return nil end -- of check for string if maxvals > 0 and #out >= maxvals then break end end -- of loop through values of propertyID return assembleoutput(out, frame.args, qid, propertyID) else return props -- either local parameter or nothing end -- of test for success return nil end ------------------------------------------------------------------------------- -- _location takes Q-id and follows P276 (location) -- or P131 (located in the administrative territorial entity) or P706 (located on terrain feature) -- from the initial item to higher level territories/locations until it reaches the highest. -- An optional boolean, 'first', determines whether the first item is returned (default: false). -- An optional boolean 'skip' toggles the display to skip to the last item (default: false). -- It returns a table containing the locations - linked where possible, except for the highest. ------------------------------------------------------------------------------- -- Dependencies: findLang(); labelOrId(); linkedItem ------------------------------------------------------------------------------- local _location = function(qid, first, skip) first = parseParam(first, false) skip = parseParam(skip, false) local locs = {"P276", "P131", "P706"} local out = {} local langcode = findLang():getCode() local finished = false local count = 0 local prevqid = "Q0" repeat local prop for i1, v1 in ipairs(locs) do local proptbl = mw.wikibase.getBestStatements(qid, v1) if #proptbl > 1 then -- there is more than one higher location local prevP131, prevP131id if prevqid ~= "Q0" then prevP131 = mw.wikibase.getBestStatements(prevqid, "P131")[1] prevP131id = prevP131 and prevP131.mainsnak.datavalue and prevP131.mainsnak.datavalue.value.id end for i2, v2 in ipairs(proptbl) do local parttbl = v2.qualifiers and v2.qualifiers.P518 if parttbl then -- this higher location has qualifier 'applies to part' (P518) for i3, v3 in ipairs(parttbl) do if v3.snaktype == "value" and v3.datavalue.value.id == prevqid then -- it has a value equal to the previous location prop = proptbl[i2] break end -- of test for matching last location end -- of loop through values of 'applies to part' else -- there's no qualifier 'applies to part' (P518) -- so check if the previous location had a P131 that matches this alternate if qid == prevP131id then prop = proptbl[i2] break end -- of test for matching previous P131 end end -- of loop through parent locations -- fallback to second value if match not found prop = prop or proptbl[2] elseif #proptbl > 0 then prop = proptbl[1] end if prop then break end end -- check if it's an instance of (P31) a country (Q6256) or sovereign state (Q3624078) -- and terminate the chain if it is local inst = mw.wikibase.getAllStatements(qid, "P31") if #inst > 0 then for k, v in ipairs(inst) do local instid = v.mainsnak.datavalue and v.mainsnak.datavalue.value.id -- stop if it's a country (or a country within the United Kingdom if skip is true) if instid == "Q6256" or instid == "Q3624078" or (skip and instid == "Q3336843") then prop = nil -- this will ensure this is treated as top-level location break end end end -- get the name of this location and update qid to point to the parent location if prop and prop.mainsnak.datavalue then if not skip or count == 0 then local args = { lprefix = ":" } out[#out+1] = linkedItem(qid, args) -- get a linked value if we can end qid, prevqid = prop.mainsnak.datavalue.value.id, qid else -- This is top-level location, so get short name except when this is the first item -- Use full label if there's no short name or this is the first item local prop1813 = mw.wikibase.getAllStatements(qid, "P1813") -- if there's a short name and this isn't the only item if prop1813[1] and (#out > 0)then local shortname -- short name is monolingual text, so look for match to the local language -- choose the shortest 'short name' in that language for k, v in pairs(prop1813) do if v.mainsnak.datavalue.value.language == langcode then local name = v.mainsnak.datavalue.value.text if (not shortname) or (#name < #shortname) then shortname = name end end end -- add the shortname if one is found, fallback to the label -- but skip it if it's "USA" if shortname ~= "USA" then out[#out+1] = shortname or labelOrId(qid) else if skip then out[#out+1] = "US" end end else -- no shortname, so just add the label local loc = labelOrId(qid) -- exceptions go here: if loc == "United States of America" then out[#out+1] = "United States" else out[#out+1] = loc end end finished = true end count = count + 1 until finished or count >= 10 -- limit to 10 levels to avoid infinite loops -- remove the first location if not required if not first then table.remove(out, 1) end -- we might have duplicate text for consecutive locations, so remove them if #out > 2 then local plain = {} for i, v in ipairs(out) do -- strip any links plain[i] = v:gsub("^%[%[[^|]*|", ""):gsub("]]$", "") end local idx = 2 repeat if plain[idx] == plain[idx-1] then -- duplicate found local removeidx = 0 if (plain[idx] ~= out[idx]) and (plain[idx-1] == out[idx-1]) then -- only second one is linked, so drop the first removeidx = idx - 1 elseif (plain[idx] == out[idx]) and (plain[idx-1] ~= out[idx-1]) then -- only first one is linked, so drop the second removeidx = idx else -- pick one removeidx = idx - (os.time()%2) end table.remove(out, removeidx) table.remove(plain, removeidx) else idx = idx +1 end until idx >= #out end return out end ------------------------------------------------------------------------------- -- _getsumofparts scans the property 'has part' (P527) for values matching a list. -- The list (args.vlist) consists of a string of Qids separated by spaces or any usual punctuation. -- If the matched values have a qualifer 'quantity' (P1114), those quantites are summed. -- The sum is returned as a number (i.e. 0 if none) -- a table of arguments is supplied implementing the usual parameters. ------------------------------------------------------------------------------- -- Dependencies: setRanks; parseParam; parseInput; sourced; assembleoutput; ------------------------------------------------------------------------------- local _getsumofparts = function(args) local vallist = (args.vlist or ""):upper() if vallist == "" then return end args.reqranks = setRanks(args.rank) local f = {} f.args = args local qid, props = parseInput(f, "", "P527") if not qid then return 0 end local onlysrc = parseParam(args.onlysourced or args.osd, true) local sum = 0 for k1, v1 in ipairs(props) do if (onlysrc == false or sourced(v1)) and v1.mainsnak.snaktype == "value" and v1.mainsnak.datavalue.type == "wikibase-entityid" and vallist:match( v1.mainsnak.datavalue.value.id ) and v1.qualifiers then local quals = v1.qualifiers["P1114"] if quals then for k2, v2 in ipairs(quals) do sum = sum + v2.datavalue.value.amount end end end end return sum end ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Public functions ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- _getValue makes the functionality of getValue available to other modules ------------------------------------------------------------------------------- -- Dependencies: setRanks; parseInput; propertyvalueandquals; assembleoutput; parseParam; sourced; -- labelOrId; i18n.latestdatequalifier; format_Date; makeOrdinal; roundto; decimalPrecision; decimalToDMS; ------------------------------------------------------------------------------- p._getValue = function(args) -- parameter sets for commonly used groups of parameters local paraset = tonumber(args.ps or args.parameterset or 0) if paraset == 1 then -- a common setting args.rank = "best" args.fetchwikidata = "ALL" args.onlysourced = "no" args.noicon = "true" elseif paraset == 2 then -- equivalent to raw args.rank = "best" args.fetchwikidata = "ALL" args.onlysourced = "no" args.noicon = "true" args.linked = "no" args.pd = "true" elseif paraset == 3 then -- third set goes here end -- implement eid parameter local eid = args.eid if eid == "" then return nil elseif eid then args.qid = eid end local propertyID = mw.text.trim(args[1] or "") args.reqranks = setRanks(args.rank) -- replacetext (rt) is a string that is returned instead of any non-empty Wikidata value -- this is useful for tracking and debugging, so we set fetchwikidata=ALL to fill the whitelist local replacetext = mw.text.trim(args.rt or args.replacetext or "") if replacetext ~= "" then args.fetchwikidata = "ALL" end local f = {} f.args = args local entityid, props = parseInput(f, f.args[2], propertyID) if not entityid then return props -- either the input parameter or nothing end -- qual is a string containing the property ID of the qualifier(s) to be returned -- if qual == "ALL" then all qualifiers returned -- if qual == "DATES" then qualifiers P580 (start time) and P582 (end time) returned -- if nothing or an empty string is passed set it nil -> no qualifiers returned local qualID = mw.text.trim(args.qual or ""):upper() if qualID == "" then qualID = nil end -- set a language object and code in the args table args.langobj = findLang(args.lang) args.lang = args.langobj.code -- table 'out' stores the return value(s): local out = propertyvalueandquals(props, args, qualID) -- format the table of values and return it as a string: return assembleoutput(out, args, entityid, propertyID) end --#Added function p._getValueFromSnaks = function(args) local propertyID = mw.text.trim(args[1] or "") -- replacetext (rt) is a string that is returned instead of any non-empty Wikidata value -- this is useful for tracking and debugging, so we set fetchwikidata=ALL to fill the whitelist local replacetext = mw.text.trim(args.rt or args.replacetext or "") if replacetext ~= "" then args.fetchwikidata = "ALL" end local props local f = {} f.args = args local refsnak = args.snak if refsnak == "" then refsnak = nil end if refsnak then props = refsnak[propertyID] or {} end if not props[1] then return nil end -- set a language object and code in the args table args.langobj = findLang(args.lang) args.lang = args.langobj.code -- table 'out' stores the return value(s): local out = propertyvalueandquals(props, args) -- format the table of values and return it as a string: return assembleoutput(out, args, nil, propertyID) end ------------------------------------------------------------------------------- -- getValue is used to get the value(s) of a property -- The property ID is passed as the first unnamed parameter and is required. -- A locally supplied parameter may optionaly be supplied as the second unnamed parameter. -- The function will now also return qualifiers if parameter qual is supplied ------------------------------------------------------------------------------- -- Dependencies: _getValue; setRanks; parseInput; propertyvalueandquals; assembleoutput; parseParam; sourced; -- labelOrId; i18n.latestdatequalifier; format_Date; makeOrdinal; roundto; decimalPrecision; decimalToDMS; ------------------------------------------------------------------------------- p.getValue = function(frame) local args= frame.args if not args[1] then args = frame:getParent().args if not args[1] then return i18n.errors["No property supplied"] end end return p._getValue(args) end ------------------------------------------------------------------------------- -- getPreferredValue is used to get a value, -- (or a comma separated list of them if multiple values exist). -- If preferred ranks are set, it will return those values, otherwise values with normal ranks -- now redundant to getValue with |rank=best ------------------------------------------------------------------------------- -- Dependencies: p.getValue; setRanks; parseInput; propertyvalueandquals; assembleoutput; -- parseParam; sourced; labelOrId; i18n.latestdatequalifier; format_Date; -- makeOrdinal; roundto; decimalPrecision; decimalToDMS; ------------------------------------------------------------------------------- p.getPreferredValue = function(frame) frame.args.rank = "best" return p.getValue(frame) end ------------------------------------------------------------------------------- -- getCoords is used to get coordinates for display in an infobox -- whitelist and blacklist are implemented -- optional 'display' parameter is allowed, defaults to nil - was "inline, title" ------------------------------------------------------------------------------- -- Dependencies: setRanks(); parseInput(); decimalPrecision(); ------------------------------------------------------------------------------- p.getCoords = function(frame) local propertyID = "P625" -- if there is a 'display' parameter supplied, use it -- otherwise default to nothing local disp = frame.args.display or "" if disp == "" then disp = nil -- default to not supplying display parameter, was "inline, title" end -- there may be a format parameter to switch from deg/min/sec to decimal degrees -- default is deg/min/sec -- decimal degrees needs |format = dec local form = (frame.args.format or ""):lower():sub(1,3) if form ~= "dec" then form = "dms" end -- just deal with best values frame.args.reqranks = setRanks("best") local qid, props = parseInput(frame, frame.args[1], propertyID) if not qid then return props -- either local parameter or nothing else local dv = props[1].mainsnak.datavalue.value local lat, long, prec = dv.latitude, dv.longitude, dv.precision lat = decimalPrecision(lat, prec) long = decimalPrecision(long, prec) local lat_long = { lat, long } lat_long["display"] = disp lat_long["format"] = form -- invoke template Coord with the values stored in the table return frame:expandTemplate{title = 'coord', args = lat_long} end end ------------------------------------------------------------------------------- -- getQualifierValue is used to get a formatted value of a qualifier -- -- The call needs: a property (the unnamed parameter or 1=) -- a target value for that property (pval=) -- a qualifier for that target value (qual=) -- The usual whitelisting and blacklisting of the property is implemented -- The boolean onlysourced= parameter can be set to return nothing -- when the property is unsourced (or only sourced to Wikipedia) ------------------------------------------------------------------------------- -- Dependencies: parseParam(); setRanks(); parseInput(); sourced(); -- propertyvalueandquals(); assembleoutput(); -- labelOrId(); i18n.latestdatequalifier(); format_Date(); -- findLang(); makeOrdinal(); roundto(); decimalPrecision(); decimalToDMS(); ------------------------------------------------------------------------------- p.getQualifierValue = function(frame) -- The property ID that will have a qualifier is the first unnamed parameter local propertyID = mw.text.trim(frame.args[1] or "") -- The value of the property we want to match whose qualifier value is to be returned -- is passed in named parameter |pval= local propvalue = frame.args.pval -- The property ID of the qualifier -- whose value is to be returned is passed in named parameter |qual= local qualifierID = frame.args.qual -- A filter can be set like this: filter=P642==Q22674854 local filter, fprop, fval local ftable = mw.text.split(frame.args.filter or "", "==") if ftable[2] then fprop = mw.text.trim(ftable[1]) fval = mw.text.trim(ftable[2]) filter = true end -- onlysourced is a boolean passed to return qualifiers -- only when property values are sourced to something other than Wikipedia -- if nothing or an empty string is passed set it true -- if "false" or "no" or 0 is passed set it false local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true) -- set a language object and language code in the frame.args table frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code -- set the requested ranks flags frame.args.reqranks = setRanks(frame.args.rank) -- check for locally supplied parameter in second unnamed parameter -- success means no local parameter and the property exists local qid, props = parseInput(frame, frame.args[2], propertyID) if qid then local out = {} -- Scan through the values of the property -- we want something like property is P793, significant event (in propertyID) -- whose value is something like Q385378, construction (in propvalue) -- then we can return the value(s) of a qualifier such as P580, start time (in qualifierID) for k1, v1 in pairs(props) do if v1.mainsnak.snaktype == "value" and v1.mainsnak.datavalue.type == "wikibase-entityid" then -- It's a wiki-linked value, so check if it's the target (in propvalue) and if it has qualifiers if v1.mainsnak.datavalue.value.id == propvalue and v1.qualifiers then if onlysrc == false or sourced(v1) then -- if we've got this far, we have a (sourced) claim with qualifiers -- which matches the target, so apply the filter and find the value(s) of the qualifier we want if not filter or (v1.qualifiers[fprop] and v1.qualifiers[fprop][1].datavalue.value.id == fval) then local quals = v1.qualifiers[qualifierID] if quals then -- can't reference qualifer, so set onlysourced = "no" (args are strings, not boolean) local qargs = frame.args qargs.onlysourced = "no" local vals = propertyvalueandquals(quals, qargs, qid) for k, v in ipairs(vals) do out[#out + 1] = v end end end end -- of check for sourced end -- of check for matching required value and has qualifiers end -- of check for wikibase entity end -- of loop through values of propertyID return assembleoutput(out, frame.args, qid, propertyID) else return props -- either local parameter or nothing end -- of test for success return nil end ------------------------------------------------------------------------------- -- getSumOfParts scans the property 'has part' (P527) for values matching a list. -- The list is passed in parameter vlist. -- It consists of a string of Qids separated by spaces or any usual punctuation. -- If the matched values have a qualifier 'quantity' (P1114), those quantities are summed. -- The sum is returned as a number or nothing if zero. ------------------------------------------------------------------------------- -- Dependencies: _getsumofparts; ------------------------------------------------------------------------------- p.getSumOfParts = function(frame) local sum = _getsumofparts(frame.args) if sum == 0 then return end return sum end ------------------------------------------------------------------------------- -- getValueByQual gets the value of a property which has a qualifier with a given entity value -- The call needs: -- a property ID (the unnamed parameter or 1=Pxxx) -- the ID of a qualifier for that property (qualID=Pyyy) -- either the Wikibase-entity ID of a value for that qualifier (qvalue=Qzzz) -- or a string value for that qualifier (qvalue=abc123) -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: _getvaluebyqual; parseParam; setRanks; parseInput; sourced; -- assembleoutput; ------------------------------------------------------------------------------- p.getValueByQual = function(frame) local qualID = frame.args.qualID -- The Q-id of the value for the qualifier we want to match is in named parameter |qvalue= local qval = frame.args.qvalue or "" if qval == "" then return "no qualifier value supplied" end local function checkQID(id) return id == qval end return _getvaluebyqual(frame, qualID, checkQID) end ------------------------------------------------------------------------------- -- getValueByLang gets the value of a property which has a qualifier P407 -- ("language of work or name") whose value has the given language code -- The call needs: -- a property ID (the unnamed parameter or 1=Pxxx) -- the MediaWiki language code to match the language (lang=xx[-yy]) -- (if no code is supplied, it uses the default language) -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: _getvaluebyqual; parseParam; setRanks; parseInput; sourced; assembleoutput; ------------------------------------------------------------------------------- p.getValueByLang = function(frame) -- The language code for the qualifier we want to match is in named parameter |lang= local langcode = findLang(frame.args.lang).code local function checkLanguage(id) -- id should represent a language like "British English (Q7979)" -- it should have string property "Wikimedia language code (P424)" -- qlcode will be a table: local qlcode = mw.wikibase.getBestStatements(id, "P424") if (#qlcode > 0) and (qlcode[1].mainsnak.datavalue.value == langcode) then return true end end return _getvaluebyqual(frame, "P407", checkLanguage) end ------------------------------------------------------------------------------- -- getValueByRefSource gets the value of a property which has a reference "stated in" (P248) -- whose value has the given entity-ID. -- The call needs: -- a property ID (the unnamed parameter or 1=Pxxx) -- the entity ID of a value to match where the reference is stated in (match=Qzzz) -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p.getValueByRefSource = function(frame) -- The property ID that we want to check is the first unnamed parameter local propertyID = mw.text.trim(frame.args[1] or ""):upper() if propertyID == "" then return "no property supplied" end -- The Q-id of the value we want to match is in named parameter |qvalue= local qval = (frame.args.match or ""):upper() if qval == "" then qval = "Q21540096" end local unit = (frame.args.unit or ""):upper() if unit == "" then unit = "Q4917" end local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true) -- set the requested ranks flags frame.args.reqranks = setRanks(frame.args.rank) -- set a language object and code in the frame.args table frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code local linked = parseParam(frame.args.linked, true) local uabbr = parseParam(frame.args.uabbr or frame.args.unitabbr, false) -- qid not nil means no local parameter and the property exists local qid, props = parseInput(frame, frame.args[2], propertyID) if qid then local out = {} local mlt= {} for k1, v1 in ipairs(props) do if onlysrc == false or sourced(v1) then if v1.references then for k2, v2 in ipairs(v1.references) do if v2.snaks.P248 then for k3, v3 in ipairs(v2.snaks.P248) do if v3.datavalue.value.id == qval then out[#out+1], mlt[#out+1] = rendersnak(v1, frame.args, linked, "", "", "", "", uabbr, unit) if not mlt[#out] then -- we only need one match per property value -- unless datatype was monolingual text break end end -- of test for match end -- of loop through values "stated in" end -- of test that "stated in" exists end -- of loop through references end -- of test that references exist end -- of test for sourced end -- of loop through values of propertyID if #mlt > 0 then local langcode = frame.args.lang langcode = mw.text.split( langcode, '-', true )[1] local fbtbl = mw.language.getFallbacksFor( langcode ) table.insert( fbtbl, 1, langcode ) local bestval = "" local found = false for idx1, lang1 in ipairs(fbtbl) do for idx2, lang2 in ipairs(mlt) do if (lang1 == lang2) and not found then bestval = out[idx2] found = true break end end -- loop through values of property end -- loop through fallback languages if found then -- replace output table with a table containing the best value out = { bestval } else -- more than one value and none of them on the list of fallback languages -- sod it, just give them the first one out = { out[1] } end end return assembleoutput(out, frame.args, qid, propertyID) else return props -- no property or local parameter supplied end -- of test for success end ------------------------------------------------------------------------------- -- getPropertyIDs takes most of the usual parameters. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented. -- It returns the Entity-IDs (Qids) of the values of a property if it is a Wikibase-Entity. -- Otherwise it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p._getPropertyIDs = function(args) args.reqranks = setRanks(args.rank) args.langobj = findLang(args.lang) args.lang = args.langobj.code -- change default for noicon to true args.noicon = tostring(parseParam(args.noicon or "", true)) local f = {} f.args = args local pid = mw.text.trim(args[1] or ""):upper() -- get the qid and table of claims for the property, or nothing and the local value passed local qid, props = parseInput(f, args[2], pid) if not qid then return props end if not props[1] then return nil end local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 local out = {} for i, v in ipairs(props) do local snak = v.mainsnak if ( snak.datatype == "wikibase-item" ) and ( v.rank and args.reqranks[v.rank:sub(1, 1)] ) and ( snak.snaktype == "value" ) and ( sourced(v) or not onlysrc ) then out[#out+1] = snak.datavalue.value.id end if maxvals > 0 and #out >= maxvals then break end end return assembleoutput(out, args, qid, pid) end p.getPropertyIDs = function(frame) local args = frame.args return p._getPropertyIDs(args) end ------------------------------------------------------------------------------- -- getQualifierIDs takes most of the usual parameters. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented. -- It takes a property-id as the first unnamed parameter, and an optional parameter qlist -- which is a list of qualifier property-ids to search for (default is "ALL") -- It returns the Entity-IDs (Qids) of the values of a property if it is a Wikibase-Entity. -- Otherwise it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p.getQualifierIDs = function(frame) local args = frame.args args.reqranks = setRanks(args.rank) args.langobj = findLang(args.lang) args.lang = args.langobj.code -- change default for noicon to true args.noicon = tostring(parseParam(args.noicon or "", true)) local f = {} f.args = args local pid = mw.text.trim(args[1] or ""):upper() -- get the qid and table of claims for the property, or nothing and the local value passed local qid, props = parseInput(f, args[2], pid) if not qid then return props end if not props[1] then return nil end -- get the other parameters local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 local qlist = args.qlist or "" if qlist == "" then qlist = "ALL" end qlist = qlist:gsub("[%p%s]+", " ") .. " " local out = {} for i, v in ipairs(props) do local snak = v.mainsnak if ( v.rank and args.reqranks[v.rank:sub(1, 1)] ) and ( snak.snaktype == "value" ) and ( sourced(v) or not onlysrc ) then if v.qualifiers then for k1, v1 in pairs(v.qualifiers) do if qlist == "ALL " or qlist:match(k1 .. " ") then for i2, v2 in ipairs(v1) do if v2.datatype == "wikibase-item" and v2.snaktype == "value" then out[#out+1] = v2.datavalue.value.id end -- of test that id exists end -- of loop through qualifier values end -- of test for kq in qlist end -- of loop through qualifiers end -- of test for qualifiers end -- of test for rank value, sourced, and value exists if maxvals > 0 and #out >= maxvals then break end end -- of loop through property values return assembleoutput(out, args, qid, pid) end ------------------------------------------------------------------------------- -- getPropOfProp takes two propertyIDs: prop1 and prop2 (as well as the usual parameters) -- If the value(s) of prop1 are of type "wikibase-item" then it returns the value(s) of prop2 -- of each of those wikibase-items. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p._getPropOfProp = function(args) -- parameter sets for commonly used groups of parameters local paraset = tonumber(args.ps or args.parameterset or 0) if paraset == 1 then -- a common setting args.rank = "best" args.fetchwikidata = "ALL" args.onlysourced = "no" args.noicon = "true" elseif paraset == 2 then -- equivalent to raw args.rank = "best" args.fetchwikidata = "ALL" args.onlysourced = "no" args.noicon = "true" args.linked = "no" args.pd = "true" elseif paraset == 3 then -- third set goes here end args.reqranks = setRanks(args.rank) args.langobj = findLang(args.lang) args.lang = args.langobj.code local pid1 = args.prop1 or args.pid1 or "" local pid2 = args.prop2 or args.pid2 or "" if pid1 == "" or pid2 == "" then return nil end local f = {} f.args = args local qid1, statements1 = parseInput(f, args[1], pid1) -- parseInput nulls empty args[1] and returns args[1] if nothing on Wikidata if not qid1 then return statements1 end -- otherwise it returns the qid and a table for the statement local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 local qualID = mw.text.trim(args.qual or ""):upper() if qualID == "" then qualID = nil end local out = {} for k, v in ipairs(statements1) do if not onlysrc or sourced(v) then local snak = v.mainsnak if snak.datatype == "wikibase-item" and snak.snaktype == "value" then local qid2 = snak.datavalue.value.id local statements2 = {} if args.reqranks.b then statements2 = mw.wikibase.getBestStatements(qid2, pid2) else statements2 = mw.wikibase.getAllStatements(qid2, pid2) end if statements2[1] then local out2 = propertyvalueandquals(statements2, args, qualID) out[#out+1] = assembleoutput(out2, args, qid2, pid2) end end -- of test for valid property1 value end -- of test for sourced if maxvals > 0 and #out >= maxvals then break end end -- of loop through values of property1 return assembleoutput(out, args, qid1, pid1) end p.getPropOfProp = function(frame) local args= frame.args if not args.prop1 and not args.pid1 then args = frame:getParent().args if not args.prop1 and not args.pid1 then return i18n.errors["No property supplied"] end end return p._getPropOfProp(args) end ------------------------------------------------------------------------------- -- getAwardCat takes most of the usual parameters. If the item has values of P166 (award received), -- then it examines each of those awards for P2517 (category for recipients of this award). -- If it exists, it returns the corresponding category, -- with the item's P734 (family name) as sort key, or no sort key if there is no family name. -- The sort key may be overridden by the parameter |sortkey (alias |sk). -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p.getAwardCat = function(frame) frame.args.reqranks = setRanks(frame.args.rank) frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code local args = frame.args args.sep = " " local pid1 = args.prop1 or "P166" local pid2 = args.prop2 or "P2517" if pid1 == "" or pid2 == "" then return nil end -- locally supplied value: local localval = mw.text.trim(args[1] or "") local qid1, statements1 = parseInput(frame, localval, pid1) if not qid1 then return localval end -- linkprefix (strip quotes) local lp = (args.linkprefix or args.lp or ""):gsub('"', '') -- sort key (strip quotes, hyphens and periods): local sk = (args.sortkey or args.sk or ""):gsub('["-.]', '') -- family name: local famname = "" if sk == "" then local p734 = mw.wikibase.getBestStatements(qid1, "P734")[1] local p734id = p734 and p734.mainsnak.snaktype == "value" and p734.mainsnak.datavalue.value.id or "" famname = mw.wikibase.getSitelink(p734id) or "" -- strip namespace and disambigation local pos = famname:find(":") or 0 famname = famname:sub(pos+1):gsub("%s%(.+%)$", "") if famname == "" then local lbl = mw.wikibase.getLabel(p734id) famname = lbl and mw.text.nowiki(lbl) or "" end end local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 local qualID = mw.text.trim(args.qual or ""):upper() if qualID == "" then qualID = nil end local out = {} for k, v in ipairs(statements1) do if not onlysrc or sourced(v) then local snak = v.mainsnak if snak.datatype == "wikibase-item" and snak.snaktype == "value" then local qid2 = snak.datavalue.value.id local statements2 = {} if args.reqranks.b then statements2 = mw.wikibase.getBestStatements(qid2, pid2) else statements2 = mw.wikibase.getAllStatements(qid2, pid2) end if statements2[1] and statements2[1].mainsnak.snaktype == "value" then local qid3 = statements2[1].mainsnak.datavalue.value.id local sitelink = mw.wikibase.getSitelink(qid3) -- if there's no local sitelink, create the sitelink from English label if not sitelink then local lbl = mw.wikibase.getLabelByLang(qid3, "en") if lbl then if lbl:sub(1,9) == "Category:" then sitelink = mw.text.nowiki(lbl) else sitelink = "Category:" .. mw.text.nowiki(lbl) end end end if sitelink then if sk ~= "" then out[#out+1] = "[[" .. lp .. sitelink .. "|" .. sk .. "]]" elseif famname ~= "" then out[#out+1] = "[[" .. lp .. sitelink .. "|" .. famname .. "]]" else out[#out+1] = "[[" .. lp .. sitelink .. "]]" end -- of check for sort keys end -- of test for sitelink end -- of test for category end -- of test for wikibase item has a value end -- of test for sourced if maxvals > 0 and #out >= maxvals then break end end -- of loop through values of property1 return assembleoutput(out, args, qid1, pid1) end ------------------------------------------------------------------------------- -- getIntersectCat takes most of the usual parameters. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented -- It takes two properties, |prop1 and |prop2 (e.g. occupation and country of citizenship) -- Each property's value is a wiki-base entity -- For each value of the first parameter (ranks implemented) it fetches the value's main category -- and then each value of the second parameter (possibly substituting a simpler description) -- then it returns all of the categories representing the intersection of those properties, -- (e.g. Category:Actors from Canada). A joining term may be supplied (e.g. |join=from). -- The item's P734 (family name) is the sort key, or no sort key if there is no family name. -- The sort key may be overridden by the parameter |sortkey (alias |sk). ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput; ------------------------------------------------------------------------------- p.getIntersectCat = function(frame) frame.args.reqranks = setRanks(frame.args.rank) frame.args.langobj = findLang(frame.args.lang) frame.args.lang = frame.args.langobj.code local args = frame.args args.sep = " " args.linked = "no" local pid1 = args.prop1 or "P106" local pid2 = args.prop2 or "P27" if pid1 == "" or pid2 == "" then return nil end local qid, statements1 = parseInput(frame, "", pid1) if not qid then return nil end local qid, statements2 = parseInput(frame, "", pid2) if not qid then return nil end -- topics like countries may have different names in categories from their label in Wikidata local subs_exists, subs = pcall(mw.loadData, "Module:WikidataIB/subs") local join = args.join or "" local onlysrc = parseParam(args.onlysourced or args.osd, true) local maxvals = tonumber(args.maxvals) or 0 -- linkprefix (strip quotes) local lp = (args.linkprefix or args.lp or ""):gsub('"', '') -- sort key (strip quotes, hyphens and periods): local sk = (args.sortkey or args.sk or ""):gsub('["-.]', '') -- family name: local famname = "" if sk == "" then local p734 = mw.wikibase.getBestStatements(qid, "P734")[1] local p734id = p734 and p734.mainsnak.snaktype == "value" and p734.mainsnak.datavalue.value.id or "" famname = mw.wikibase.getSitelink(p734id) or "" -- strip namespace and disambigation local pos = famname:find(":") or 0 famname = famname:sub(pos+1):gsub("%s%(.+%)$", "") if famname == "" then local lbl = mw.wikibase.getLabel(p734id) famname = lbl and mw.text.nowiki(lbl) or "" end end local cat1 = {} for k, v in ipairs(statements1) do if not onlysrc or sourced(v) then -- get the ID representing the value of the property local pvalID = (v.mainsnak.snaktype == "value") and v.mainsnak.datavalue.value.id if pvalID then -- get the topic's main category (P910) for that entity local p910 = mw.wikibase.getBestStatements(pvalID, "P910")[1] if p910 and p910.mainsnak.snaktype == "value" then local tmcID = p910.mainsnak.datavalue.value.id -- use sitelink or the English label for the cat local cat = mw.wikibase.getSitelink(tmcID) if not cat then local lbl = mw.wikibase.getLabelByLang(tmcID, "en") if lbl then if lbl:sub(1,9) == "Category:" then cat = mw.text.nowiki(lbl) else cat = "Category:" .. mw.text.nowiki(lbl) end end end cat1[#cat1+1] = cat end -- of test for topic's main category exists end -- of test for property has vaild value end -- of test for sourced if maxvals > 0 and #cat1 >= maxvals then break end end local cat2 = {} for k, v in ipairs(statements2) do if not onlysrc or sourced(v) then local cat = rendersnak(v, args) if subs[cat] then cat = subs[cat] end cat2[#cat2+1] = cat end if maxvals > 0 and #cat2 >= maxvals then break end end local out = {} for k1, v1 in ipairs(cat1) do for k2, v2 in ipairs(cat2) do if sk ~= "" then out[#out+1] = "[[" .. lp .. v1 .. " " .. join .. " " .. v2 .. "|" .. sk .. "]]" elseif famname ~= "" then out[#out+1] = "[[" .. lp .. v1 .. " " .. join .. " " .. v2 .. "|" .. famname .. "]]" else out[#out+1] = "[[" .. lp .. v1 .. " " .. join .. " " .. v2 .. "]]" end -- of check for sort keys end end args.noicon = "true" return assembleoutput(out, args, qid, pid1) end ------------------------------------------------------------------------------- -- qualsToTable takes most of the usual parameters. -- The usual whitelisting, blacklisting, onlysourced, etc. are implemented. -- A qid may be given, and the first unnamed parameter is the property ID, which is of type wikibase item. -- It takes a list of qualifier property IDs as |quals= -- For a given qid and property, it creates the rows of an html table, -- each row being a value of the property (optionally only if the property matches the value in |pval= ) -- each cell being the first value of the qualifier corresponding to the list in |quals ------------------------------------------------------------------------------- -- Dependencies: parseParam; setRanks; parseInput; sourced; ------------------------------------------------------------------------------- p.qualsToTable = function(frame) local args = frame.args local quals = args.quals or "" if quals == "" then return "" end args.reqranks = setRanks(args.rank) local propertyID = mw.text.trim(args[1] or "") local f = {} f.args = args local entityid, props = parseInput(f, "", propertyID) if not entityid then return "" end args.langobj = findLang(args.lang) args.lang = args.langobj.code local pval = args.pval or "" local qplist = mw.text.split(quals, "%p") -- split at punctuation and make a sequential table for i, v in ipairs(qplist) do qplist[i] = mw.text.trim(v):upper() -- remove whitespace and capitalise end local col1 = args.firstcol or "" if col1 ~= "" then col1 = col1 .. "</td><td>" end local emptycell = args.emptycell or "&nbsp;" -- construct a 2-D array of qualifier values in qvals local qvals = {} for i, v in ipairs(props) do local skip = false if pval ~= "" then local pid = v.mainsnak.datavalue and v.mainsnak.datavalue.value.id if pid ~= pval then skip = true end end if not skip then local qval = {} local vqualifiers = v.qualifiers or {} -- go through list of wanted qualifier properties for i1, v1 in ipairs(qplist) do -- check for that property ID in the statement's qualifiers local qv, qtype if vqualifiers[v1] then qtype = vqualifiers[v1][1].datatype if qtype == "time" then if vqualifiers[v1][1].snaktype == "value" then qv = mw.wikibase.renderSnak(vqualifiers[v1][1]) qv = frame:expandTemplate{title="dts", args={qv}} else qv = "?" end elseif qtype == "url" then if vqualifiers[v1][1].snaktype == "value" then qv = mw.wikibase.renderSnak(vqualifiers[v1][1]) local display = mw.ustring.match( mw.uri.decode(qv, "WIKI"), "([%w ]+)$" ) if display then qv = "[" .. qv .. " " .. display .. "]" end end else qv = mw.wikibase.formatValue(vqualifiers[v1][1]) end end -- record either the value or a placeholder qval[i1] = qv or emptycell end -- of loop through list of qualifiers -- add the list of qualifier values as a "row" in the main list qvals[#qvals+1] = qval end end -- of for each value loop local out = {} for i, v in ipairs(qvals) do out[i] = "<tr><td>" .. col1 .. table.concat(qvals[i], "</td><td>") .. "</td></tr>" end return table.concat(out, "\n") end ------------------------------------------------------------------------------- -- getGlobe takes an optional qid of a Wikidata entity passed as |qid= -- otherwise it uses the linked item for the current page. -- If returns the Qid of the globe used in P625 (coordinate location), -- or nil if there isn't one. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getGlobe = function(frame) local qid = frame.args.qid or frame.args[1] or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end local coords = mw.wikibase.getBestStatements(qid, "P625")[1] local globeid if coords and coords.mainsnak.snaktype == "value" then globeid = coords.mainsnak.datavalue.value.globe:match("(Q%d+)") end return globeid end ------------------------------------------------------------------------------- -- getCommonsLink takes an optional qid of a Wikidata entity passed as |qid= -- It returns one of the following in order of preference: -- the Commons sitelink of the linked Wikidata item; -- the Commons sitelink of the topic's main category of the linked Wikidata item; ------------------------------------------------------------------------------- -- Dependencies: _getCommonslink(); _getSitelink(); parseParam() ------------------------------------------------------------------------------- p.getCommonsLink = function(frame) local oc = frame.args.onlycat or frame.args.onlycategories local fb = parseParam(frame.args.fallback or frame.args.fb, true) return _getCommonslink(frame.args.qid, oc, fb) end ------------------------------------------------------------------------------- -- getSitelink takes the qid of a Wikidata entity passed as |qid= -- It takes an optional parameter |wiki= to determine which wiki is to be checked for a sitelink -- If the parameter is blank, then it uses the local wiki. -- If there is a sitelink to an article available, it returns the plain text link to the article -- If there is no sitelink, it returns nil. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getSiteLink = function(frame) return _getSitelink(frame.args.qid, frame.args.wiki or mw.text.trim(frame.args[1] or "")) end ------------------------------------------------------------------------------- -- getLink has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= -- If there is a sitelink to an article on the local Wiki, it returns a link to the article -- with the Wikidata label as the displayed text. -- If there is no sitelink, it returns the label as plain text. -- If there is no label in the local language, it displays the qid instead. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getLink = function(frame) local itemID = mw.text.trim(frame.args[1] or frame.args.qid or "") if itemID == "" then return end local sitelink = mw.wikibase.getSitelink(itemID) local label = labelOrId(itemID) if sitelink then return "[[:" .. sitelink .. "|" .. label .. "]]" else return label end end ------------------------------------------------------------------------------- -- getLabel has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= -- It returns the Wikidata label for the local language as plain text. -- If there is no label in the local language, it displays the qid instead. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getLabel = function(frame) local itemID = mw.text.trim(frame.args[1] or frame.args.qid or "") if itemID == "" then return end local lang = frame.args.lang or "" if lang == "" then lang = nil end local label = labelOrId(itemID, lang) return label end ------------------------------------------------------------------------------- -- label has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= -- if no qid is supplied, it uses the qid associated with the current page. -- It returns the Wikidata label for the local language as plain text. -- If there is no label in the local language, it returns nil. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.label = function(frame) local qid = mw.text.trim(frame.args[1] or frame.args.qid or "") if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return end local lang = frame.args.lang or "" if lang == "" then lang = nil end local label, success = labelOrId(qid, lang) if success then return label end end ------------------------------------------------------------------------------- -- getAT (Article Title) -- has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= -- If there is a sitelink to an article on the local Wiki, it returns the sitelink as plain text. -- If there is no sitelink or qid supplied, it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAT = function(frame) local itemID = mw.text.trim(frame.args[1] or frame.args.qid or "") if itemID == "" then return end return mw.wikibase.getSitelink(itemID) end ------------------------------------------------------------------------------- -- getDescription has the qid of a Wikidata entity passed as |qid= -- (it defaults to the associated qid of the current article if omitted) -- and a local parameter passed as the first unnamed parameter. -- Any local parameter passed (other than "Wikidata" or "none") becomes the return value. -- It returns the article description for the Wikidata entity if the local parameter is "Wikidata". -- Nothing is returned if the description doesn't exist or "none" is passed as the local parameter. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getDescription = function(frame) local desc = mw.text.trim(frame.args[1] or "") local itemID = mw.text.trim(frame.args.qid or "") if itemID == "" then itemID = nil end if desc:lower() == 'wikidata' then return mw.wikibase.getDescription(itemID) elseif desc:lower() == 'none' then return nil else return desc end end ------------------------------------------------------------------------------- -- getAliases has the qid of a Wikidata entity passed as |qid= -- (it defaults to the associated qid of the current article if omitted) -- and a local parameter passed as the first unnamed parameter. -- It implements blacklisting and whitelisting with a field name of "alias" by default. -- Any local parameter passed becomes the return value. -- Otherwise it returns the aliases for the Wikidata entity with the usual list options. -- Nothing is returned if the aliases do not exist. ------------------------------------------------------------------------------- -- Dependencies: findLang(); assembleoutput() ------------------------------------------------------------------------------- p.getAliases = function(frame) local args = frame.args local fieldname = args.name or "" if fieldname == "" then fieldname = "alias" end local blacklist = args.suppressfields or args.spf or "" if blacklist:find(fieldname) then return nil end local localval = mw.text.trim(args[1] or "") if localval ~= "" then return localval end local whitelist = args.fetchwikidata or args.fwd or "" if whitelist == "" then whitelist = "NONE" end if not (whitelist == 'ALL' or whitelist:find(fieldname)) then return nil end local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid or not mw.wikibase.entityExists(qid) then return nil end local aliases = mw.wikibase.getEntity(qid).aliases if not aliases then return nil end args.langobj = findLang(args.lang) local langcode = args.langobj.code args.lang = langcode local out = {} for k1, v1 in pairs(aliases) do if v1[1].language == langcode then for k1, v2 in ipairs(v1) do out[#out+1] = v2.value end break end end return assembleoutput(out, args, qid) end ------------------------------------------------------------------------------- -- pageId returns the page id (entity ID, Qnnn) of the current page -- returns nothing if the page is not connected to Wikidata ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.pageId = function(frame) return mw.wikibase.getEntityIdForCurrentPage() end ------------------------------------------------------------------------------- -- formatDate is a wrapper to export the private function format_Date ------------------------------------------------------------------------------- -- Dependencies: format_Date(); ------------------------------------------------------------------------------- p.formatDate = function(frame) return format_Date(frame.args[1], frame.args.df, frame.args.bc) end ------------------------------------------------------------------------------- -- location is a wrapper to export the private function _location -- it takes the entity-id as qid or the first unnamed parameter -- optional boolean parameter first toggles the display of the first item -- optional boolean parameter skip toggles the display to skip to the last item -- parameter debug=<y/n> (default 'n') adds error msg if not a location ------------------------------------------------------------------------------- -- Dependencies: _location(); ------------------------------------------------------------------------------- p.location = function(frame) local debug = (frame.args.debug or ""):sub(1, 1):lower() if debug == "" then debug = "n" end local qid = mw.text.trim(frame.args.qid or frame.args[1] or ""):upper() if qid == "" then qid=mw.wikibase.getEntityIdForCurrentPage() end if not qid then if debug ~= "n" then return i18n.errors["entity-not-found"] else return nil end end local first = mw.text.trim(frame.args.first or "") local skip = mw.text.trim(frame.args.skip or "") return table.concat( _location(qid, first, skip), ", " ) end ------------------------------------------------------------------------------- -- checkBlacklist implements a test to check whether a named field is allowed -- returns true if the field is not blacklisted (i.e. allowed) -- returns false if the field is blacklisted (i.e. disallowed) -- {{#if:{{#invoke:WikidataIB |checkBlacklist |name=Joe |suppressfields=Dave; Joe; Fred}} | not blacklisted | blacklisted}} -- displays "blacklisted" -- {{#if:{{#invoke:WikidataIB |checkBlacklist |name=Jim |suppressfields=Dave; Joe; Fred}} | not blacklisted | blacklisted}} -- displays "not blacklisted" ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.checkBlacklist = function(frame) local blacklist = frame.args.suppressfields or frame.args.spf or "" local fieldname = frame.args.name or "" if blacklist ~= "" and fieldname ~= "" then if blacklist:find(fieldname) then return false else return true end else -- one of the fields is missing: let's call that "not on the list" return true end end ------------------------------------------------------------------------------- -- emptyor returns nil if its first unnamed argument is just punctuation, whitespace or html tags -- otherwise it returns the argument unchanged (including leading/trailing space). -- If the argument may contain "=", then it must be called explicitly: -- |1=arg -- (In that case, leading and trailing spaces are trimmed) -- It finds use in infoboxes where it can replace tests like: -- {{#if: {{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}} | <span class="xxx">{{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}}</span> | }} -- with a form that uses just a single call to Wikidata: -- {{#invoke |WikidataIB |emptyor |1= <span class="xxx">{{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}}</span> }} ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.emptyor = function(frame) local s = frame.args[1] or "" if s == "" then return nil end local sx = s:gsub("%s", ""):gsub("<[^>]*>", ""):gsub("%p", "") if sx == "" then return nil else return s end end ------------------------------------------------------------------------------- -- labelorid is a public function to expose the output of labelOrId() -- Pass the Q-number as |qid= or as an unnamed parameter. -- It returns the Wikidata label for that entity or the qid if no label exists. ------------------------------------------------------------------------------- -- Dependencies: labelOrId ------------------------------------------------------------------------------- p.labelorid = function(frame) return (labelOrId(frame.args.qid or frame.args[1])) end ------------------------------------------------------------------------------- -- getLang returns the MediaWiki language code of the current content. -- If optional parameter |style=full, it returns the language name. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getLang = function(frame) local style = (frame.args.style or ""):lower() local langcode = mw.language.getContentLanguage().code if style == "full" then return mw.language.fetchLanguageName( langcode ) end return langcode end ------------------------------------------------------------------------------- -- getItemLangCode takes a qid parameter (using the current page's qid if blank) -- If the item for that qid has property country (P17) it looks at the first preferred value -- If the country has an official language (P37), it looks at the first preferred value -- If that official language has a language code (P424), it returns the first preferred value -- Otherwise it returns nothing. ------------------------------------------------------------------------------- -- Dependencies: _getItemLangCode() ------------------------------------------------------------------------------- p.getItemLangCode = function(frame) return _getItemLangCode(frame.args.qid or frame.args[1]) end ------------------------------------------------------------------------------- -- findLanguage exports the local findLang() function -- It takes an optional language code and returns, in order of preference: -- the code if a known language; -- the user's language, if set; -- the server's content language. ------------------------------------------------------------------------------- -- Dependencies: findLang ------------------------------------------------------------------------------- p.findLanguage = function(frame) return findLang(frame.args.lang or frame.args[1]).code end ------------------------------------------------------------------------------- -- getQid returns the qid, if supplied -- failing that, the Wikidata entity ID of the "category's main topic (P301)", if it exists -- failing that, the Wikidata entity ID associated with the current page, if it exists -- otherwise, nothing ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getQid = function(frame) local qid = (frame.args.qid or ""):upper() -- check if a qid was passed; if so, return it: if qid ~= "" then return qid end -- check if there's a "category's main topic (P301)": qid = mw.wikibase.getEntityIdForCurrentPage() if qid then local prop301 = mw.wikibase.getBestStatements(qid, "P301") if prop301[1] then local mctid = prop301[1].mainsnak.datavalue.value.id if mctid then return mctid end end end -- otherwise return the page qid (if any) return qid end ------------------------------------------------------------------------------- -- followQid takes four optional parameters: qid, props, list and all. -- If qid is not given, it uses the qid for the connected page -- or returns nil if there isn't one. -- props is a list of properties, separated by punctuation. -- If props is given, the Wikidata item for the qid is examined for each property in turn. -- If that property contains a value that is another Wikibase-item, that item's qid is returned, -- and the search terminates, unless |all=y when all of the qids are returned, separated by spaces. -- If |list= is set to a template, the qids are passed as arguments to the template. -- If props is not given, the qid is returned. ------------------------------------------------------------------------------- -- Dependencies: parseParam() ------------------------------------------------------------------------------- p._followQid = function(args) local qid = (args.qid or ""):upper() local all = parseParam(args.all, false) local list = args.list or "" if list == "" then list = nil end if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end local out = {} local props = (args.props or ""):upper() if props ~= "" then for p in mw.text.gsplit(props, "%p") do -- split at punctuation and iterate p = mw.text.trim(p) for i, v in ipairs( mw.wikibase.getBestStatements(qid, p) ) do local linkedid = v.mainsnak.datavalue and v.mainsnak.datavalue.value.id if linkedid then if all then out[#out+1] = linkedid else return linkedid end -- test for all or just the first one found end -- test for value exists for that property end -- loop through values of property to follow end -- loop through list of properties to follow end if #out > 0 then local ret = "" if list then ret = mw.getCurrentFrame():expandTemplate{title = list, args = out} else ret = table.concat(out, " ") end return ret else return qid end end p.followQid = function(frame) return p._followQid(frame.args) end ------------------------------------------------------------------------------- -- globalSiteID returns the globalSiteID for the current wiki -- e.g. returns "enwiki" for the English Wikipedia, "enwikisource" for English Wikisource, etc. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.globalSiteID = function(frame) return mw.wikibase.getGlobalSiteId() end ------------------------------------------------------------------------------- -- siteID returns the root of the globalSiteID -- e.g. "en" for "enwiki", "enwikisource", etc. -- treats "en-gb" as "en", etc. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.siteID = function(frame) local txtlang = frame:callParserFunction('int', {'lang'}) or "" -- This deals with specific exceptions: be-tarask -> be-x-old if txtlang == "be-tarask" then return "be_x_old" end local pos = txtlang:find("-") local ret = "" if pos then ret = txtlang:sub(1, pos-1) else ret = txtlang end return ret end ------------------------------------------------------------------------------- -- projID returns the code used to link to the reader's language's project -- e.g "en" for [[:en:WikidataIB]] -- treats "en-gb" as "en", etc. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.projID = function(frame) local txtlang = frame:callParserFunction('int', {'lang'}) or "" -- This deals with specific exceptions: be-tarask -> be-x-old if txtlang == "be-tarask" then return "be-x-old" end local pos = txtlang:find("-") local ret = "" if pos then ret = txtlang:sub(1, pos-1) else ret = txtlang end return ret end ------------------------------------------------------------------------------- -- formatNumber formats a number according to the the supplied language code ("|lang=") -- or the default language if not supplied. -- The number is the first unnamed parameter or "|num=" ------------------------------------------------------------------------------- -- Dependencies: findLang() ------------------------------------------------------------------------------- p.formatNumber = function(frame) local lang local num = tonumber(frame.args[1] or frame.args.num) or 0 lang = findLang(frame.args.lang) return lang:formatNum( num ) end ------------------------------------------------------------------------------- -- examine dumps the property (the unnamed parameter or pid) -- from the item given by the parameter 'qid' (or the other unnamed parameter) -- or from the item corresponding to the current page if qid is not supplied. -- e.g. {{#invoke:WikidataIB |examine |pid=P26 |qid=Q42}} -- or {{#invoke:WikidataIB |examine |P26 |Q42}} or any combination of these -- or {{#invoke:WikidataIB |examine |P26}} for the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.examine = function( frame ) local args if frame.args[1] or frame.args.pid or frame.args.qid then args = frame.args else args = frame:getParent().args end local par = {} local pid = (args.pid or ""):upper() local qid = (args.qid or ""):upper() par[1] = mw.text.trim( args[1] or "" ):upper() par[2] = mw.text.trim( args[2] or "" ):upper() table.sort(par) if par[2]:sub(1,1) == "P" then par[1], par[2] = par[2], par[1] end if pid == "" then pid = par[1] end if qid == "" then qid = par[2] end local q1 = qid:sub(1,1) if pid:sub(1,1) ~= "P" then return "No property supplied" end if q1 ~= "Q" and q1 ~= "M" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return "No item for this page" end return "<pre>" .. mw.dumpObject( mw.wikibase.getAllStatements( qid, pid ) ) .. "</pre>" end ------------------------------------------------------------------------------- -- checkvalue looks for 'val' as a wikibase-item value of a property (the unnamed parameter or pid) -- from the item given by the parameter 'qid' -- or from the Wikidata item associated with the current page if qid is not supplied. -- It only checks ranks that are requested (preferred and normal by default) -- If property is not supplied, then P31 (instance of) is assumed. -- It returns val if found or nothing if not found. -- e.g. {{#invoke:WikidataIB |checkvalue |val=Q5 |pid=P31 |qid=Q42}} -- or {{#invoke:WikidataIB |checkvalue |val=Q5 |P31 |qid=Q42}} -- or {{#invoke:WikidataIB |checkvalue |val=Q5 |qid=Q42}} -- or {{#invoke:WikidataIB |checkvalue |val=Q5 |P31}} for the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.checkvalue = function( frame ) local args if frame.args.val then args = frame.args else args = frame:getParent().args end local val = args.val if not val then return nil end local pid = mw.text.trim(args.pid or args[1] or "P31"):upper() local qid = (args.qid or ""):upper() if pid:sub(1,1) ~= "P" then return nil end if qid:sub(1,1) ~= "Q" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end local ranks = setRanks(args.rank) local stats = {} if ranks.b then stats = mw.wikibase.getBestStatements(qid, pid) else stats = mw.wikibase.getAllStatements( qid, pid ) end if not stats[1] then return nil end if stats[1].mainsnak.datatype == "wikibase-item" then for k, v in pairs( stats ) do local ms = v.mainsnak if ranks[v.rank:sub(1,1)] and ms.snaktype == "value" and ms.datavalue.value.id == val then return val end end end return nil end ------------------------------------------------------------------------------- -- url2 takes a parameter url= that is a proper url and formats it for use in an infobox. -- If no parameter is supplied, it returns nothing. -- This is the equivalent of Template:URL -- but it keeps the "edit at Wikidata" pen icon out of the microformat. -- Usually it will take its url parameter directly from a Wikidata call: -- e.g. {{#invoke:WikidataIB |url2 |url={{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no}} }} ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.url2 = function(frame) local txt = frame.args.url or "" if txt == "" then return nil end -- extract any icon local url, icon = txt:match("(.+)&nbsp;(.+)") -- make sure there's at least a space at the end url = (url or txt) .. " " icon = icon or "" -- extract any protocol like https:// local prot = url:match("(https*://).+[ \"\']") -- extract address local addr = "" if prot then addr = url:match("https*://(.+)[ \"\']") or " " else prot = "//" addr = url:match("[^%p%s]+%.(.+)[ \"\']") or " " end -- strip trailing / from end of domain-only url and add <wbr/> before . and / local disp, n = addr:gsub( "^([^/]+)/$", "%1" ):gsub("%/", "<wbr/>/"):gsub("%.", "<wbr/>.") return '<span class="url">[' .. prot .. addr .. " " .. disp .. "]</span>&nbsp;" .. icon end ------------------------------------------------------------------------------- -- getWebsite fetches the Official website (P856) and formats it for use in an infobox. -- This is similar to Template:Official website but with a url displayed, -- and it adds the "edit at Wikidata" pen icon beyond the microformat if enabled. -- A local value will override the Wikidata value. "NONE" returns nothing. -- e.g. {{#invoke:WikidataIB |getWebsite |qid= |noicon= |lang= |url= }} ------------------------------------------------------------------------------- -- Dependencies: findLang(); parseParam(); ------------------------------------------------------------------------------- p.getWebsite = function(frame) local url = frame.args.url or "" if url:upper() == "NONE" then return nil end local urls = {} local quals = {} local qid = frame.args.qid or "" if url and url ~= "" then urls[1] = url else if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return nil end local prop856 = mw.wikibase.getBestStatements(qid, "P856") for k, v in pairs(prop856) do if v.mainsnak.snaktype == "value" then urls[#urls+1] = v.mainsnak.datavalue.value if v.qualifiers and v.qualifiers["P1065"] then -- just take the first archive url (P1065) local au = v.qualifiers["P1065"][1] if au.snaktype == "value" then quals[#urls] = au.datavalue.value end -- test for archive url having a value end -- test for qualifers end -- test for website having a value end -- loop through website(s) end if #urls == 0 then return nil end local out = {} for i, u in ipairs(urls) do local link = quals[i] or u local prot, addr = u:match("(http[s]*://)(.+)") addr = addr or u local disp, n = addr:gsub("%.", "<wbr/>%.") out[#out+1] = '<span class="url">[' .. link .. " " .. disp .. "]</span>" end local langcode = findLang(frame.args.lang).code local noicon = parseParam(frame.args.noicon, false) if url == "" and not noicon then out[#out] = out[#out] .. createicon(langcode, qid, "P856") end local ret = "" if #out > 1 then ret = mw.getCurrentFrame():expandTemplate{title = "ubl", args = out} else ret = out[1] end return ret end ------------------------------------------------------------------------------- -- getAllLabels fetches the set of labels and formats it for display as wikitext. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllLabels = function(frame) local args = frame.args or frame:getParent().args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local labels = mw.wikibase.getEntity(qid).labels if not labels then return i18n["labels-not-found"] end local out = {} for k, v in pairs(labels) do out[#out+1] = v.value .. " (" .. v.language .. ")" end return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- getAllDescriptions fetches the set of descriptions and formats it for display as wikitext. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllDescriptions = function(frame) local args = frame.args or frame:getParent().args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local descriptions = mw.wikibase.getEntity(qid).descriptions if not descriptions then return i18n["descriptions-not-found"] end local out = {} for k, v in pairs(descriptions) do out[#out+1] = v.value .. " (" .. v.language .. ")" end return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- getAllAliases fetches the set of aliases and formats it for display as wikitext. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllAliases = function(frame) local args = frame.args or frame:getParent().args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local aliases = mw.wikibase.getEntity(qid).aliases if not aliases then return i18n["aliases-not-found"] end local out = {} for k1, v1 in pairs(aliases) do local lang = v1[1].language local val = {} for k1, v2 in ipairs(v1) do val[#val+1] = v2.value end out[#out+1] = table.concat(val, ", ") .. " (" .. lang .. ")" end return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- showNoLinks displays the article titles that should not be linked. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.showNoLinks = function(frame) local out = {} for k, v in pairs(donotlink) do out[#out+1] = k end table.sort( out ) return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- checkValidity checks whether the first unnamed parameter represents a valid entity-id, -- that is, something like Q1235 or P123. -- It returns the strings "true" or "false". -- Change false to nil to return "true" or "" (easier to test with #if:). ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- function p.checkValidity(frame) local id = mw.text.trim(frame.args[1] or "") if mw.wikibase.isValidEntityId(id) then return true else return false end end ------------------------------------------------------------------------------- -- getEntityFromTitle returns the Entity-ID (Q-number) for a given title. -- Modification of Module:ResolveEntityId -- The title is the first unnamed parameter. -- The site parameter determines the site/language for the title. Defaults to current wiki. -- The showdab parameter determines whether dab pages should return the Q-number or nil. Defaults to true. -- Returns the Q-number or nil if it does not exist. ------------------------------------------------------------------------------- -- Dependencies: parseParam ------------------------------------------------------------------------------- function p.getEntityFromTitle(frame) local args=frame.args if not args[1] then args=frame:getParent().args end if not args[1] then return nil end local title = mw.text.trim(args[1]) local site = args.site or "" local showdab = parseParam(args.showdab, true) local qid = mw.wikibase.getEntityIdForTitle(title, site) if qid then local prop31 = mw.wikibase.getBestStatements(qid, "P31")[1] if not showdab and prop31 and prop31.mainsnak.datavalue.value.id == "Q4167410" then return nil else return qid end end end ------------------------------------------------------------------------------- -- getDatePrecision returns the number representing the precision of the first best date value -- for the given property. -- It takes the qid and property ID -- The meanings are given at https://www.mediawiki.org/wiki/Wikibase/DataModel#Dates_and_times -- 0 = 1 billion years .. 6 = millennium, 7 = century, 8 = decade, 9 = year, 10 = month, 11 = day -- Returns 0 (or the second unnamed parameter) if the Wikidata does not exist. ------------------------------------------------------------------------------- -- Dependencies: parseParam; sourced; ------------------------------------------------------------------------------- function p.getDatePrecision(frame) local args=frame.args if not args[1] then args=frame:getParent().args end local default = tonumber(args[2] or args.default) or 0 local prop = mw.text.trim(args[1] or "") if prop == "" then return default end local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid then return default end local onlysrc = parseParam(args.onlysourced or args.osd, true) local stat = mw.wikibase.getBestStatements(qid, prop) for i, v in ipairs(stat) do local prec = (onlysrc == false or sourced(v)) and v.mainsnak.datavalue and v.mainsnak.datavalue.value and v.mainsnak.datavalue.value.precision if prec then return prec end end return default end return p ------------------------------------------------------------------------------- -- List of exported functions ------------------------------------------------------------------------------- --[[ _getValue getValue getPreferredValue getCoords getQualifierValue getSumOfParts getValueByQual getValueByLang getValueByRefSource getPropertyIDs getQualifierIDs getPropOfProp getAwardCat getIntersectCat getGlobe getCommonsLink getSiteLink getLink getLabel label getAT getDescription getAliases pageId formatDate location checkBlacklist emptyor labelorid getLang getItemLangCode findLanguage getQID followQid globalSiteID siteID projID formatNumber examine checkvalue url2 getWebsite getAllLabels getAllDescriptions getAllAliases showNoLinks checkValidity getEntityFromTitle getDatePrecision --]] ------------------------------------------------------------------------------- qqvq4ii6o0mcmkha80spepy37r91hfo کارخانه چینی زرین (موبارکه) 0 90550 390373 272310 2026-07-17T16:58:50Z ~2026-40347-12 46100 /* */ 390373 wikitext text/x-wiki {{ایران_روستائون_جعبه |رسمی_نوم‌=کارخانه چینی زرین |نقشه_سر= |جوغرافیائی‌عرض= |جوغرافیائی‌طول= |تصویر= |تصویر_اندازه= |تصویر_برچسب= |اوستان=اصفهان |شهرستون=مبارکه |بخش= [[گرکن جنوبی بخش|گرکن جنوبی]] |دهستون=نورآباد دهستان (مبارکه) |محلی_نوم= |دیگه_نوم‌ئون= |قدیمی_نوم‌ئون= |بساتن_گدر= |جمعیت= ۰ نفر |جمعیت_رشد= |جمعیت_انبسی= |زوون= |دین= |گتی= |ارتفاع= |دما_میونگین= |وارش_میونگین= |یخبندون= |دهیار= |سوغاتی= |پیش‌شوماره=۰۳۱ |سایت= |پانویس= }} '''کارخانه چینی زرین''' اتا روستایِ نوم هسته که [[اصفهان اوستان]] دله قرار دارنه و [[موبارکه شهرستان]] ِ[[گرکن جنوبی بخش]] دله دره. == جمعیت == اینتا روستا، [[نورآباد دهستان (موبارکه) دهستون]] شِنه و اینتی که [[ایران نفوس و مسکن عمومی سرشماری|ایران آمارِ سرشماری]] دله باتنه، [[نفوس و مسکن عمومی سرشماری (۱۳۹۵)|سال ۱۳۹۵]] ونه جمیعت ۰ نفر (۰خانوار) بی‌یه.<ref name=amar95>{{یادکرد وب|عنوان=تعداد جمعیت و خانوار به تفکیک تقسیمات کشوری براساس سرشماری عمومی نفوس و مسکن سال ۱۳۹۵|ناشر=درگاه ملی آمار|نشانی=https://www.amar.org.ir/سرشماری-عمومی-نفوس-و-مسکن/نتایج-سرشماری/جمعیت-به-تفکیک-تقسیمات-کشوری-سال-1395|تاریخ بازدید=۷ مه ۲۰۲۳ |تلمبار لینک = https://web.archive.org/web/20191113170923/https://www.amar.org.ir/%D8%B3%D8%B1%D8%B4%D9%85%D8%A7%D8%B1%DB%8C-%D8%B9%D9%85%D9%88%D9%85%DB%8C-%D9%86%D9%81%D9%88%D8%B3-%D9%88-%D9%85%D8%B3%DA%A9%D9%86/%D9%86%D8%AA%D8%A7%DB%8C%D8%AC-%D8%B3%D8%B1%D8%B4%D9%85%D8%A7%D8%B1%DB%8C/%D8%AC%D9%85%D8%B9%DB%8C%D8%AA-%D8%A8%D9%87-%D8%AA%D9%81%DA%A9%DB%8C%DA%A9-%D8%AA%D9%82%D8%B3%DB%8C%D9%85%D8%A7%D8%AA-%DA%A9%D8%B4%D9%88%D8%B1%DB%8C-%D8%B3%D8%A7%D9%84-1395 |تلمبار تاریخ= ۱۳ نوامبر ۲۰۱۹}}</ref> == منابع == {{پانویس}} {{موبارکه شهرستان|گرکن جنوبی بخش}} [[رج:موبارکه شهرستان روستائون|کارخانه چینی زرین]] [[fa:کارخانه چینی زرین (مبارکه)]] nejmwv197m8d4py6ctt9cvz8tr0anq3 ماژول:Cite Q 828 113720 390384 325774 2026-07-17T18:57:02Z محک 1023 390384 Scribunto text/plain local p = {} require('strict') local sandbox = '' local wdib = require('Module:WikidataIB' .. sandbox) local getValue = wdib._getValue local getValueFromSnaks = wdib._getValueFromSnaks local getPropOfProp = wdib._getPropOfProp local followQid = wdib._followQid local getPropertyIDs = wdib._getPropertyIDs local rtl_lang = {ar = true, fa = true, ur = true, ku = true, he = true, arc = true, dv = true, ha = true, khw = true, ks = true, ps = true, yi = true, ota = true } local ref_cash = {} local aliases = { ['accessdate'] = {'هارشی‌ین تاریخ','تاریخ بازدید', 'بازدید', 'access-date', 'accessdate'}, ['agency'] = {'آژانس', 'agency'}, ['archivedate'] = {'تلمبار تاریخ', 'تلنبار تاریخ', 'تاریخ بایگانی', 'archive-date', 'archivedate'}, ['archive-format'] = {'فرمت بایگانی', 'تلمبار شیوه', 'archive-format'}, ['archive-url'] = {'نشانی بایگانی', 'تلمبار لینک', 'نشانی_بایگانی', 'archive-url', 'archiveurl'}, ['article-number'] = {'رقم مقاله', 'article-number'}, ['asin-tld'] = 'asin-tld', ['at'] = {'در', 'at'}, --##TOREVISE ['authors'] = {'نویسنده', 'نویسندگون', 'authors', 'people', 'host', 'credits', 'نویسندگان'}, ['book-title'] = {'عنوان کتاب', 'book-title', 'booktitle', 'کتاب نوم'}, ['cartography'] = 'cartography', ['chapter'] = {'فصل', 'chapter', 'contribution', 'entry', 'article', 'section'}, ['chapter-format'] = {'صيغة-الفصل', 'صيغة الفصل', 'تنسيق الفصل', 'chapter-format', 'contribution-format', 'entry-format', 'article-format', 'section-format'}, ['chapter-url'] = {'نشانی فصل', 'فصل لینک', 'chapter-url', 'contribution-url', 'entry-url', 'article-url', 'section-url'}, -- Used by InternetArchiveBot ['chapter-url-access'] = {'chapter-url-access', 'contribution-url-access', 'entry-url-access', 'article-url-access', 'section-url-access'}, -- Used by InternetArchiveBot ['class'] = {'کلاس', 'class'}, -- cite arxiv and arxiv identifier ['collaboration'] = 'collaboration', ['conference'] = {'کنفرانس', 'کنفرانس نوم', 'conference'}, ['conference-format'] = 'conference-format', ['conference-url'] = {'نشانی کنفرانس', 'کنفرانس لینک', 'conference-url'}, -- Used by InternetArchiveBot ['date'] = {'سال', 'تاریخ', 'date', 'air-date', 'airdate'}, ['degree'] = {'درجه', 'degree'}, ['df'] = 'df', ['display-authors'] = {'نمایش نویسندگان', 'display-authors', 'display-subjects'}, ['display-contributors'] = 'display-contributors', ['display-editors'] = {'نمایش ویراستاران', 'display-editors'}, ['display-interviewers'] = 'display-interviewers', ['display-translators'] = 'display-translators', ['docket'] = 'docket', ['doi-broken-date'] = 'doi-broken-date', ['edition'] = {'دچی‌یه', 'دچی‌ین', 'ویرایش', 'نسخه', 'edition'}, ['pmc-embargo-date'] = 'pmc-embargo-date', ['encyclopedia'] = {'دانشنومه', 'encyclopedia', 'encyclopaedia', 'دانشنامه', 'dictionary', 'دایره المعارف'}, -- cite encyclopedia only ['episode'] = {'اپیزود', 'episode'}, -- cite serial only TODO: make available to cite episode? ['format'] = {'شیوه', 'format', 'فرمت', 'فورمت'}, ['id'] = {'id', 'ID', 'شناسه'}, ['inset'] = {'inset', 'مجموعه'}, ['issue'] = {'تعداد', 'issue', 'number'}, ['language'] = {'زوون', 'زبان', 'language', 'lang'}, ['mailing-list'] = {'میلینگ لیست', 'mailing-list'}, -- cite mailing list only ['map'] = {'نقشه', 'map'}, -- cite map only ['map-format'] = {'نقشه فورمت', 'map-format'}, -- cite map only ['map-url'] = {'نقشه لینک', 'map-url'}, -- cite map only -- Used by InternetArchiveBot ['map-url-access'] = 'map-url-access', -- cite map only -- Used by InternetArchiveBot ['minutes'] = {'دقه', 'minutes'}, ['mode'] = 'mode', ['name-list-style'] = 'name-list-style', ['network'] = {'شبکه', 'network'}, ['newsgroup'] = {'مجموعه نوم', 'newsgroup'}, -- cite newsgroup only ['nopp'] = {'no-pp', 'nopp'}, ['no-tracking'] = {'no-tracking', 'template-doc-demo'}, ['number'] = 'number', -- this case only for cite techreport ['orig-date'] = {'orig-date', 'orig-year', 'origyear', 'اصل نشر سال'}, ['others'] = {'دیگه','others', 'دیگرون', 'دیگران'}, ['page'] = {'صفحه', 'p', 'صفحات', 'page', 'ولگه', 'صفه','ص'}, -- Used by InternetArchiveBot ['pages'] = {'صص', 'صفحات', 'pp', 'ولگون', 'pages'}, -- Used by InternetArchiveBot ['journal'] = { 'ژورنال', 'journal', 'جورنال', 'مجله', 'magazine', 'مجله نوم', 'newspaper', 'روزنامه', 'روزنومه', 'فصلنامه', 'periodical', 'سایت', 'website', 'وبگاه', 'اثر', 'work', 'عمل', }, ['place'] = { 'مکان', 'place', 'جا', 'مقر', 'شهر', 'location'}, ['postscript'] = 'postscript', ['publication-date'] = {'نشر تاریخ', 'تاریخ نشر', 'publication-date'}, ['publication-place'] = {'محل نشر', 'مکان نشر', 'publication-place'}, ['publisher'] = {'ناشر', 'publisher', 'ناشرون', 'institution', 'تنک‌کر', 'مؤسسه'}, ['quote'] = {'اقتباس', 'quote', 'quotation'}, ['quote-page'] = 'quote-page', ['quote-pages'] = 'quote-pages', ['ref'] = {'مرجع', 'ref'}, ['scale'] = {'مقیاس', 'scale'}, ['script-chapter'] = {'script-chapter', 'script-contribution', 'script-entry', 'script-article', 'script-section'}, ['script-encyclopedia'] = {'script-encyclopedia', 'script-encyclopaedia'}, -- cite encyclopedia only ['script-map'] = 'script-map', ['script-journal'] = {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-website', 'script-work'}, ['script-quote'] = 'script-quote', ['script-title'] = 'script-title', -- Used by InternetArchiveBot ['season'] = {'فصل', 'season'}, ['sections'] = {'بخش', 'sections'}, -- cite map only ['series'] = {'سری', 'series', 'version'}, ['series-link'] = {'نشانی مجموعه', 'سری لینک', 'series-link', 'نشانی سری'}, ['series-number'] = {'شماره سری', 'سری شماره', 'series-number', 'series-no'}, ['sheet'] = {'ورق', 'sheet'}, -- cite map only ['sheets'] = {'اوراق', 'sheets'}, -- cite map only ['station'] = {'ایستگاه', 'station'}, ['time'] = {'زمون', 'time'}, ['time-caption'] = 'time-caption', ['title'] = {'عنوان', 'title', 'نوم'}, ['title-link'] = {'نشانی عنوان', 'عنوان لینک', 'title-link', 'episode-link', 'نشانی نام'}, ['title-note'] = {'title-note', 'department'}, ['type'] = {'نوع', 'type', 'medium'}, ['trans-chapter'] = {'trans-article', 'trans-chapter', 'trans-contribution', 'trans-entry', 'trans-section'}, ['transcript'] = 'transcript', ['transcript-format'] = 'transcript-format', ['transcript-url'] = 'transcript-url', -- Used by InternetArchiveBot ['trans-encyclopedia'] = {'trans-encyclopedia', 'trans-encyclopaedia'}, -- cite encyclopedia only ['trans-map'] = 'trans-map', -- cite map only ['trans-journal'] = {'trans-journal', 'trans-magazine', 'trans-newspaper', 'trans-periodical', 'trans-website', 'trans-work'}, ['trans-quote'] = 'trans-quote', ['trans-title'] = {'عنوان مترجم', 'عنوان دوم', 'عنوان فرعی', 'عنوان جانبی', 'trans-title', 'مترجم نوم'}, -- Used by InternetArchiveBot ['url'] = {'لینک', 'نشانی','پیوند', 'url', 'URL'}, -- Used by InternetArchiveBot ['url-access'] = {'url-access', 'التسجيل'}, -- Used by InternetArchiveBot ['url-status'] = {'url-status','حالة المسار'}, -- Used by InternetArchiveBot ['vauthors'] = {'vauthors', 'عدة مؤلفين'}, ['veditors'] = {'veditors', 'عدة محررين' }, ['via'] = {'عبر', 'via'}, ['volume'] = {'مجلد', 'volume', 'جلد', 'ج'}, ['wikidatacite'] = 'wikidatacite', ['year'] = {'سال', 'year', 'سنه'}, } local i18n = { ["unknown-author"] = mw.wikibase.getLabel("Q4233718"):gsub("^%l", mw.ustring.upper), -- Next Line Edited ["unknown-author-trackingcat"] = "", -- [[رج:Cite Q - author unknown]] ["ordinal"] = { [1] = "st", [2] = "nd", [3] = "rd", ["default"] = "th" }, ["months"] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }, ["ar"] = { illustrator = "نقاش", composer = "آهنگساز", animator = "انیماتور", director = "کارگردان", screenwriter = "سناریو", signatory = "توقیع", presenter = "تقدیم", performer = "اجرا", annotator = "تحقیق", reviewer = "ناظر", unknown = "مجهول", supervisor = "إشراف", ["unknown-publication-date"] = '<abbr class="abbr" title="بدون تاریخ">د.ت.</abbr>', ["unknown-publisher"] = '<abbr class="abbr" title="بدون ناشر">د.ن.</abbr>', wikidata = "ویکی‌دیتا" } } local rejected = { sources = { Q465 = true, Q15241312 = true, Q52 = true }, properties = { "P1800", "P1566", "P21"}, instances = { Q5 = true, -- Human is not a direct reference Q184188 = true, Q1250464 = true, -- inatance of refference DBs Q8513 = true, Q17152639 = true, Q7094076 = true, Q5535082 = true, Q856638= true, Q1982918 = true, Q36524 = true, Q36218176 = true, Q526334 = true, Q5227411 = true } } --[[-------------------< A R G U M E N T _ W R A P P E R >---------------------- Argument wrapper. This function provides support for argument mapping defined in the configuration file so that multiple names can be transparently aliased to single internal variable. ]] local function argument_wrapper ( arglist ) local origin = {}; local nilargs = {}; return setmetatable({ ORIGIN = function ( self, k ) local dummy = self[k]; -- force the variable to be loaded. return origin[k]; end }, { __index = function ( tbl, k ) local v = rawget(tbl,k) if v then return v elseif nilargs[k] then return nil end local list = (type(k)=="number") and k or aliases[k]; if type( list ) == 'table' then for _, alias_key in pairs( list ) do if arglist[alias_key] then v = arglist[alias_key] origin[k] = alias_key break; end end elseif list ~= nil then v = arglist[list] if v then origin[k] = list end end if v == nil then nilargs[k] = true else rawset( tbl, k, v ) end return v end, }); end ------------------------------------------------------------------------------- -- makeOrdinal needs to be internationalised along with the above i18n -- takes cardinal number as a numeric and returns the ordinal as a string -- we need three exceptions in English for 1st, 2nd, 3rd, 21st, .. 31st, etc. ------------------------------------------------------------------------------- p.makeOrdinal = function(cardinal) local card = tonumber(cardinal) if not card then return cardinal end local ordsuffix = i18n.ordinal.default if card % 10 == 1 then ordsuffix = i18n.ordinal[1] elseif card % 10 == 2 then ordsuffix = i18n.ordinal[2] elseif card % 10 == 3 then ordsuffix = i18n.ordinal[3] end -- In English, 1, 21, 31, etc. use 'st', but 11, 111, etc. use 'th' -- similarly for 12 and 13, etc. if (card % 100 == 11) or (card % 100 == 12) or (card % 100 == 13) then ordsuffix = i18n.ordinal.default end return card .. ordsuffix end -- Table of simple properties that can be fetched in roughly the same way: -- id = PXXX -- maxvals = maximum number of multiple values (0 for all) -- linked = "no" suppresses linking -- populate_from_journal = true/false determines whether to look in a journal where the source is published -- rank = "best", "preferred", normal, etc. determines how Wikidata ranks are treated -- others = true - the value for the property goes to "others" section local simple_properties = { -- Next Line Edited publisher = {id = "P123", maxvals = 3}, oclc = {id = "P243", maxvals = 1}, ['publication-place'] = {id = "P291", maxvals = 0, linked = 'no'}, -- publication place (don't put into |place=; is treated specially in {{citation}} if both are given) doi = {id = "P356", maxvals = 1}, -- take care of |doi-broken-date= (WD "reason for deprecation"/"stated as") and |doi-access= (WD "access status")? issue = {id = "P433", maxvals = 0, populate_from_journal = true}, -- distinguish from |number= ("P1545"?) if both are given (still blocked by {{citation}}, but will be supported in the future) pmid = {id = "P698", maxvals = 1}, mdid = {id = "P12914", maxvals = 1, populate_from_journal = true}, marefa = {id = "P14250", maxvals = 1, populate_from_journal = true}, -- gbooks = {id = "P675", maxvals = 1}, -- to be added to {{citation}} -- ia = {id = "P724", maxvals = 1}, -- to be added to {{citation}} arxiv = {id = "P818", maxvals = 1}, bibcode = {id = "P819", maxvals = 1}, -- take care of |bibcode-access=? jstor = {id = "P888", maxvals = 1}, -- take care of |jstor-access=? mr = {id = "P889", maxvals = 1}, rfc = {id = "P892", maxvals = 1}, zbl = {id = "P894", maxvals = 1}, ssrn = {id = "P893", maxvals = 1}, place = {id = "P1071", maxvals = 0, linked = 'no'}, -- written-at place -- ['total-pages'] = {id = "P1104", maxvals = 0, linked = 'no'}, -- to be added to {{citation}} / COinS &rft.tpages= -- coden = {id = "P1159", maxvals = 1}, -- to be added to {{citation}} / COinS &rft.coden= s2cid = {id = "P8299", maxvals = 1}, -- take care of |s2cid-access=? pmc = {id = "P932", maxvals = 1}, -- take care of |pmc-embargo-date= (WD "reason for deprecation")? lccn = {id = "P1144", maxvals = 1}, hdl = {id = "P1184", maxvals = 1}, -- take care of |hdl-access=? ismn = {id = "P1208", maxvals = 1}, journal = {id = "P1433", maxvals = 1}, citeseerx = {id = "P3784", maxvals = 1}, osti = {id = "P3894", maxvals = 1}, -- take care of |osti-access=? biorxiv = {id = "P3951", maxvals = 1}, asin = {id = "P5749", maxvals = 1}, -- What about |asin-tld=? (WD examples resolve to .com at present, but may change) -- ['catalog-number'] = {id = "P528", maxvals = 0}, -- to be added to {{citation}} / COinS &rft.artnum= isbn = {id = "P212", maxvals = 1, populate_from_journal = true}, -- ISBN 13 issn = {id = "P236", maxvals = 1, populate_from_journal = true}, -- distinguish from |eissn= for electronic issues? -- jfm = {id = "P?", maxvals = 1}, -- Jahrbuch über die Fortschritte der Mathematik (not Zbl) -- sbn = {id = "P?", maxvals = 1}, -- Standard Book Number (predecessor of ISBN, not ICCU) -- message-id = {id = "P?", maxvals = 1}, -- Usenet message ID chapter = {id = "P792", maxvals = 1}, ['publication-date'] = {id = "P577", maxvals = 1, populate_from_journal = true}, -- publication date (don't use |date=; is treated specially in {{citation}} if both are given.) series = {id = "P179", maxvals = 1, populate_from_journal = true, qual = "P1545"}, version = {id = "P348", maxvals = 0}, edition = {id = "P393", maxvals = 0}, volume = {id = "P478", maxvals = 0, populate_from_journal = true}, -- part = {id = "P1545"?, maxvals = 0}, -- to be added to {{citation}} / COinS &rft.part= title = {id = "P1476", rank="p n"}, -- url = {id = "P953", maxvals = 1}, -- deal with this along with archive-url pages = {id = "P304", maxvals = 0, populate_from_journal = true}, at = {id = "P958", maxvals = 0, populate_from_journal = true}, -- also incorporate lines (P7421) and columns (P3903) into this (cite map also supports |section=) -- sheets = {id = "P7416", maxvals = 0, populate_from_journal = true}, -- interviewer = {id = "P?", maxvals = 0}, -- does **not** go to "others" section! Multiple interviewers should be n-enumerated illustrator = {id = "P110", maxvals = 10, others = true}, -- goes to "others" section -- foreword and afterword, when contributions to another author's work, are contributions so belong in |contribution=; -- the writer's name goes in |contributor=; requires |title= and |author= -- However, this might need to add support for multiple contributors and their roles to {{citation}}, see Help_talk:Citation_Style_1#Others -- foreword = {id = "P2679", maxvals = 10, others = true}, -- goes to "others" section -- afterword = {id = "P2680", maxvals = 10, others = true}, -- goes to "others" section composer = {id = "P86", maxvals = 10, others = true}, -- goes to "others" section animator = {id = "P6942", maxvals = 10, others = true}, -- goes to "others" section director = {id = "P57", maxvals = 10, others = true}, -- goes to "others" section screenwriter = {id = "P58", maxvals = 10, others = true}, -- goes to "others" section signatory = {id = "P1891", maxvals = 10, others = true}, -- goes to "others" section presenter = {id = "P371", maxvals = 10, others = true}, -- goes to "others" section performer = {id = "P175", maxvals = 10, others = true}, -- goes to "others" section -- next 2 lines added for Arabic Wikipedia annotator = {id ="P11105", maxvals = 10, others = true}, -- goes to "others" section reviewer = {id ="P4032", maxvals = 10, others = true}, -- goes to "others" section supervisor = {id ="P7604", maxvals = 3, others = true}, -- goes to "others" section } local used_args = {accessdate=true, language=true, mode=true, ol=true, other=true, ['display-authors']=true, ['display-editors']=true, ['archive-url']=true, ['archive-date']=true, url=true, title=true} -- all_used_properties local used_properties = { P1071 = {arg= "place", maxvals = 0, linked = 'no'}, -- written-at place P110 = {arg= "illustrator", maxvals = 10, others = true}, -- goes to "others" section P11105 = {arg= "annotator", maxvals = 10, others = true}, -- goes to "others" section P1144 = {arg= "lccn", maxvals = 1}, P1184 = {arg= "hdl", maxvals = 1}, -- take care of |hdl-access=? P1208 = {arg= "ismn", maxvals = 1}, P123 = {arg= "publisher", maxvals = 3}, P1433 = {arg= "journal", maxvals = 1}, P1476 = {arg= "title", rank="p n"}, P1680 = true, P175 = {arg= "performer", maxvals = 10, others = true}, -- goes to "others" section P179 = {arg= "series", maxvals = 1, populate_from_journal = true}, P1891 = {arg= "signatory", maxvals = 10, others = true}, -- goes to "others" section P1932 = true, P2093 = true, -- author string P212 = {arg= "isbn", maxvals = 1, populate_from_journal = true}, -- ISBN 13 P236 = {arg= "issn", maxvals = 1, populate_from_journal = true}, -- distinguish from |eissn= for electronic issues? P243 = {arg= "oclc", maxvals = 1}, P14250 = {arg= "marefa", maxvals = 1, populate_from_journal = true}, P12914 = {arg= "mdid", maxvals = 1, populate_from_journal = true}, P2699 = true, P291 = {arg= "publication-place", maxvals = 0, linked = 'no'}, -- publication place (don't put into |place=; is treated specially in {{citation}} if both are given) P304 = {arg= "pages", maxvals = 0, populate_from_journal = true}, P348 = {arg= "version", maxvals = 0}, P356 = {arg= "doi", maxvals = 1}, -- take care of |doi-broken-date= (WD "reason for deprecation"/"stated as") and |doi-access= (WD "access status")? P371 = {arg= "presenter", maxvals = 10, others = true}, -- goes to "others" section P3784 = {arg= "citeseerx", maxvals = 1}, P3894 = {arg= "osti", maxvals = 1}, -- take care of |osti-access=? P393 = {arg= "edition", maxvals = 0}, P3951 = {arg= "biorxiv", maxvals = 1}, P4032 = {arg= "reviewer", maxvals = 10, others = true}, -- goes to "others" section P407 = true, P433 = {arg= "issue", maxvals = 0, populate_from_journal = true}, -- distinguish from |number= ("P1545"?) if both are given (still blocked by {{citation}}, but will be supported in the future) P478 = {arg= "volume", maxvals = 0, populate_from_journal = true}, P50 = true, -- author P57 = {arg= "director", maxvals = 10, others = true}, -- goes to "others" section P5749 = {arg= "asin", maxvals = 1}, -- What about |asin-tld=? (WD examples resolve to .com at present, but may change) P5769 = true, --editor P577 = {arg= "publication-date", maxvals = 1, populate_from_journal = true}, -- publication date (don't use |date=; is treated specially in {{citation}} if both are given.) P58 = {arg= "screenwriter", maxvals = 10, others = true}, -- goes to "others" section P655 = true, P6942 = {arg= "animator", maxvals = 10, others = true}, -- goes to "others" section P698 = {arg= "pmid", maxvals = 1}, P7604 = {arg ="supervisor", maxvals = 3, others = true}, -- goes to "others" section P792 = {arg= "chapter", maxvals = 1}, P818 = {arg= "arxiv", maxvals = 1}, P819 = {arg= "bibcode", maxvals = 1}, -- take care of |bibcode-access=? P8299 = {arg= "s2cid", maxvals = 1}, -- take care of |s2cid-access=? P856 = true, P86 = {arg= "composer", maxvals = 10, others = true}, -- goes to "others" section P888 = {arg= "jstor", maxvals = 1}, -- take care of |jstor-access=? P889 = {arg= "mr", maxvals = 1}, P892 = {arg= "rfc", maxvals = 1}, P893 = {arg= "ssrn", maxvals = 1}, P894 = {arg= "zbl", maxvals = 1}, P932 = {arg= "pmc", maxvals = 1}, -- take care of |pmc-embargo-date= (WD "reason for deprecation")? P953 = true, P958 = {arg= "at", maxvals = 0, populate_from_journal = true}, -- also incorporate lines (P7421) and columns (P3903) into this (cite map also supports |section=) P98 = true, P854 = true, } --[[--------------------------< I S _ S E T >-------------------------------------------------------------- Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string. ]] local function is_set( var ) return not (var == nil or var == '') end --[[--------------------------< I N _ A R R A Y >-------------------------------------------------------------- Whether needle is in haystack (taken from Module:Citation/CS1/Utilities) ]] local function in_array( needle, haystack ) if needle == nil then return false end for n, v in ipairs( haystack ) do if v == needle then return n end end return false end --[[--------------------------< A C C E P T _ V A L U E >------------------------------------------------------- Accept WD value by framing in ((...)) if param_val is equal to keyword; else pass-through WD value as is. ]] local function accept_value( param_val, wd_val ) local val = param_val if val then if in_array (val, {'accept', '))((', ':d:'}) then val = '((' .. wd_val .. '))' elseif '((accept))' == val then val = 'accept' elseif '(())(())' == val then val = '))((' elseif '((:d:))' == val then val = ':d:' else val = wd_val end end return val end -- function to fetch a value to display local function makelink(v, out, link, maxpos, wdl, lang) local label if v.mainsnak.snaktype == "value" then if v.mainsnak.datatype == "wikibase-item" then local qnumber = v.mainsnak.datavalue.value.id local sitelink = mw.wikibase.getSitelink(qnumber) if qnumber == "Q2818964" then sitelink = nil end -- suppress link to "Various authors" -- من المهم التحقق من وجود datavalue if v.qualifiers and v.qualifiers.P1932 and v.qualifiers.P1932[1].datavalue then label = v.qualifiers.P1932[1].datavalue.value else label = mw.wikibase.getLabelByLang(qnumber, lang) or mw.wikibase.getLabel(qnumber) if label then label = mw.text.nowiki(label) else label = qnumber -- should add tracking category end end local position = maxpos + 1 -- Default to 'next' author. -- use P1545 (series ordinal) instead of default position. if v["qualifiers"] and v.qualifiers["P1545"] and v.qualifiers["P1545"][1] then position = tonumber(v.qualifiers["P1545"][1].datavalue.value) end maxpos = math.max(maxpos, position) if sitelink then -- just the plain name, -- but keep a record of the links, using the same index out[position] = label link[position] = sitelink else if wdl then -- show that there's a Wikidata entry available out[position] = "[[:d:Q" .. v.mainsnak.datavalue.value["numeric-id"] .. "|" .. label .. "]]&nbsp;<span title='" .. i18n["errors"]["local-article-not-found"] .. "'>[[پرونده:Wikidata-logo.svg|16px|alt=|link=]]</span>" else -- no Wikidata links wanted, so just give the plain label out[position] = label end end elseif v.mainsnak.datatype == "string" then local position = maxpos + 1 -- Default to 'next' author. -- use P1545 (series ordinal) instead of default position. if v["qualifiers"] and v.qualifiers["P1545"] and v.qualifiers["P1545"][1] then position = tonumber(v.qualifiers["P1545"][1].datavalue.value) end maxpos = math.max(maxpos, position) out[position] = v.mainsnak.datavalue.value else -- not a wikibase-item or a string! end else -- code here if we want to return something when author is "unknown" -- من المهم التحقق من وجود datavalue if v.qualifiers and v.qualifiers.P1932 and v.qualifiers.P1932[1].datavalue then label = v.qualifiers.P1932[1].datavalue.value else label = mw.wikibase.getLabelByLang("Q4233718", lang):gsub("^%l", mw.ustring.upper) end maxpos = maxpos + 1 out[maxpos] = label end return maxpos end --[=[-------------------------< G E T _ N A M E _ L I S T >---------------------------------------------------- get_name_list -- adapted from getAuthors code taken from Module:RexxS arguments: nl_type - type of name list to fetch: nl_type = 'author' for authors; 'editor' for editors; 'translator' for translators args - pointer to the parameter arguments table from the template call qid - value from |qid= parameter; the Q-id of the source (book, etc.) in qid wdl - value from the |wdl= parameter; a Boolean passed to enable links to Wikidata when no article exists returns nothing; modifies the args table ]=] local function get_name_list (nl_type, args, qid, wdl, lang, refsnak) local propertyID = "P50" local fallbackID = "P2093" -- author name string if nl_type =="author" then propertyID = 'P50' -- for authors fallbackID = 'P2093' -- author-string elseif nl_type =="editor" then propertyID = 'P5769' -- "editor-in-chief" fallbackID = 'P98' -- for editors - So-called "fallbacks" are actually a second set of properties processed -- TBD. Take book series editors into account as well (if they have a separate P code as well)? elseif nl_type == "translator" then propertyID = 'P655' -- for translators fallbackID = nil -- elseif 'contributor' == nl_type then -- f.e. author of forewords (P2679) and afterwords (P2680); requires |contribution=, |title= and |author= -- propertyID = 'P' -- for contributors -- fallbackID = nil else return -- not specified so return end -- wdl is a Boolean passed to enable links to Wikidata when no article exists -- if "false" or "no" or "0" is passed set it false -- if nothing or an empty string is passed set it false if wdl and (#wdl > 0) then wdl = wdl:lower() wdl = in_array (wdl, {"false", "no", "0"}) else -- wdl is empty, so wdl = false end local props = nil local fallback = nil if qid then if mw.wikibase.entityExists(qid) then props = mw.wikibase.getAllStatements(qid, propertyID) if #props == 0 and fallbackID then fallback = mw.wikibase.getAllStatements(qid, fallbackID) end end elseif refsnak then props = refsnak[propertyID] if not props and fallbackID then fallback = refsnak[fallbackID] end end -- Make sure it actually has at least one of the properties requested if not (props and props[1]) and not (fallback and fallback[1]) then return nil end -- So now we have something to return: -- table 'out' is going to store the names(s): -- and table 'link' will store any links to the name's article local out = {} local link = {} local maxpos = 0 if props and props[1] then for k, v in pairs(props) do maxpos = makelink(v, out, link, maxpos, wdl, lang) end end if fallback and fallback[1] then -- second properties for k, v in pairs(fallback) do maxpos = makelink(v, out, link, maxpos, wdl, lang) end end -- if there's anything to return, then insert the additions in the template arguments table -- in the form |author1=firstname secondname |author2= ... -- Renumber, in case we have inconsistent numbering local keys = {} for k, v in pairs(out) do keys[#keys + 1] = k end table.sort(keys) -- as they might be out of order for i, k in ipairs(keys) do out[k] = out[k]:gsub ('&#39;', '\''); -- prevent cs1|2 multiple names categorization; replace html entity with the actual character if args[nl_type .. i] then -- name gets overwritten -- pull corresponding -link only if overwritten name is same as WD name if link[k] and (args[nl_type .. i] == out[k]) then args[nl_type .. '-link' .. i] = args[nl_type .. '-link' .. i] or link[k] -- author-linkn or editor-linkn end else -- name does not get overwritten, so pull name from WD args[nl_type .. i] = out[k] if link[k] then args[nl_type .. '-link' .. i] = args[nl_type .. '-link' .. i] or link[k] -- author-linkn or editor-linkn end end end end -- gets language codes used for a monolingual text property as a table function p._getLangOfProp(qid, pid) if not pid or not qid then return {} end local out = {} local props = mw.wikibase.getAllStatements(qid, pid) for i, v in ipairs(props) do if v.mainsnak.datatype == "monolingualtext" and v.mainsnak.datavalue then out[#out + 1] = v.mainsnak.datavalue.value.language end end return out end function p._getLangOfSnakProp(snak, pid) if not pid or not snak then return {} end local out = {} local props = snak[pid] for i, v in ipairs(props) do if v.datatype == "monolingualtext" and v.datavalue then out[#out + 1] = v.datavalue.value.language end end return out end function p.getLangOfProp(frame) local pid = frame.args.pid or mw.text.trim(frame.args[1] or "") if pid == "" then return end local qid = frame.args.qid if qid == "" then qid = nil end return table.concat(p._getLangOfProp(qid, pid), ", ") end -- gets the language codes of a Wikidata entry as a table local function _lang_code(qid) local lc = getPropOfProp( {qid = qid, prop1 = "P407", prop2 = "P424", ps = 1} ) if lc then return mw.text.split( lc, "[,، ]+" ) end --modified lc = getPropOfProp( {qid = qid, prop1 = "P407", prop2 = "P218", ps = 1} ) if lc then return mw.text.split( lc, "[,، ]+" ) end --modified return p._getLangOfProp(qid, "P1476") end function p.lang_code(frame) return table.concat(_lang_code(frame.args.qid or mw.text.trim(frame.args[1] or "")), ", ") end -- export for debug function p.getPropOfProp(frame) return getPropOfProp(frame.args) end -- wraps a string in nowiki unless disable flag is set local function wrap_nowiki(str, disable) if disable then return str or '' end return mw.text.nowiki(str or '') end -- sort sequence table whose values are key-value pairs by key local function comp_key(a, b) return a[1] < b[1] end -- sort sequence table whose values are key-value pairs by value local function comp_val(a, b) return a[2] < b[2] end -- ref filtering for citing from wikidata local function is_rejected(item) -- rejected Q if rejected.sources[item]==true then return true; end -- rejected Properties local item_entity = mw.wikibase.getEntity(item); for _, v in pairs(rejected.properties) do if (#item_entity:getAllStatements( v )>0 ) then return true; end end -- Rejected InatanceOf local instance = item_entity:getAllStatements( "P31" ) for _,v in pairs(instance) do if rejected.instances[v.mainsnak.datavalue.value.id] then return true; end end --No used Properties local has_properties = false for k, _ in pairs(used_properties) do if (#item_entity:getAllStatements( k )>0 ) then has_properties = true; break; end end return not has_properties; end function p._cite_web(citeq_args) local refsnak= citeq_args.snak citeq_args.snak = nil -- retrieve all the parameters local pqid = citeq_args.pqid citeq_args.pqid = nil local wdl = false local qid = nil local multi_args = { P50 = "author", P2093 = "author", P5769 = "editor", P98 = "editor", P655 = "translator", } -- find language local langcodes = {} if refsnak["P1476"] then langcodes = p._getLangOfSnakProp(refsnak, "P1476") citeq_args.language = citeq_args.language or langcodes[1] end langcodes[#langcodes+1] = 'ar' langcodes[#langcodes+1] = 'en' local labellang = langcodes[1] local rtl = rtl_lang[langcodes[1]] or false local oth={} for i in pairs(refsnak) do local label = "" -- multiple authors may be given if refsnak[i][1].snaktype ~= 'novalue' then if multi_args[i] then get_name_list (multi_args[i], citeq_args, qid, wdl, labellang) elseif used_properties[i] and type(used_properties[i]) == "table" then local data = used_properties[i] local langidx = 1 while citeq_args[data.arg] == nil and langidx<=#langcodes do citeq_args[data.arg] = getValueFromSnaks( {i, fwd = "ALL", osd = "no", noicon = "true", maxvals = data.maxvals, linked = data.linked, rank = data.rank or "best", lang=langcodes[langidx], snak = refsnak } ) if citeq_args[data.arg] == nil then break elseif citeq_args[data.arg]:find('[[رج:Articles with missing Wikidata information]]', 1, true) then citeq_args[data.arg] = nil langidx = langidx + 1 else break end end if not citeq_args[data.arg] then citeq_args[data.arg] = getValueFromSnaks( {i, ps = 1, qid = qid, maxvals = data.maxvals, linked = data.linked, snak = refsnak} ) if citeq_args[data.arg]:find('^Q%d+$') then -- qid was returned -- try fallback to qid's native language local qid_languages = _lang_code(citeq_args[data.arg]) citeq_args[data.arg] = getValueFromSnaks( {i, ps = 1, qid = qid, maxvals = data.maxvals, linked = data.linked, lang = qid_languages[1], snak = refsnak} ) if citeq_args[data.arg]:find('^Q%d+$') then -- qid was returned again citeq_args[data.arg] = nil else -- record the language found if no lang specified citeq_args.language = citeq_args.language or qid_languages[1] end end end --- translate unknown value if citeq_args[data.arg] == "Unknown" then if rtl then citeq_args[data.arg] = i18n.ar["unknown-" .. data.arg] or i18n.ar["unknown"] else citeq_args[data.arg] = mw.wikibase.getLabelByLang("Q4233718", lang):gsub("^%l", mw.ustring.upper) end end ----------------- if data.others then oth[#oth + 1] = citeq_args[data.arg] and ((i18n.ar[data.arg] or data.arg:gsub("^%l", string.upper)) .. ": " .. citeq_args[data.arg]) citeq_args[data.arg] = nil end elseif used_properties[i] then if i == "P648" then citeq_args.ol = (getValueFromSnaks( {"P648", ps = 1, maxvals = 1, snak = refsnak, citeq_args.ol } ) or ''):gsub("^OL(.+)$", "%1") if citeq_args.ol == "" then citeq_args.ol = nil end elseif i == "P957" then citeq_args.isbn = getValueFromSnaks( {"P957", ps = 1, maxvals = 1, rank="best", snak = refsnak } ) elseif in_array(i,{"P854", "P953", "P856", "P2699"}) then local url; for _, pr in ipairs( {"P854", "P953", "P856", "P2699"} ) do url = getValueFromSnaks( {pr, ps = 1,osd = "no", noicon = "true", maxvals = 1, snak = refsnak } ) if url then citeq_args.url = mw.text.split( url, " (", true )[1] local arcurl = mw.ustring.match( url, " %((.*)%)" ) -- when there is an archive url, <url> holds: url<space>(archive url); here extract the archive url if present if arcurl then local arcy, arcm, arcd = arcurl:match("(20%d%d)%p?(%d%d)%p?(%d%d)") if arcy and arcm and arcd then citeq_args["archive-url"] = arcurl citeq_args["archive-date"] = tonumber(arcd) .. " " .. i18n.months[tonumber(arcm)] .. " " .. arcy end end break end end end end end end if citeq_args.url then if refsnak["P813"] then citeq_args.accessdate = getValueFromSnaks( {"P813", ps = 1,osd = "no", noicon = "true", maxvals = 1, snak = refsnak } ) end if refsnak["P1065"] and refsnak["P2960"] then citeq_args["archive-url"] = getValueFromSnaks( {"P1065", ps = 1,osd = "no", noicon = "true", maxvals = 1, snak = refsnak } ) citeq_args["archive-date"]= getValueFromSnaks( {"P2960", ps = 1,osd = "no", noicon = "true", maxvals = 1, snak = refsnak } ) end end citeq_args.others = citeq_args.others or table.concat(oth, ". ") if citeq_args.others == "" then citeq_args.others = nil end citeq_args.biorxiv = citeq_args.biorxiv and ("10.1101/" .. citeq_args.biorxiv) -- if url then see if there's an archive: citeq_args.url local url if citeq_args.publisher == "Unknown" then -- look for "stated as" (P1932) local stated_as = getValue( {"P123", ps = 1, qid = qid, maxvals = 1, qual="P1932", qo="y"} ) if stated_as then citeq_args.publisher = stated_as end end local title_display = citeq_args.title if citeq_args.url then citeq_args.title = wrap_nowiki(title_display) end -- TBD: incorporate |at, |sheets= and |sheet= here as well -- Sort out what should happen if several of them are given at the same time if citeq_args.page or citeq_args.p then -- let single take precedence over multiple citeq_args.pages = nil citeq_args.pp = nil end if citeq_args.pages then local _, count = string.gsub(citeq_args.pages, "[,;%s]%d+", "") if count == 1 then citeq_args.page = citeq_args.pages citeq_args.pages = nil end end for k, v in pairs(citeq_args) do if in_array (v, {'(())', 'unset', 'ignore'}) or 'string' ~= type(k) then -- empty accept-as-is-written (()) markup to indicate an empty/unused parameter value, other ((...)) markups are deliberately passed down to {{citation}} citeq_args[k] = nil elseif in_array (v, {'((unset))', '((ignore))'}) then -- strip off markup for free-text values clashing with local keywords citeq_args[k] = 'unset' end end local author_count = 0 for k, v in pairs(citeq_args) do if k:find("^author%d+$") then author_count = author_count + 1 end end if author_count > 8 then -- convention in astronomy journals, optional mode for this? if 'all' == citeq_args['display-authors'] then citeq_args['display-authors'] = nil; -- unset because no longer needed else citeq_args['display-authors'] = citeq_args['display-authors'] or 3 -- limit to three displayed names end end -- replace no-break space by space, User:Mr. Ibrahem if citeq_args.title then citeq_args.title = mw.ustring.gsub( citeq_args.title, "\194\160", " " ) end local editor_count = 0 for k, v in pairs(citeq_args) do if k:find("^editor%d+$") then editor_count = editor_count + 1 end end if editor_count > 8 then -- convention in astronomy journals, optional mode for this? if 'all' == citeq_args['display-editors'] then citeq_args['display-editors'] = nil; -- unset because no longer needed else citeq_args['display-editors'] = citeq_args['display-editors'] or 3 -- limit to three displayed names end end -- code to make a guess what template to use from the supplied parameters -- (first draft for proof-of-concept) local template = "ويب" -- |id= could hold more than one identifier pulled from Wikidata not supported by {{citation}}, right now only add our qid to the list local list_sep = '. ' if citeq_args.mode ~= 'cs1' then list_sep = ', ' end -- clean up any blank parameters for k, v in pairs(citeq_args) do if v == "" then citeq_args[k] = nil end end if template then -- citeq_args.mode = citeq_args.mode or "cs1" -- a cs1 template already knows that it is cs1 so this line is superfluous template = "استشهاد " .. template else -- citeq_args.mode = citeq_args.mode or "cs2" -- a cs2 template already knows that it is cs2 so this line is superfluous template = "استشهاد" end citeq_args['no-tracking'] = 'true' -- لإيقاف ظهور تصانيف التتبع return mw.getCurrentFrame():expandTemplate{title = template, args = citeq_args} -- render the template end --[[-------------------------< C I T E _ Q >------------------------------------------------------------------ Takes standard CS1|2 template parameters and passes all to {{citation}}. If neither of |author= and |author1= are set, calls get_authors() to try to get an author name-list from Wikidata. The result is passed to {{citation}} for rendering. --]] function p._cite_q (in_citeq_args) local frame = mw.getCurrentFrame() local citeq_args = {} local origin_args = {} -- parameters that don't get passed to Citation local expand = in_citeq_args.expand -- when set to anything, causes {{cite q}} to render <code><nowiki>{{citation|...}}</nowiki></code> local qid = in_citeq_args.qid or in_citeq_args[1] local wdl = in_citeq_args.wdl local template = in_citeq_args.template local cite_class = 'citation' local rtl = true local snak = in_citeq_args.snak or {} local pqid = in_citeq_args.pqid in_citeq_args.expand = nil in_citeq_args[1] = nil in_citeq_args.qid = nil in_citeq_args.wdl = nil in_citeq_args.template = nil in_citeq_args.snak = nil in_citeq_args.pqid = nil if in_citeq_args.wikidatacite then citeq_args = in_citeq_args else local A = argument_wrapper(in_citeq_args) local loaded_args ={} for _,args_table in pairs({simple_properties,used_args}) do for k,_ in pairs(args_table) do if A[k] then citeq_args[k] = A[k] if k ~= A:ORIGIN(k) then origin_args[k] = A:ORIGIN(k) table.insert(loaded_args, A:ORIGIN(k)) else table.insert(loaded_args, k) end end end end for k,v in pairs(in_citeq_args) do if not in_array(k,loaded_args) then citeq_args[k] = v end end end local labellang = 'ar' -- if title supplied, flag to not read html title local titleforced = (citeq_args.title ~= nil) local oth = {} -- put the language codes into a sequential table langcodes[] local langcodes = {} if citeq_args.language then -- check these are a supported language codes for lc in mw.text.gsplit( citeq_args.language, "[,، ]+", false ) do --modified langcodes[#langcodes+1] = mw.language.isSupportedLanguage(lc) and lc end end if not langcodes[1] then -- try to find language of work langcodes = _lang_code(qid) end if not langcodes[1] then -- try fallback to journal's language local journal_qid = followQid({qid = qid, props = "P1433"}) langcodes = journal_qid and _lang_code(journal_qid) end citeq_args.language = citeq_args.language or table.concat(langcodes, ", ") labellang = langcodes[1] or labellang rtl = rtl_lang[langcodes[1]] or false -- loop through list of simple properties and get their values in citeq_args for name, data in pairs(simple_properties) do citeq_args[name] = getValue( {data.id, fwd = "ALL", osd = "no", noicon = "true", qid = qid, maxvals = data.maxvals, linked = data.linked, rank = data.rank or "best", lang = labellang, snak = snak, citeq_args[name], qual=data.qual } ) if data.populate_from_journal then local publishedin = getValue( {"P1433", ps = 1, qid = qid, maxvals = 0, lang = labellang, citeq_args[name], qual = data.id, qualsonly = 'yes'} ) citeq_args[name] = publishedin or getPropOfProp({qid = qid, prop1 = "P1433", prop2 = data.id, lang = labellang, maxvals = data.maxvals, ps = 1}) end if citeq_args[name] and citeq_args[name]:find('[[رج:Articles with missing Wikidata information]]', 1, true) then -- try fallback to work's native language citeq_args[name] = getValue( {data.id, ps = 1, qid = qid, maxvals = data.maxvals, linked = data.linked, lang = labellang, snak = snak} ) if citeq_args[name]:find('^Q%d+$') then -- qid was returned -- try fallback to qid's native language local qid_languages = _lang_code(citeq_args[name]) citeq_args[name] = getValue( {data.id, ps = 1, qid = qid, maxvals = data.maxvals, linked = data.linked, lang = qid_languages[1], snak = snak} ) if citeq_args[name]:find('^Q%d+$') then -- qid was returned again citeq_args[name] = nil else -- record the language found if no lang specified citeq_args.language = citeq_args.language or qid_languages[1] end end end if citeq_args[name] and snak[data.id] then snak[data.id] = nil end --- translate unknown value if citeq_args[name] == "Unknown" and rtl then citeq_args[name] = i18n.ar["unknown-" .. name] or i18n.ar["unknown"] end ----------------- if data.others then oth[#oth + 1] = citeq_args[name] and ((rtl and i18n.ar[name] or name:gsub("^%l", string.upper)) .. ": " .. citeq_args[name]) citeq_args[name] = nil end end citeq_args.others = citeq_args.others or table.concat(oth, ". ") if citeq_args.others == "" then citeq_args.others = nil end citeq_args.journal = citeq_args.journal and citeq_args.journal:gsub("^''", ""):gsub("''$", ""):gsub("|''", "|"):gsub("'']]", "]]") citeq_args.ol = (getValue( {"P648", ps = 1, qid = qid, maxvals = 1, snak = snak, citeq_args.ol } ) or ''):gsub("^OL(.+)$", "%1") if citeq_args.ol == "" then citeq_args.ol = nil end -- TBD. Take care of |ol-access=? citeq_args.biorxiv = citeq_args.biorxiv and ("10.1101/" .. citeq_args.biorxiv) citeq_args.isbn = getValue( {"P957", ps = 1, qid = qid, maxvals = 1, rank="best", snak = snak, citeq_args.isbn } ) -- try ISBN 10 (only one value accepted) -- if url then see if there's an archive: citeq_args.url local url --find formatted url if snak ~= {} then for k, v in pairs(snak) do if (v[1].datatype == "external-id") then local furl = mw.wikibase.getBestStatements( k, "P1630" ) if 0 ~= #furl then furl = furl[1]["mainsnak"]["datavalue"]["value"] citeq_args.url = mw.message.newRawMessage(furl, {v[1]["datavalue"]["value"]}):plain() snak[k] = nil break; end end end if citeq_args.url == nil and pqid and qid then local refproperty = mw.wikibase.getBestStatements(qid , "P1687" ) if 0 ~= #refproperty then -- خطأ لوا في وحدة:Cite_Q على السطر 1124: attempt to index field 'datavalue' (a nil value). if refproperty[1]["mainsnak"] and refproperty[1]["mainsnak"]["datavalue"] and refproperty[1]["mainsnak"]["datavalue"]["value"] then refproperty=refproperty[1]["mainsnak"]["datavalue"]["value"]["id"] local furl = mw.wikibase.getBestStatements( refproperty, "P1630" ) if 0 ~= #furl then furl = furl[1]["mainsnak"]["datavalue"]["value"] local refval = mw.wikibase.getBestStatements( pqid, refproperty ) refval = (0 ~= #refval) and refval[1]["mainsnak"]["datavalue"]["value"] if refval then citeq_args.url = mw.message.newRawMessage(furl, {refval}):plain() end end end end end end if not citeq_args.url then for i, pr in ipairs( {"P953", "P856", "P2699"} ) do url = getValue( {pr, ps = 1, qid = qid, maxvals = 1, snak = snak, qual="P1065" } ) if url then citeq_args.url = mw.text.split( url, " (", true )[1] local arcurl = mw.ustring.match( url, " %((.*)%)" ) -- when there is an archive url, <url> holds: url<space>(archive url); here extract the archive url if present if arcurl then local arcy, arcm, arcd = arcurl:match("(20%d%d)%p?(%d%d)%p?(%d%d)") if arcy and arcm and arcd then citeq_args["archive-url"] = arcurl citeq_args["archive-date"] = tonumber(arcd) .. " " .. i18n.months[tonumber(arcm)] .. " " .. arcy end end break end end end if citeq_args.publisher == "Unknown" then -- look for "stated as" (P1932) local stated_as = getValue( {"P123", ps = 1, qid = qid, maxvals = 1, qual="P1932", qo="y"} ) if stated_as then citeq_args.publisher = stated_as end end if not titleforced then -- Handle subtitle. if citeq_args.title then local subtitle = mw.wikibase.getBestStatements (qid, 'P1680'); if 0 ~= #subtitle and subtitle[1].mainsnak.snaktype == 'value' then subtitle = subtitle[1].mainsnak.datavalue.value.text; citeq_args.title = citeq_args.title .. ": " .. subtitle end end local htmltitle = getValue( {"P1476", qual = "P6833", ps = 1, qid = qid, snak = snak, maxvals = 1, qo = "y"} ) if htmltitle then citeq_args.title = htmltitle:gsub("</?i>", "''") else local title_display = citeq_args.title or (langcodes[1] and mw.wikibase.getLabelByLang(qid, langcodes[1])) or mw.wikibase.getLabel(qid) if title_display and snak and snak.P1810 then title_display=title_display .. " | " .. snak.P1810[1].datavalue.value snak.P1810 = nil end title_display = title_display or ("No label or title -- debug: " .. qid) if citeq_args.url then citeq_args.title = wrap_nowiki(title_display) else local slink = mw.wikibase.getSitelink(qid) local slink_flag = false local wrap_title = '' local wslink = false if not slink then -- See if we have wikisource if not citeq_args.url then local wikisource_sitelink = mw.wikibase.getSitelink(qid, "enwikisource") or nil if wikisource_sitelink then slink = ':s:'..wikisource_sitelink wslink = true end end end if citeq_args.title then if slink then wrap_title = wrap_nowiki(citeq_args.title) slink_flag = true else citeq_args.title = wrap_nowiki(citeq_args.title) end else if slink and not wslink then if slink:lower() == title_display:lower() then citeq_args.title = '[[' .. slink .. ']]' else wrap_title = wrap_nowiki(slink:gsub("%s%(.+%)$", ""):gsub(",.+$", "")) slink_flag = true end elseif wslink then wrap_title = wrap_nowiki(title_display) slink_flag = true else citeq_args.title = wrap_nowiki(title_display) end end if slink_flag then if slink == wrap_title and not wslink then -- direct link citeq_args.title = '[[' .. slink .. ']]' else -- piped link citeq_args.title = '[[' .. slink .. '|' .. wrap_title .. ']]' end end end end end -- replace no-break space by space, User:Mr. Ibrahem if citeq_args.title then citeq_args.title = mw.ustring.gsub( citeq_args.title, "\194\160", " " ) end -- fetch other snak properties for debugging -- if snak and snak ~= {} then -- for k,v in pairs(snak) do -- if not used_properties[k] then -- end -- end -- end -- TBD: incorporate |at, |sheets= and |sheet= here as well -- Sort out what should happen if several of them are given at the same time if citeq_args.page then -- let single take precedence over multiple citeq_args.pages = nil citeq_args.pp = nil end if citeq_args.pages then local _, count = string.gsub(citeq_args.pages, "[,;%s]%d+", "") if count == 1 then citeq_args.page = citeq_args.pages citeq_args.pages = nil end end if is_set (qid) then if not is_set (citeq_args.author) and not is_set (citeq_args.author1) and not is_set (citeq_args.subject) and not is_set (citeq_args.subject1) and not is_set (citeq_args.host) and not is_set (citeq_args.host1) and not is_set (citeq_args.last) and not is_set (citeq_args.last1) and not is_set (citeq_args.surname) and not is_set (citeq_args.surname1) and not is_set (citeq_args['author-last']) and not is_set (citeq_args['author-last1']) and not is_set (citeq_args['author1-last']) and not is_set (citeq_args['author-surname']) and not is_set (citeq_args['author-surname1']) and not is_set (citeq_args['author1-surname1']) then -- if neither are set, try to get authors from Wikidata get_name_list ('author', citeq_args, qid, wdl, labellang) -- modify citeq_args table with authors from Wikidata end if not is_set (citeq_args.editor) and not is_set (citeq_args.editor1) and not is_set (citeq_args['editor-last']) and not is_set (citeq_args['editor-last1']) and not is_set (citeq_args['editor1-last']) and not is_set (citeq_args['editor-surname']) and not is_set (citeq_args['editor-surname1']) and not is_set (citeq_args['editor1-surname']) then -- if neither are set, try to get editors from Wikidata get_name_list ('editor', citeq_args, qid, wdl, labellang) -- modify citeq_args table with editors from Wikidata end if not is_set (citeq_args.translator) and not is_set (citeq_args.translator1) and not is_set (citeq_args['translator-last']) and not is_set (citeq_args['translator-last1']) and not is_set (citeq_args['translator1-last']) and not is_set (citeq_args['translator-surname']) and not is_set (citeq_args['translator-surname1']) and not is_set (citeq_args['translator1-surname']) then -- if neither are set, try to get translators from Wikidata get_name_list ('translator', citeq_args, qid, wdl, labellang) -- modify citeq_args table with translators from Wikidata end end for k, v in pairs(citeq_args) do if in_array (v, {'(())', 'unset', 'ignore'}) or 'string' ~= type(k) then -- empty accept-as-is-written (()) markup to indicate an empty/unused parameter value, other ((...)) markups are deliberately passed down to {{citation}} citeq_args[k] = nil elseif in_array (v, {'((unset))', '((ignore))'}) then -- strip off markup for free-text values clashing with local keywords citeq_args[k] = 'unset' end end local author_count = 0 for k, v in pairs(citeq_args) do if k:find("^author%d+$") then author_count = author_count + 1 end end if author_count > 8 then -- convention in astronomy journals, optional mode for this? if 'all' == citeq_args['display-authors'] then citeq_args['display-authors'] = nil; -- unset because no longer needed else citeq_args['display-authors'] = citeq_args['display-authors'] or 3 -- limit to three displayed names end end local editor_count = 0 for k, v in pairs(citeq_args) do if k:find("^editor%d+$") then editor_count = editor_count + 1 end end if editor_count > 8 then -- convention in astronomy journals, optional mode for this? if 'all' == citeq_args['display-editors'] then citeq_args['display-editors'] = nil; -- unset because no longer needed else citeq_args['display-editors'] = citeq_args['display-editors'] or 3 -- limit to three displayed names end end -- change edition to ordinal if it's set and numeric if (rtl == false) then citeq_args.edition = citeq_args.edition and p.makeOrdinal(citeq_args.edition) end -- code to make a guess what template to use from the supplied parameters -- (first draft for proof-of-concept) if citeq_args.journal then template = template or "بدورية محكمة" elseif citeq_args.isbn then template = template or "بكتاب" citeq_args.asin = nil -- suppress ASIN if ISBN exists elseif citeq_args.website then template = template or "ويب" end -- template is CS1 designator: journal, web, news, etc. if template then -- citeq_args.mode = citeq_args.mode or "cs1" -- a cs1 template already knows that it is cs1 so this line is superfluous local citeclasses = {["بدورية محكمة"] = 'journal', ["بكتاب"] = "book", ["ويب"] = "web" } cite_class = citeclasses[template] template = "استشهاد " .. template else -- citeq_args.mode = citeq_args.mode or "cs2" -- a cs2 template already knows that it is cs2 so this line is superfluous template = "استشهاد" end -- |id= could hold more than one identifier pulled from Wikidata not supported by {{citation}}, right now only add our qid to the list local list_sep = '. ' if citeq_args.mode ~= 'cs1' then list_sep = ', ' end local id = '[[ویکی‌دیتا|QID]]:[[:d:' .. qid .. '|' .. qid .. ']]' -- go through "WDQ (identifier)" redirect to reduce clutter in "What links here" and improve reverse lookup. Keep in sync with {{QID}}. local old_id = citeq_args.id if wdl then -- show WD logo id = id .. '[[پرونده:Wikidata-logo.svg|16px|alt=|link=]]' -- possibly replace by WD edit icon? end if is_set (old_id) then citeq_args.id = old_id .. list_sep .. id -- append to user-specified contents else citeq_args.id = id end -- clean up any blank parameters for k, v in pairs(citeq_args) do if v == "" then citeq_args[k] = nil end end -- use real param names for CS1 messages for k,v in pairs(origin_args) do if citeq_args[k] and citeq_args[k] == in_citeq_args[v] then citeq_args[v] = citeq_args[k] citeq_args[k] = nil end end -- if |expand=<anything>, write a nowiki'd version to see what the {{citation}} template call looks like if expand then local expand_args = { "{{" .. template .. "\n" } -- init with citation template if expand == "self" then citeq_args.id = old_id -- restore original |id= parameter expand_args = { "{{cite Q|" .. qid } -- expand to itself end -- make a sortable table and sort it by param name local sorttable = {} for param, val in pairs (citeq_args) do table.insert(sorttable, {param, val}) end table.sort(sorttable, comp_key) -- add contents to expand_args for idx, val in ipairs(sorttable) do table.insert(expand_args, val[1] .. '=' .. val[2] .. "\n") end -- make the nowiki'd string and done return table.concat (expand_args, '| ') .. "\n}}" end local erratumid = getPropertyIDs( { "P2507", qid = qid, fwd = "ALL", osd = "no", rank = "best", maxvals = 1 } ) if erratumid then erratumid = " [[d:" .. erratumid .. "|(erratum)]]" .. "[[رج:Cite Q - cites a work with an erratum]]" else erratumid = "" end local opt_cat = '' if getValue( {"P5824", ps = 1, qid = qid} ) then opt_cat = '[[رج:Cite Q - cites a retracted work]]<!-- retracted -->' end if getValue( {"P1366", ps = 1, qid = qid} ) then opt_cat = opt_cat .. '[[رج:Cite Q - cites a replaced work]]<!-- replaced -->' end if citeq_args.wikidatacite then return frame:expandTemplate{title = template, args = citeq_args} .. erratumid .. opt_cat -- render the template else local CS = require("Module:citation/CS1" .. sandbox) return CS._citation(frame , citeq_args, {['CitationClass'] = cite_class}) .. erratumid .. opt_cat end end --[[-------------------------< C I T E _ Q >------------------------------------------------------------------ Takes standard CS1|2 template parameters and passes all to {{citation}}. If neither of |author= and |author1= are set, calls get_authors() to try to get an author name-list from Wikidata. The result is passed to {{citation}} for rendering. --]] function p._cite_wikidata (ref, pqid) -- early exit if not ref then return nil end local snak = ref.snaks -- مراجع غير مقبولة if snak.P143 or snak.P3452 or snak.P4656 then return nil end local hash = ref.hash if hash and hash ~= "" and ref_cash[hash] then return ref_cash[hash] end local citeq_args = {} local frame = mw.getCurrentFrame() if snak.P248 then for _, prop in pairs(snak.P248) do if prop.snaktype == "value" then citeq_args.qid = "Q" .. prop.datavalue.value["numeric-id"] end end snak.P248 = nil; end if citeq_args.qid and is_rejected(citeq_args.qid) == true then return nil end local reference citeq_args.snak = snak citeq_args.pqid = pqid citeq_args.wikidatacite = 1 if citeq_args.qid then reference = p._cite_q(citeq_args) else local has_properties = false for k, _ in pairs(used_properties) do if snak[k] then has_properties = true; break; end end reference = (has_properties and p._cite_web(citeq_args) or nil) end if reference and reference ~= "" then reference = frame:extensionTag("ref", reference, {name = 'wikidata-' .. hash}) end if hash and hash ~= "" then ref_cash[hash] = reference end return reference end function p.cite_q (frame) local args = {} for k, v in pairs(frame:getParent().args) do if v ~= "" then args[k] = v end end for k, v in pairs(frame.args) do if v ~= "" then args[k] = v end end args.qid = args.qid or args[1] or "" if args.qid == "" then return nil end args[1] = nil local citesep = (args.citesep or "") if citesep == "" then citesep = ", " end citesep = citesep:gsub('"', '') -- strip double quotes after setting default to allow |citesep="" as a blank separator args.citesep = nil local tag = args.tag or "" if tag == "" then tag = nil end args.tag = nil local list = args.list or "" if list == "" then list = nil end args.list = nil args.language = args.language or args.lang args.lang = nil local cites = {} for q in args.qid:gmatch("Q%d+") do -- make a new copy of the arguments local newargs = {} for k, v in pairs(args) do if k ~= "qid" then newargs[k] = v end end newargs.qid = q if tag == "ref" then cites[#cites + 1] = frame:callParserFunction{ name = "#tag:ref", args = { p._cite_q(newargs), name = q } } -- expand like this: args = { p._cite_q(newargs), name = 'foo', group = 'bar' } else cites[#cites + 1] = p._cite_q(newargs) end end if list then return frame:expandTemplate{ title = list, args = cites } else return table.concat(cites, citesep) end end return p 5uzl1w1wialkhvc66je51rqzdhc07k1 شابلون:Ubli 10 171983 390374 2026-04-18T04:10:49Z en>Pppery 0 Changed protection settings for "[[Template:Ubli]]" ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)) 390374 wikitext text/x-wiki #redirect [[Template:Unbulleted indent list]] {{rcat shell|{{r from template shortcut}}}} h4afikxjf5w5pmmnytsfgsyyf1kn57c 390375 390374 2026-07-17T18:01:04Z محک 1023 ۱ نسخه واردشده از [[:en:Template:Ubli]] 390374 wikitext text/x-wiki #redirect [[Template:Unbulleted indent list]] {{rcat shell|{{r from template shortcut}}}} h4afikxjf5w5pmmnytsfgsyyf1kn57c شابلون:Unbulleted indent list 10 171984 390376 2026-04-18T03:48:54Z en>Pppery 0 Changed protection settings for "[[Template:Unbulleted indent list]]" ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)) 390376 wikitext text/x-wiki {{#invoke:list|unbulleted|list_style=margin-left:{{{in|{{{indent|1em}}}}}};text-indent:-{{{in|{{{indent|1em}}};{{{list_style|}}}}}}}}<noinclude> {{documentation}} <!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --> </noinclude> e7g6r2fcww4yjx4nb1dqwr0bhklddpj 390377 390376 2026-07-17T18:01:24Z محک 1023 ۱ نسخه واردشده از [[:en:Template:Unbulleted_indent_list]] 390376 wikitext text/x-wiki {{#invoke:list|unbulleted|list_style=margin-left:{{{in|{{{indent|1em}}}}}};text-indent:-{{{in|{{{indent|1em}}};{{{list_style|}}}}}}}}<noinclude> {{documentation}} <!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --> </noinclude> e7g6r2fcww4yjx4nb1dqwr0bhklddpj شابلون:صندخ/پشوبزه خط اختیاری ویکی دیتا2/چنگ‌مویی 10 171985 390380 2026-07-17T18:25:31Z محک 1023 اتا نو ولگ بساته که ونه دله «<includeonly>{{صندخ/پشوبزه خط اختیاری |{{{1|}}} |{{#switch:{{تقليم|{{{2|}}}}} |نا|نه|لا|خیر|-|no = <!-- مقدار سرکوب شود، خالی بماند --> |#default = {{#اگر:{{{2|}}} | {{#اگر:{{{قیمه موجود|{{{قیمت موجود|{{{مقدار موجود|{{{موجود مقدار|}}}}}}}}}}}} | {{{قیمه موجود|{{{قیمت موجود|{{{مقدار موجود|{{{...» دره 390380 wikitext text/x-wiki <includeonly>{{صندخ/پشوبزه خط اختیاری |{{{1|}}} |{{#switch:{{تقليم|{{{2|}}}}} |نا|نه|لا|خیر|-|no = <!-- مقدار سرکوب شود، خالی بماند --> |#default = {{#اگر:{{{2|}}} | {{#اگر:{{{قیمه موجود|{{{قیمت موجود|{{{مقدار موجود|{{{موجود مقدار|}}}}}}}}}}}} | {{{قیمه موجود|{{{قیمت موجود|{{{مقدار موجود|{{{موجود مقدار|}}}}}}}}}}}} | {{{2|}}} }} | {{#ifeq:{{{ویکی دیتا|}}} | no | <!-- ویکی‌داده غیرفعال --> | {{#iferror:{{#invoke:ویکی دیتا مقدار{{#اگر:{{{چنگ‌مویی|}}}|/{{{چنگ‌مویی|}}}}}|main|value_is_2=true}} | [[رج:ویکی‌دیتا شابلون خطا دارنه|{{{خاصیه|{{{ویژگی|{{{property|}}}}}}}}}]] }} }} }} }} |colspan={{{co|{{{colspan|}}}}}} |بکگراند={{{بکگراند|}}} }}<!-- -->{{#switch:{{{ویکی دیتا|{{{2|}}}}}}|no= [[رج:صفحه‌ئونی که ویکی دیتا په‌روونه|{{#if:{{{خاصیه|{{{ویژگی|{{{property|}}}}}}}}}|{{{خاصیه|{{{ویژگی|{{{property|}}}}}}}}}|no}}]]}} <!-- نهایه قالب:صندخ/پشوبزه خط اختیاری ویکی دیتا2 --></includeonly><noinclude>{{توضیحات}}[[رج:صندخ]]</noinclude> izgslm1fxdpzz9l3dbi09kjes23jzvg 390382 390380 2026-07-17T18:34:50Z محک 1023 390382 wikitext text/x-wiki <includeonly>{{صندخ/پشوبزه خط اختیاری |{{{1|}}} |{{#switch:{{تقليم|{{{2|}}}}} |نا|نه|لا|خیر|-|no = <!-- سرکوب عمدی --> |#default = {{#اگر:{{تقليم|{{{2|}}}}} | {{#اگر:{{{قیمه موجود|{{{قیمت موجود|{{{مقدار موجود|{{{موجود مقدار|}}}}}}}}}}}} | {{{قیمه موجود|{{{قیمت موجود|{{{مقدار موجود|{{{موجود مقدار|}}}}}}}}}}}} | {{{2|}}} }} | {{#ifeq:{{{ویکی دیتا|}}} | no | <!-- ویکی‌داده غیرفعال --> | {{#iferror:{{#invoke:ویکی دیتا مقدار{{#اگر:{{{چنگ‌مویی|}}}|/{{{چنگ‌مویی|}}}}}|main|value_is_2=true}} | [[رج:ویکی‌دیتا شابلون خطا دارنه|{{{خاصیه|{{{ویژگی|{{{property|}}}}}}}}}]] }} }} }} }} |colspan={{{co|{{{colspan|}}}}}} |بکگراند={{{بکگراند|}}} }}<!-- -->{{#switch:{{{ویکی دیتا|{{{2|}}}}}}|no= [[رج:صفحه‌ئونی که ویکی دیتا په‌روونه|{{#if:{{{خاصیه|{{{ویژگی|{{{property|}}}}}}}}}|{{{خاصیه|{{{ویژگی|{{{property|}}}}}}}}}|no}}]]}} <!-- نهایه قالب:صندخ/پشوبزه خط اختیاری ویکی دیتا2 --></includeonly><noinclude>{{توضیحات}}[[رج:صندخ]]</noinclude> b0u1izucyc3yw91me44fddy5jxvu7ap پورتال:اسایی دکته‌ئون/دکته‌ئون ۱۸ ژوئیه ۲۰۲۶ 100 171986 390391 2026-07-18T05:28:40Z محک 1023 اتا نو ولگ بساته که ونه دله «* آمریکای ارتش شه بمبارون ره إدامه دنه. وشون چنتا پل و فرودگاه ره هم بزونه که [[آنتونیو گوارش]] (متحد ملل رئیس) وشون کار ره محکوم هاکرده. ایران هم أی چنتا نفتکش ره بترکانی‌یه و باته اونان که ونه هداری نشینه، مین ره بندستنه و بترکستنه. عربی کشورو...» دره 390391 wikitext text/x-wiki * آمریکای ارتش شه بمبارون ره إدامه دنه. وشون چنتا پل و فرودگاه ره هم بزونه که [[آنتونیو گوارش]] (متحد ملل رئیس) وشون کار ره محکوم هاکرده. ایران هم أی چنتا نفتکش ره بترکانی‌یه و باته اونان که ونه هداری نشینه، مین ره بندستنه و بترکستنه. عربی کشورون ره همینتی موشک کپتل کنده. ایرانی نظامیون هشدار هدانه که اگه آمریکا بخائه ایرانِ جیرساختون ره بزنه، این‌صوه [[باب‌المندب|باب‌المندب تنگه]] ره [[یمن انصار الله]] کومک جه، وندنه. tsyba2lizlytjfiu1rkhqqvc32eiszw 390393 390391 2026-07-18T05:29:16Z محک 1023 390393 wikitext text/x-wiki * آمریکای ارتش شه بمبارون ره إدامه دنه. وشون چنتا پل و فرودگاه ره هم بزونه که [[آنتونیو گوترش]] (متحد ملل رئیس) وشون کار ره محکوم هاکرده. ایران هم أی چنتا نفتکش ره بترکانی‌یه و باته اونان که ونه هداری نشینه، مین ره بندستنه و بترکستنه. عربی کشورون ره همینتی موشک کپتل کنده. ایرانی نظامیون هشدار هدانه که اگه آمریکا بخائه ایرانِ جیرساختون ره بزنه، این‌صوه [[باب‌المندب|باب‌المندب تنگه]] ره [[یمن انصار الله]] کومک جه، وندنه. phobumxiufyzafnyxev167vyswyw436 یمن انصار الله 0 171987 390392 2026-07-18T05:29:03Z محک 1023 ونه مسیر ره دکشی‌یه [[یمن انصارالله]] دله 390392 wikitext text/x-wiki #بور[[یمن انصارالله]] 746b1ctpdmdwifvgt3vfepg6qi30s17 شابلون:Country data UN 10 171988 390397 2026-07-18T05:49:49Z محک 1023 ونه مسیر ره دکشی‌یه [[شابلون:Country data United Nations]] دله 390397 wikitext text/x-wiki #بور[[شابلون:Country data United Nations]] 1mrp87kh8sjb4h2ljmf50fg6g1hwnig آلمانیزوون 0 171989 390400 2026-07-18T05:57:09Z محک 1023 ونه مسیر ره دکشی‌یه [[آلمانی]] دله 390400 wikitext text/x-wiki #بور[[آلمانی]] grqlfuidjs7ybe48uot8yrh6phdzyzw آمیش 0 171990 390401 2026-07-18T06:05:27Z محک 1023 مقاله‌ئونی که گت صفحه‌یِ کادر جه بساتنه. 390401 wikitext text/x-wiki {{صندخ/نژاد<!-- اینجه تونی شه مقالهٔ کلّی موضوع ره بنویسین تا صندخ بساجه. شهر، شخص، موجود، بنا، کومپانی و... واری -->}} '''آمیش''' اتا فرقه آدم هستنه که [[آمریکای متحده ایالات]] دله درنه. وشون [[آلمانی]] رگ-ریشه دارنه و اتی زوون گپ زنه که وه ره [[پنسیلوانیای آلمانی]] (یا هلندی) گننه. آمیش ویشته اتا مذهب هسته تا قومیت. وشون خله سخت و دبسته عقیده دارنه؛ موشین سوار نوونه، تلفن ندارنه، سره برق دنی‌یه و قدیم دسوری درنه. آمیش‌ها شه وچون ره [[تعمید غسل]] نکنه و گنه هرکس شه ونه اونجه برسه که مسیح جه ایمان بیاره و اون گدر غسل هاکنه. وشون هئی جه زن گیرنه و اتا جا منزل کنه. کلیسا نشونه و هر یه‌شمبه هئی سره دوره إلنه. البته وشون دله تندرو و معتدل درنه. بعضی‌شون کسی که حاضر نبو تکنولوجی جه دست بکشه ره طرد کنّه و سره راه ندنّه و ونجه دکّل دیگه گپ نزنه. == منابع == {{په‌نویس}} <!--- رج‌ئون: ---> [[رج:آلمانی تبارون]] [[رج:آمریکا فرهنگ]] bfntqbr9jjo0mkcb9pvw7l8gxhtah0c گپ:آمیش 1 171991 390402 2026-07-18T06:08:20Z محک 1023 اتا نو ولگ بساته که ونه دله «{{شاپ‌زن}} {{گپ صفحه}}» دره 390402 wikitext text/x-wiki {{شاپ‌زن}} {{گپ صفحه}} 1vjigdfx9z1fnd3v7eklhi54qleb3gu وسطا سده‌ئون 0 171992 390404 2026-07-18T06:15:30Z محک 1023 ونه مسیر ره دکشی‌یه [[میونی صدکون]] دله 390404 wikitext text/x-wiki #بور[[میونی صدکون]] 7ub7hs0gkr48ppsakiy0m0vewa6gnf1 فرانسه گت اینقلاب 0 171993 390405 2026-07-18T06:16:01Z محک 1023 ونه مسیر ره دکشی‌یه [[فرانسه انقلاب]] دله 390405 wikitext text/x-wiki #بور[[فرانسه انقلاب]] j8t3w7rzmymz5wvfh5x684a6neniz7n اونوره دو بازاک 0 171994 390406 2026-07-18T06:16:49Z محک 1023 ونه مسیر ره دکشی‌یه [[انغه دو بلزک]] دله 390406 wikitext text/x-wiki #بور[[انغه دو بلزک]] gci6bhbxvtgs1bkj1k21yf109emi3b3