Module:ja-counter-table
Appearance
- The following documentation is located at Module:ja-counter-table/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module deploys a formatted table with the informational purpose for counter words and numbers in Japanese, with their proper contractions.
Example for 個:
Japanese counter/suffix: 個 (ko) | |||
---|---|---|---|
Number | Kanji | Kana | Romaji |
? | 何個 | なんこ | nanko |
0 | 0個、零個 | ゼロこ、れいこ | zeroko, reiko |
1 | 一個 | いっこ | ikko |
2 | 二個 | にこ | niko |
3 | 三個 | さんこ | sanko |
4 | 四個 | よんこ | yonko |
5 | 五個 | ごこ | goko |
6 | 六個 | ろっこ | rokko |
7 | 七個 | ななこ、しちこ | nanako, shichiko |
8 | 八個 | はっこ、はちこ | hakko, hachiko |
9 | 九個 | きゅうこ | kyūko |
10 | 十個 | じっこ、じゅっこ | jikko, jukko |
11 | 十一個 | じゅういっこ | jūikko |
12 | 十二個 | じゅうにこ | jūniko |
20 | 二十個 | にじっこ、にじゅっこ | nijikko, nijukko |
21 | 二十一個 | にじゅういっこ | nijūikko |
100 | 百個 | ひゃっこ | hyakko |
1000 | 千個 | せんこ | senko |
10000 | 一万個 | いちまんこ | ichimanko |
100000000 | 一億個 | いちおくこ | ichiokuko |
local export = {}
local janumeral = require("Module:ja-numeral").convert
local kanatoromaji = require("Module:Hrkt-translit").tr
local jalink = require("Module:ja-link").link
function export.show(frame)
local params = { [1] = { required=true, allow_empty=true, list=true } }
local args = require("Module:parameters").process(frame.args, params)[1]
if args[1] == nil then
error("Zero arguments")
end
local counter = args[1]
local counterkana = args[2]
local strbuf = {}
table.insert(strbuf, '{| class="wikitable mw-collapsible mw-expanded"')
table.insert(strbuf, 'style="margin-left:0.5em; ')
table.insert(strbuf, 'margin-bottom:0.5em; border: 1px solid #AAAAAA; ')
table.insert(strbuf, 'border-collapse:collapse;" cellpadding="3" ')
table.insert(strbuf, 'rules="all"')
table.insert(strbuf, '\n! colspan = 4 | Japanese counter/suffix: ')
if counterkana == "" then
if counterkana ~= nil then
table.insert(strbuf, "[[")
table.insert(strbuf, counter)
table.insert(strbuf, "#Japanese|")
table.insert(strbuf, counter)
table.insert(strbuf, "]]")
end
else
table.insert(strbuf, jalink({
lang=require('Module:languages').getByCode("ja"),
lemma=counter, kana=counterkana},
{ }))
end
table.insert(strbuf, '\n|-')
table.insert(strbuf, '\n! Number\n! [[kanji|Kanji]]')
table.insert(strbuf, '\n! [[kana|Kana]]\n! [[romaji|Romaji]]')
if args[3] ~= nil and args[3] ~= "-" then
error('Argument 3 must be single hyphen "-"')
end
local i = 3
while true do
if args[i] == nil then
break
end
local number = args[i + 1]
local numberkanji = args[i + 2]
local readingsbegin = i + 3
local readingsend = i + 3
while true do
local reading = args[readingsend]
if reading == "" or reading == nil or reading == "-" then
break
end
readingsend = readingsend + 1
end
table.insert(strbuf, '\n|-\n|align="right"| ')
if number ~= nil and number ~= "" then
table.insert(strbuf, number)
end
table.insert(strbuf, '\n|align="center"| ')
if numberkanji ~= nil and numberkanji ~= "" then
table.insert(strbuf, numberkanji)
elseif number ~= nil and number ~= "" then
if number == "?" then
table.insert(strbuf, "[[何")
table.insert(strbuf, counter)
table.insert(strbuf, "#Japanese|何")
table.insert(strbuf, counter)
table.insert(strbuf, "]]")
elseif string.match(number, "^%d+$") then
if tonumber(number) == 0 then
table.insert(strbuf, "[[0")
table.insert(strbuf, counter)
table.insert(strbuf, "#Japanese|0")
table.insert(strbuf, counter)
table.insert(strbuf, "]]、[[零")
table.insert(strbuf, counter)
table.insert(strbuf, "#Japanese|零")
table.insert(strbuf, counter)
table.insert(strbuf, "]]")
else
local numeral = janumeral(number)
table.insert(strbuf, "[[")
table.insert(strbuf, numeral)
table.insert(strbuf, counter)
table.insert(strbuf, "#Japanese|")
table.insert(strbuf, numeral)
table.insert(strbuf, counter)
table.insert(strbuf, "]]")
end
end
end
table.insert(strbuf, '\n|align="center"| ')
for readingi = readingsbegin, readingsend - 1 do
local reading = args[readingi]
table.insert(strbuf, reading)
if readingi ~= readingsend - 1 then
table.insert(strbuf, "、")
end
end
table.insert(strbuf, '\n|align="center"| ')
for readingi = readingsbegin, readingsend - 1 do
local reading = args[readingi]
local romaji = kanatoromaji(reading)
table.insert(strbuf, romaji)
if readingi ~= readingsend - 1 then
table.insert(strbuf, ", ")
end
end
i = readingsend
end
table.insert(strbuf, '\n|}')
return table.concat(strbuf)
end
return export
Categories:
- Southern Amami Ōshima modules
- Language-specific utility modules
- Japanese modules
- Old Japanese modules
- Kunigami modules
- Kikai modules
- Okinawan modules
- Proto-Ryukyuan modules
- Miyako modules
- Yonaguni modules
- Yaeyama modules
- Northern Amami Ōshima modules
- Hachijō modules
- Proto-Japonic modules
- Tokunoshima modules
- Okinoerabu modules
- Yoron modules