Module:Localized name: Difference between revisions

From Inkipedia, the Splatoon wiki
 
mNo edit summary
Line 35: Line 35:
     local args = frame:getParent().args
     local args = frame:getParent().args
     local colorClass = "generic"
     local colorClass = "generic"
     if args["color"] then
     if args["color"] and args["color"] ~= '' then
         colorClass = getGameShortened(string.lower(args["color"]))
         colorClass = getGameShortened(string.lower(args["color"]))
     end
     end

Revision as of 19:00, 13 September 2023

Summary

This template is a standardized table for the languages that the Splatoon series supports, to translate article subjects and provide their respective meanings.

Usage

This template should precede the Trivia section of a page and be a subsection to Etymology when applicable.

The color of the template can be specified using

  • color= X, where X is Splatoon for a Splatoon article, Splatoon 2 for a Splatoon 2 article, and Splatoon 3 for a Splatoon 3 article. Do not use this parameter for a table that is not specifically attributed to any game.

If needed, the table can be customized using

  • title= X, where X is any title you want to add. This parameter is meant for pages with multiple uses of the template to be able to have more precise titles.
  • column-1= X, where X is the heading for column 1. By default this is "Language".
  • column-2= X, where X is the heading for column 2. By default this is "Name".
  • column-3= X, where X is the heading for column 3. By default this is "Meaning".

The language's abbreviation and M (for Meaning) are parameters for this template. For Japanese, Korean, Chinese and Russian, an additional abbreviation + R (Romanized) can be used. Multiple names can also be specified by adding the number 1 to 9 after the language's abbreviation (e.g. Jap1, Jap1R, Jap1M), in case there has been multiple different localization for the name in various context.

Chinese, French, Spanish, and Portuguese have additional localizations depending on the region. If the localization is the same, please use the parent group. Otherwise, the more specific parameters should be used.

Parameter Additional options Language Culture code
Jap JapM, JapR Japanese JPja
Dut DutM Dutch EUnl
Fra or Fre FraM French EUfr and USfr
FraA or FreA FraAM NOA French USfr
FraE or FreE FraEM NOE French EUfr
Ger GerM German EUde
Ita ItaM Italian EUit
Por PorM Portuguese EUpt(?) and USpt(?)
PorA PorAM NOA Portuguese USpt(?)
PorE PorEM NOE Portuguese EUpt(?)
Rus RusM, RusR Russian EUru
Spa SpaM Spanish EUes and USes
SpaA SpaAM NOA Spanish USes
SpaE SpaEM NOE Spanish EUes
Chi ChiM, ChiR Chinese CNzh and TWzh
ChiS ChiSM, ChiSR Simplified Chinese CNzh
ChiT ChiTM, ChiTR Traditional Chinese TWzh
Kor KorM, KorR Korean KRko
Cze CzeM Czech ?
Dan DanM Danish ?
Fin FinM Finnish ?
Hun HunM Hungarian ?
Nor NorM Norwegian ?
Pol PolM Polish ?
Swe SweM Swedish ?
Internal InternalM Game IDs and supporting notes.
This must be sourced per our leaks policy.
--

Examples

A small table:

{{Localized name
|title=Small table
|color=Splatoon 2
|Jap=Example Japanese
|JapM=Explanation for Japanese
}}

A full template:

{{Localized name
|title=Optional table title
|color=Splatoon
|Jap=日本
|JapR=Nihon
|JapM=Japan
|Dut=nederlands
|DutM=Dutch
|Fre=français
|FreM=French
|Ger=Deutsch
|GerM=German
|Ita=italiano
|ItaM=Italian
|Por=portugues
|PorM=Portuguese
|Rus=русский
|RusR=russkiy
|RusM=Russian
|Spa=español
|SpaM=Spanish
|Chi=中文
|ChiR=zhōngwén
|ChiM=Chinese
|Kor=한국어
|KorR=han gook uh
|KorM=Korean language
|Cze=český jazyk
|CzeM=Czech language
|Dan=dansk
|DanM=Danish
|Fin=Suomen kieli
|FinM=Finnish language
|Hun=magyar nyelv
|HunM=Hungarian language
|Nor=norsk
|NorM=Norweigian
|Pol=Język polski
|PolM=Polish language
|Swe=svenska
|SweM=Swedish
|Internal=Vss_Object_Language
|InternalM=Additional notes for the game IDs
}}

Multiple names:

{{Localized name
|title=Multiple names test
|Jap=数字
|JapR=sūji
|JapM=numeral
|Jap1=一
|Jap1R=ichi
|Jap1M=one
|Jap2=二
|Jap2R=ni
|Jap2M=two
|Jap3=三
|Jap3R=san
|Jap3M=three
|Jap4=四
|Jap4R=shi
|Jap4M=four
|Jap5=五
|Jap5R=go
|Jap5M=five
|Jap6=六
|Jap6R=roku
|Jap6M=six
|Jap7=七
|Jap7R=shichi
|Jap7M=seven
|Jap8=八
|Jap8R=hachi
|Jap8M=eight
|Jap9=九
|Jap9R=kyū
|Jap9M=nine
}}

