Zum Inhalt springen

Modul:Age: Unterschied zwischen den Versionen

642 Bytes hinzugefügt ,  vor 11 Jahren
K
Documented unusual plural/singular handling (no code changes were made, only comments); tested with :Australian_Labor_Party
(add support for {{Age in days}} and {{Gregorian serial date}})
K (Documented unusual plural/singular handling (no code changes were made, only comments); tested with :Australian_Labor_Party)
Zeile 15: Zeile 15:
     sep = sep or ' '
     sep = sep or ' '
     return tostring(number) .. sep .. ((number == 1) and singular or plural)
     return tostring(number) .. sep .. ((number == 1) and singular or plural)
    -- this uses an interesting trick of Lua:
    --  * and reurns false if the first argument is false, and the second otherwise, so (number==1) and singular returns singular if its 1, returns false if it is only 1
    --  * or returns the first argument if it is not false, and the second argument if the first is false
    --  * so, if number is 1, and evaluates (true and singular) returning (singular); or evaluates (singular or plural), finds singular non-false, and returns singular
    --  * but, if number is not 1, and evaluates (false and singular) returning (false); or evaluates (false or plural), and is forced to return plural
end
end


Anonymer Benutzer