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 OODA WIKI 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 module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
Some simple internationalization that can be called by other modules
--[[ __ __ _ _ _ _ _ _ _ | \/ | ___ __| |_ _| | ___ _| | (_)_ __ __ _ _ _(_)___| |_(_) ___ | |\/| |/ _ \ / _` | | | | |/ _ (_) | | | '_ \ / _` | | | | / __| __| |/ __| | | | | (_) | (_| | |_| | | __/_| |___| | | | | (_| | |_| | \__ \ |_| | (__ |_| |_|\___/ \__,_|\__,_|_|\___(_)_____|_|_| |_|\__, |\__,_|_|___/\__|_|\___| |___/ Simple internationalization functions that can be called by other modules.This Module was copied from Wikimedia Commons, so please request changes there.Maintainers:* Zolo - original version* JarektDependencies:* Module:I18n/or* Module:Delink* Module:Yesno]]-- ==================================================-- === Internal functions ===========================-- ==================================================localfunctionlangSwitch(list,lang)locallangList=mw.language.getFallbacksFor(lang)table.insert(langList,1,lang)fori,languageinipairs(langList)doiflist[language]thenreturnlist[language]endendreturnnilend-- ==================================================-- === External functions ===========================-- ==================================================localp={}functionp.vowelfirst(str)ifstrthenlocalvowels='aeiouyąăẵằẳặȃắâẫấầẩậãäǟāáàȁǎảẚåǻḁạǡæǣǽĕȇêễếềểệḙẽḛëēḕéḗèȅěẻẹęȩḝǝĭȋîĩḭïḯīíìȉǐỉịįıŏȏôỗốồổộõṏṍöōṑóṓòȍǒỏọǫǭơỡớờởợøǿŭȗûṷũṻṹṵüǖǘǜǚṳūúùȕǔủůụųưữứừửựŷỹÿȳýỳỷẙỵ'str=mw.ustring.lower(mw.ustring.sub(str,1,1))returnmw.ustring.find(vowels,str,1,true)endendfunctionp.inparentheses(str,lang)--todo: define language with exotic parenthesesif(notstr)or(str=="")thenreturnstrelsereturn' ('..str..')'-- needs internationalization.-- Needs leading space in English because as some languages do not use it, it is part of the formattingendendfunctionp.of(word,lang,raw,gender,number,determiner)-- rough translation of "of" in various languages-- note that the cases when on "of" is employed varies a lot among languages, so it is more prudent to call this from lang specific function onlyifnotrawormw.text.trim(raw)==""thenlocalargs={}localDelink=require('Module:Delink')._delinkargs[1]=wordraw=mw.ustring.lower(Delink(args))end-- raw is the string without the Wikiformatting so that it correctly analyses the string that is [[:fr:Italie|Italie]] -> 'italie'-- any way to automate this ?iflang=='fr'thenlocalyesno=require('Module:Yesno')determiner=yesno(determiner,false)ifdeterminerthenifstring.sub(numberor'',1,1)=='p'then-- number == 'plural'return'des '..wordelseifp.vowelfirst(raw)thenreturn'de l’'..wordelseifstring.sub(genderor'',1,1)=='f'then-- gender == 'feminine'return'de la '..wordelsereturn'du '..wordendelseifp.vowelfirst(raw)thenreturn'd’'..wordelsereturn'de '..wordendendelseiflang=='ca'then-- implement [[Template:Of/ca]] or https://ca.wikipedia.org/wiki/Plantilla:Deod%27/base for case where "{{{context}}}" is "en" (default on Commons)if(p.vowelfirst(raw)andnotmw.ustring.find('ia|ià|ie|io|iu|ua|ue|ui|uí|uï|uo|ya|ye|yi|yo|yu|',mw.ustring.sub(raw,1,2)..'|'))thenreturn'd\''..wordelsereturn'de '..wordendendendfunctionp.offromwiki(frame)args=frame.argsreturnp.of(args.word,args.lang,args.raw,args.gender,args.number,args.determiner)endfunctionp.noungroup(noun,adj,lang)ifnotnounornoun==''thenreturnnil-- not '' so that it is not counted as a string by mw.listToTextendifnotadjoradj==''thenreturnnounendlocalwordsep=mw.message.new("Word-separator"):inLanguage(lang):plain()localLUT={de=1,en=1,pl=1,zh=1,fr=2,es=2,it=2}localcase=langSwitch(LUT,lang)ifcase==1then-- adjective before the nounreturnadj..wordsep..nounelseifcase==2then-- adjective after the nounreturnnoun..wordsep..adjelse-- order unknownreturnnoun' ('..adj..')'endendfunctionp.conj(args,lang,conjtype)localcomma=mw.message.new("comma-separator"):inLanguage(lang):plain()localwordsep=mw.message.new("Word-separator"):inLanguage(lang):plain()localandtable={ar=' و',he=' ו',ja='および',pl=' i '}-- languages with a problem with the MediaWiki:Andifconjtype=='comma'thenreturnmw.text.listToText(args,comma,comma)elseifconjtype=='or'thenlocalwordor=langSwitch(require('Module:I18n/or'),lang)returnmw.text.listToText(args,comma,wordor..wordsep)elseifconjtype=='explicit or'then-- adds "or" betwen all words when the context can be confusinglocalwordor=langSwitch(require('Module:I18n/or'),lang)returnmw.text.listToText(args,wordor..wordsep,wordor..wordsep)elseifconjtypeandconjtype~='and'andconjtype~=''thenreturnmw.text.listToText(args,conjtype,conjtype)elseifandtable[lang]thenreturnmw.text.listToText(args,comma,andtable[lang])elselocalwordand=mw.message.new("and"):inLanguage(lang):plain()returnmw.text.listToText(args,comma,wordand..wordsep)endendfunctionp.conjfromWiki(frame)args=frame.argsifnotargsornotargs[1]thenargs=frame:getParent().argsendlocallang=args.langifnotlangormw.text.trim(lang)==''thenlang=frame:callParserFunction("int","lang")endnewargs={}-- transform args metatable into a table so it can be concetenatedfori,jinpairs(args)doiftype(i)=='number'thenj=mw.text.trim(j)ifj~=''thentable.insert(newargs,j)endelseifi~='type'andi~='lang'thenreturn'error: bad parameter in template:Conj: '..i..'[[Category:Pages with incorrect template usage/Conj|A]]'endendendreturnp.conj(newargs,lang,args.type)endreturnp