This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing.
This template is used in MediaWiki:Watchlist-messages. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid large-scale disruption, any changes should first be tested in this template's /sandbox or /testcases subpage, or in your own user space. The tested changes can then be added in one single edit to this template. Please discuss any changes at the talk page before implementing them.
This template is used on approximately 18٬000 pages, so changes to it will be widely noticed. Please test any changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Please consider discussing changes on the talk page قبل تنفيذهم.
Module:StripToNumbers - extract a number from a string (supports negatives and decimals) and return it, or optionally return a halved value
-- وحدة لتحويل الأرقام إلى كلمات عربية-- Arabic version of ConvertNumeric for converting numbers to Arabic text-- This is a simplified version focusing on common Convert module usagerequire('strict')-- الأرقام من 0 إلى 19 (مذكر)localones_position_masc={[0]='صفر',[1]='واحد',[2]='اثنان',[3]='ثلاثة',[4]='أربعة',[5]='خمسة',[6]='ستة',[7]='سبعة',[8]='ثمانية',[9]='تسعة',[10]='عشرة',[11]='أحد عشر',[12]='اثنا عشر',[13]='ثلاثة عشر',[14]='أربعة عشر',[15]='خمسة عشر',[16]='ستة عشر',[17]='سبعة عشر',[18]='ثمانية عشر',[19]='تسعة عشر'}-- الأرقام من 0 إلى 19 (مؤنث)localones_position_fem={[0]='صفر',[1]='واحدة',[2]='اثنتان',[3]='ثلاث',[4]='أربع',[5]='خمس',[6]='ست',[7]='سبع',[8]='ثمان',[9]='تسع',[10]='عشر',[11]='إحدى عشرة',[12]='اثنتا عشرة',[13]='ثلاث عشرة',[14]='أربع عشرة',[15]='خمس عشرة',[16]='ست عشرة',[17]='سبع عشرة',[18]='ثمان عشرة',[19]='تسع عشرة'}-- العشراتlocaltens_position={[2]='عشرون',[3]='ثلاثون',[4]='أربعون',[5]='خمسون',[6]='ستون',[7]='سبعون',[8]='ثمانون',[9]='تسعون'}-- المئاتlocalhundreds={[1]='مائة',[2]='مائتان',[3]='ثلاثمائة',[4]='أربعمائة',[5]='خمسمائة',[6]='ستمائة',[7]='سبعمائة',[8]='ثمانمائة',[9]='تسعمائة'}-- الآلاف والملايينlocalgroups={[1]='ألف',[2]='مليون',[3]='مليار',[4]='تريليون',[5]='كوادريليون',[6]='كوينتيليون'}-- تحويل رقم إلى كلمات عربية (أقل من 100)localfunctionnumeral_to_arabic_less_100(num,feminine,zero)localones_table=feminineandones_position_femorones_position_mascifnum==0andzero~=nilthenreturnzeroelseifnum<20thenreturnones_table[num]elseifnum%10==0thenreturntens_position[num/10]elselocalones=num%10localtens=math.floor(num/10)returnones_table[ones]..' و'..tens_position[tens]endend-- تحويل رقم إلى كلمات عربية (أقل من 1000)localfunctionnumeral_to_arabic_less_1000(num,feminine,zero)num=tonumber(num)ifnum<100thenreturnnumeral_to_arabic_less_100(num,feminine,zero)elseifnum%100==0thenreturnhundreds[num/100]elselocalhundreds_digit=math.floor(num/100)localremainder=num%100returnhundreds[hundreds_digit]..' '..numeral_to_arabic_less_100(remainder,feminine,zero)endend-- دالة أساسية لتحويل الأرقام إلى كلمات عربيةlocalfunction_numeral_to_arabic(num,capitalize,feminine,zero)ifnotnumornum==''thenreturnzeroor'صفر'end-- تحويل إلى نص والتنظيفnum=tostring(num)num=num:gsub("^%s*(.-)%s*$","%1")-- إزالة المسافاتnum=num:gsub(",","")-- إزالة الفواصل-- التحقق من الأرقام السالبةlocalnegative=num:find("^%-")ifnegativethennum=num:sub(2)end-- التحقق من صحة الرقمifnotnum:match("^%d+$")thenreturnzeroor'صفر'endlocalresult=''localnum_value=tonumber(num)-- معالجة الأرقام الكبيرةifnum_value==0thenresult=zeroor'صفر'elseifnum_value<1000thenresult=numeral_to_arabic_less_1000(num_value,feminine,zero)else-- معالجة مبسطة للأرقام الكبيرةlocalgroup_count=0while#num>3dogroup_count=group_count+1localgroup_size=(#num-1)%3+1localgroup_num=tonumber(num:sub(1,group_size))ifgroup_num>0thenifresult~=''thenresult=result..' 'endresult=result..numeral_to_arabic_less_1000(group_num,feminine,zero)ifgroups[group_count]thenresult=result..' '..groups[group_count]endendnum=num:sub(group_size+1)end-- المجموعة الأخيرةlocalfinal_num=tonumber(num)iffinal_num>0thenifresult~=''thenresult=result..' 'endresult=result..numeral_to_arabic_less_1000(final_num,feminine,zero)endend-- إضافة السالبifnegativeandresult~=(zeroor'صفر')thenresult='سالب '..resultend-- الحرف الكبيرifcapitalizethenresult=result:gsub("^(.)",function(c)returnmw.ustring.upper(c)end)endreturnresultend-- دالة مبسطة للاستخدام من قِبل وحدة Convertlocalfunctionspell_number(number,numerator,denominator,case,sp,adj)-- معاملات أساسية لوحدة Convertlocalcapitalize=(case==true)localzero=nillocalfeminine=false-- يمكن تخصيصه حسب الحاجة-- تحويل الرقم الأساسيlocalresult=_numeral_to_arabic(number,capitalize,feminine,zero)-- معالجة الكسور (مبسطة)ifnumeratoranddenominatorthenlocalnum_text=_numeral_to_arabic(numerator,false,feminine,zero)localden_text=_numeral_to_arabic(denominator,false,feminine,zero)ifresultandresult~=''andresult~='صفر'thenresult=result..' و'..num_text..' من '..den_textelseresult=num_text..' من '..den_textendendreturnresultor'صفر'end-- واجهة الوحدةlocalp={spell_number=spell_number,}-- دالة للاستدعاء من القوالبfunctionp.numeral_to_arabic(frame)localargs=frame.argsreturn_numeral_to_arabic(args[1],args['case']=='U'orargs['case']=='u',args['gender']=='f'orargs['gender']=='fem',args['zero'])or'صفر'endreturnp