Wikimedia+Commons>Jarekt |
|
(2 intermediate revisions by 2 users not shown) |
Line 125: |
Line 125: |
| -- INPUTS: | | -- INPUTS: |
| -- * label - label string | | -- * label - label string |
| -- * capitalization - capitalization to be applied: allowed values are "lc", | | -- * capitalization - capitalization to be applied: allowed values are "tc", "lc", |
| -- "uc", "lcfirst", and "ucfirst". Any other value will return original string | | -- "uc", "lcfirst", and "ucfirst". Any other value will return original string |
| -- * lang - language of the label | | -- * lang - language of the label |
Line 135: |
Line 135: |
| return label | | return label |
| elseif capitalization == 'uc' then | | elseif capitalization == 'uc' then |
| return mw.ustring.upper(label) | | return mw.language.new(lang):uc(label) |
| | elseif capitalization == 'lc' then |
| | return mw.language.new(lang):lc(label) |
| | elseif capitalization == 'tc' then -- title case |
| | local new_label = {} |
| | for _, word in ipairs(mw.text.split(label, ' ')) do |
| | table.insert(new_label, mw.language.new(lang):ucfirst(word)) |
| | end |
| | return table.concat(new_label, ' ') |
| elseif capitalization == 'ucfirst' then | | elseif capitalization == 'ucfirst' then |
| return mw.language.new(lang):ucfirst(label) | | return mw.language.new(lang):ucfirst(label) |
| elseif capitalization == 'lc' then
| |
| return mw.ustring.lower(label)
| |
| elseif capitalization == 'lcfirst' then | | elseif capitalization == 'lcfirst' then |
| return mw.language.new(lang):lcfirst(label) | | return mw.language.new(lang):lcfirst(label) |
Line 443: |
Line 449: |
| 2: language (optional; default {{int:lang}}) | | 2: language (optional; default {{int:lang}}) |
| 3: link_style: "wikipedia" (default), "Wikidata", "Commons", or "-" (no link) | | 3: link_style: "wikipedia" (default), "Wikidata", "Commons", or "-" (no link) |
| 4: capitalization - can be "uc", "lc", "ucfirst", "lcfirst" | | 4: capitalization - can be "uc", "lc", "tc", "ucfirst", "lcfirst" |
|
| |
|
| Error Handling: | | Error Handling: |