« Module:Localized name » : différence entre les versions

De Pikmin FR
fr>Fxfxfx0
mAucun résumé des modifications
mAucun résumé des modifications
Ligne 1 : Ligne 1 :
local p = {}
local p = {}
local gameShortenedModule = require("Module:GameShortened")
local gameShortenedModule = require("Module:Game shortened")
local flagModule = require("Module:Flag")
local flagModule = require("Module:Flag")


Ligne 90 : Ligne 90 :
     end
     end


     table.insert(t, "!" .. (args["column-1"] or "Langue"))
     table.insert(t, "!" .. (args["column-1"] or "Language"))
     table.insert(t, "!" .. (args["column-2"] or "Nom"))
     table.insert(t, "!" .. (args["column-2"] or "Name"))
     table.insert(t, "!" .. (args["column-3"] or "Signification"))
     table.insert(t, "!" .. (args["column-3"] or "Meaning"))


     -- Handle each language
     -- Handle each language
     handleLanguage(t, args, "Français (NOA)", "FraA", "ca", "fr-ca")
     handleLanguage(t, args, "Japanese", "Jap", "jp", "ja")
     handleLanguage(t, args, "Japonais", "Jap", "jp", "ja")
     handleLanguage(t, args, "Dutch", "Dut", "nl", "nl")
     handleLanguage(t, args, "Anglais", "Eng", "usgb", "usgb")
     handleLanguage(t, args, "French", "Fra", "cafr", "fr")
     handleLanguage(t, args, "Anglais (NOA)", "EngA", "uk", "en-uk")
     handleLanguage(t, args, "French (NOA)", "FraA", "ca", "fr-ca")
     handleLanguage(t, args, "Anglais (NOE)", "EngE", "us", "en-us")
     handleLanguage(t, args, "French (NOE)", "FraE", "fr", "fr-fr")
     handleLanguage(t, args, "Allemand", "Ger", "de", "de")
     handleLanguage(t, args, "French", "Fre", "cafr", "fr")
     handleLanguage(t, args, "Espagnol", "Spa", "esmx", "es")
     handleLanguage(t, args, "French (NOA)", "FreA", "ca", "fr-ca")
     handleLanguage(t, args, "Espagnol (NOA)", "SpaA", "mx", "es-mx")
     handleLanguage(t, args, "French (NOE)", "FreE", "fr", "fr-fr")
     handleLanguage(t, args, "Espagnol (NOE)", "SpaE", "es", "es-es")
     handleLanguage(t, args, "German", "Ger", "de", "de")
     handleLanguage(t, args, "Italien", "Ita", "it", "it")
     handleLanguage(t, args, "Italian", "Ita", "it", "it")
     handleLanguage(t, args, "Néerlandais", "Dut", "nl", "nl")
     handleLanguage(t, args, "Russian", "Rus", "ru", "ru")
     handleLanguage(t, args, "Portugais", "Por", "pt", "pt")
     handleLanguage(t, args, "Spanish", "Spa", "esmx", "es")
     handleLanguage(t, args, "Portugais (NOA)", "PorA", "br", "pt-br")
     handleLanguage(t, args, "Spanish (NOA)", "SpaA", "mx", "es-mx")
     handleLanguage(t, args, "Portugais (NOE)", "PorE", "pt", "pt-pt")
     handleLanguage(t, args, "Spanish (NOE)", "SpaE", "es", "es-es")
     handleLanguage(t, args, "Russe", "Rus", "ru", "ru")
     handleLanguage(t, args, "Chinese", "Chi", "cn", "zh")
     handleLanguage(t, args, "Chinois", "Chi", "cn", "zh")
     handleLanguage(t, args, "Chinese (Simplified)", "ChiS", "cn", "zh-Hans")
     handleLanguage(t, args, "Chinois (Simplifié)", "ChiS", "cn", "zh-Hans")
     handleLanguage(t, args, "Chinese (Traditional)", "ChiT", "hk", "zh-Hant")
     handleLanguage(t, args, "Chinois (Traditionnel)", "ChiT", "hk", "zh-Hant")
     handleLanguage(t, args, "Czech", "Cze", "cz", "cs")
     handleLanguage(t, args, "Coréen", "Kor", "kr", "ko")
     handleLanguage(t, args, "Danish", "Dan", "dk", "da")
     handleLanguage(t, args, "Danois", "Dan", "da", "da")
     handleLanguage(t, args, "Finnish", "Fin", "fi", "fi")
     handleLanguage(t, args, "Finlandais", "Fin", "fi", "fi")
     handleLanguage(t, args, "Hungarian", "Hun", "hu", "hu")
     handleLanguage(t, args, "Hongrois", "Hun", "hu", "hu")
     handleLanguage(t, args, "Korean", "Kor", "kr", "ko")
     handleLanguage(t, args, "Norvégien", "Nor", "no", "no")
     handleLanguage(t, args, "Norwegian", "Nor", "no", "no")
     handleLanguage(t, args, "Polonais", "Pol", "pl", "pl")
     handleLanguage(t, args, "Polish", "Pol", "pl", "pl")
     handleLanguage(t, args, "Suédois", "Swe", "se", "sv")
     handleLanguage(t, args, "Portuguese", "Por", "pt", "pt")
     handleLanguage(t, args, "Tchèque", "Cze", "cz", "cs")
     handleLanguage(t, args, "Portuguese (NOA)", "PorA", "br", "pt-br")
 
    handleLanguage(t, args, "Portuguese (NOE)", "PorE", "pt", "pt-pt")
 
    handleLanguage(t, args, "Swedish", "Swe", "se", "sv")
 
 
 
 
 
 


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



