Wikimedia

Create a plural module for Romanian Wikipedia

[knowledge of Romanian is NOT needed for this task]
Create a new Scribunto [1] module that, given the number of elements and a second parameter (the singular of a noun) returns the correct plural form.

The plural rule for Romanian is: (n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);

In this equation:

  • n is the number of elements (the first parameter of the function)
  • 0,1,2 (the possible results of the expression) are the plural forms to be used:
    • 0 means singular (return the second parameter)
    • 1 means the first plural form is used; this form will be retrieved from a Lua table. If the singular form is not in the table, it will be generated by appending 'i' to the singular form.
    • 2 means the second plural form will be used; this form is created by concatenating the word 'de ' (plus whitespace) + the first plural form

Example (use this for testing your page):
Singular: 1 locuitor
1st plural: 15 locuitori
2nd plural: 23 de locuitori
Plural table:

  plural = {}  
  plural["locuitor"] = "locuitori"

Other notes:

  • in order to be seen as a Scribunto module, the script must be in the "Modul:" namespace; we strongly suggest using "Modul:Plural" [2]; if not, please mention the title used
  • you will need to create a page that will invoke [3] the module in order to show it works

[1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual
[2] https://ro.wikipedia.org/w/index.php?title=Modul:Plural
[3] https://www.mediawiki.org/wiki/Extension:Scribunto#Usage

Task tags

  • lua
  • scribunto
  • coding
  • modules
  • language

Students who completed this task

neonowy

Task type

  • code Code
close

2015