Which looks like: Lua error at line 42: bad argument #3 to 'format' (no value).

Lua error at line 42: bad argument #3 to 'format' (no value).

Lua error at line 42: bad argument #3 to 'format' (no value).


local p = {}
local gameShortenedModule = require("Module:GameShortened")
local flagModule = require("Module:Flag")

local function getGameShortened(game)
    return gameShortenedModule.getGame(game, "")
end

local function getFlag(country)
    return flagModule.getFlag(country, "20x20")
end

-- Function to handle a single language entry in the table
-- t: the table to append
-- args: the frame args which includes the Meaning and Romanized values if applicable
-- languageTitle: the Title Case description of the language
-- wikiParameter: the base wiki parameter (without M and R) for the language we are handling
-- flagParameter: the two letter lower-case code for this language
-- htmlLanguageCode: the language code used in HTML for this language. Reference: [https://www.w3schools.com/tags/ref_language_codes.asp]
local function handleLanguage(t, args, languageTitle, wikiParameter, flagParameter, htmlLanguageCode)
    if args[wikiParameter] then
        table.insert(t, "|-")
        table.insert(t,
            string.format(
                "|%s&nbsp;%s|||<span lang=\"%s\">%s</span>%s|||%s",
                getFlag(flagParameter), languageTitle, htmlLanguageCode or wikiParameter,
                args[wikiParameter], args[wikiParameter .. "R"] and "<br/>''" .. args[wikiParameter .. "R"] .. "''" or "",
                args[wikiParameter .. "M"] or ""
            )
        )
    end
end

function p.main(frame)
    local args = frame:getParent().args
    local colorClass = "generic"
    if args["color"] and args["color"] ~= '' then
        colorClass = getGameShortened(string.lower(args["color"]))
    end
    local t = {}
    table.insert(t,
                 string.format(
                     '{| class="wikitable sitecolor-%s" style="min-width: 25%;"',
                     colorClass))

    if args["title"] then
        table.insert(t, "|+" .. args.title)
    end

    table.insert(t, string.format("!%s", args["column-1"] or "Language"))
    table.insert(t, string.format("!%s", args["column-2"] or "Name"))
    table.insert(t, string.format("!%s", args["column-3"] or "Meaning"))

    -- Handle each language
    handleLanguage("Japanese", "Jap", "jp", "ja")
    handleLanguage("Dutch", "Dut", "nl", "nl")
    handleLanguage("French", "Fra", "cafr", "fr")
    handleLanguage("French (NOA)", "FraA", "ca", "fr-ca")
    handleLanguage("French (NOE)", "FraE", "fr", "fr-fr")
    handleLanguage("German", "Ger", "de", "de")
    handleLanguage("Italian", "Ita", "it", "it")
    handleLanguage("Russian", "Rus", "ru", "ru")
    handleLanguage("Spanish", "Spa", "esmx", "es")
    handleLanguage("Spanish (NOA)", "SpaA", "mx", "es-mx")
    handleLanguage("Spanish (NOE)", "SpaE", "es", "es-es")
    handleLanguage("Chinese", "Chi", "cn", "zh")
    handleLanguage("Chinese (Simplified)", "ChiS", "cn", "zh-Hans")
    handleLanguage("Chinese (Traditional)", "ChiT", "hk", "zh-Hant")
    handleLanguage("Czech", "Cze", "cz", "cs")
    handleLanguage("Danish", "Dan", "da", "da")
    handleLanguage("Finnish", "Fin", "fi", "fi")
    handleLanguage("Hungarian", "Hun", "hu", "hu")
    handleLanguage("Korean", "Kor", "kr", "ko")
    handleLanguage("Norwegian", "Nor", "no", "no")
    handleLanguage("Polish", "Pol", "pl", "pl")
    handleLanguage("Portuguese", "Por", "pt", "pt")
    handleLanguage("Portuguese (NOA)", "PorA", "br", "pt-br")
    handleLanguage("Portuguese (NOE)", "PorE", "pt", "pt-pt")
    handleLanguage("Swedish", "Swe", "se", "sv")

    -- Internal is a bit different because there's no code or flag
    if args["Internal"] then
        table.insert(t, "|-")
        table.insert(t,
            string.format(
                "[[File:Translate logo.svg|border|20px|link=]]&nbsp;Internal|||<span lang=\"\">%s</span>|||%s",
                args["Internal"], args["InternalM"] or ""
            )
        )
    end

    return table.concat(t, "\n") .. "\n|}"
end

return p