Version du 17 septembre 2024 à 16:49

Summary

This template is a standardized table for the languages that the série Splatoon 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.
--
Eng EngM Anglais ?
EngA EngAM Anglais NOA ?
EngE EngME Anglais NOE ?

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=Nihongo
|JapM=Japanese
|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
|Eng=Anglais
|EngM=Anglais
|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:

Small table
Language Name Meaning
Japan Japanese Example Japanese Explanation for Japanese


Optional table title
Language Name Meaning
Japan Japanese 日本語
Nihongo
Japanese
Netherlands Dutch nederlands Dutch
Canada French (NOA) Français NOA Français NOA
Germany German Deutsch German
Italy Italian italiano Italian
Russia Russian русский
russkiy
Russian
SpainMexico Spanish español Spanish
China Chinese 中文
zhōngwén
Chinese
CzechRepublic Czech český jazyk Czech language
Denmark Danish dansk Danish
Finland Finnish Suomen kieli Finnish language
Hungary Hungarian magyar nyelv Hungarian language
South Korea Korean 한국어
han gook uh
Korean language
Norway Norwegian norsk Norweigian
Poland Polish Język polski Polish language
Portugal Portuguese portugues Portuguese
Sweden Swedish svenska Swedish
Fichier:Translate logo.svg Internal Vss_Object_Language Additional notes for the game IDs


Multiple names test
Language Name Meaning
Japan Japanese 数字
sūji
numeral

ichi
one

ni
two

san
three

shi
four

go
five

roku
six

shichi
seven

hachi
eight

kyū
nine

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

local function getGameShortened(game, default)
    return gameShortenedModule.getGame(game, default)
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)

    local function getName(args, wikiParameter)
        local name = args[wikiParameter] or "Unnamed language (" .. wikiParameter .. ")"

        local romanized = ""
        if args[wikiParameter .. "R"] and args[wikiParameter .. "R"] ~= "" then
            romanized = "<br/>''" .. args[wikiParameter .. "R"] .. "''"
        end

        local meaning = ""
        if args[wikiParameter .. "M"] and args[wikiParameter .. "M"] ~= "" then
            meaning = args[wikiParameter .. "M"]
        end

        return {
            name=name,
            romanized=romanized,
            meaning=meaning,
        }
    end

    local names = {}
    if args[wikiParameter] and args[wikiParameter] ~= '' then
        table.insert(names, getName(args, wikiParameter))
    end
    for i=1,9 do
        if args[wikiParameter .. i] and args[wikiParameter .. i] ~= '' then
            table.insert(names, getName(args, wikiParameter .. i))
        end
    end

    if table.getn(names) > 0 then
        local flag = getFlag(flagParameter)
        if not flag then
            flag = "[[File:Flag.svg|link=]]"
        end

        local htmlLang = htmlLanguageCode or wikiParameter or ""

        for i,v in ipairs(names) do
            table.insert(t, "|-")
            local row = ""
            if i == 1 then
                if table.getn(names) > 1 then
                    row = "|rowspan=" .. table.getn(names)
                end
                row = row .. "|" .. flag .. "&nbsp;" .. languageTitle .. "||"
            end
            row = row .. "|<span lang=\"" .. htmlLang .. "\">" .. v.name .. "</span>" .. v.romanized .. "|||" .. v.meaning
            table.insert(t, row)
        end
    end
end

function p.main(frame)
    local args = frame:getParent().args
    return p.localizedName(args)
end

function p.localizedName(args)
    local colorClass = "generic"
    if args["color"] and args["color"] ~= '' then
        colorClass = mw.ustring.lower(getGameShortened(args["color"], "generic")) or "generic"
    end
    local t = {}
    mw.logObject(colorClass)
    table.insert(t, '{| class="wikitable sitecolor-' .. colorClass .. '" style="min-width: 25%;')
    if args["title"] then
        table.insert(t, "|+" .. args.title)
    end

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

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

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

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

return p