Terraria Mods Wiki:Translating mod wiki

From Terraria Mods Wiki
Jump to navigation Jump to search

On the Terraria Mods Wiki, you can translate existing wiki pages about a mod from English to other languages. This is possible due to the templates that support i18n.

Translating a mod wiki

Preparation

At this moment, Terraria Mods Wiki supports translation into 9 languages: Chinese (zh), French (fr), German (de), Korean (ko), Polish (pl), Portuguese (pt), Russian (ru), Spanish (es), and Ukrainian (uk). If you want to add more languages, ask about it on the Terraria Mods Wiki:Admin noticeboard or contact one of the administrators.

You are only able to translate wikis that already exist. If the mod doesn't have its own English wiki here, please first create a wiki about this mod in English and after that you can translate it into your language.

Language database

First, you have to add a database with the localization of the mod's terms for the proper work of many templates. This database should contain terms like item names, NPC names, names of mechanics, etc. To do this, create a new page called Module:Tr/db-<mod name> and copy the following placeholder:

return {
    ["de"] = {
        -- add your localization for the terms in German
        -- f.e. you can add `["Fish"] = "Fisch",` to transform `Fish` into `Fisch`
        -- you can delete the subtable for this language if you want
        
    },
    ["es"] = {
        -- add your localization for the terms in Spanish
        -- f.e. you can add `["Fish"] = "Pesca",` to transform `Fish` into `Pesca`
        -- you can delete the subtable for this language if you want
        
    },
    ["fr"] = {
        -- add your localization for the terms in French
        -- f.e. you can add `["Fish"] = "Poisson",` to transform `Fish` into `Poisson`
        -- you can delete the subtable for this language if you want
        
    },
    ["ko"] = {
        -- add your localization for the terms in Korean
        -- f.e. you can add `["Fish"] = "물고기",` to transform `Fish` into `물고기`
        -- you can delete the subtable for this language if you want
        
    },
    ["pl"] = {
        -- add your localization for the terms in Polish
        -- f.e. you can add `["Fish"] = "Ryba",` to transform `Fish` into `Ryba`
        -- you can delete the subtable for this language if you want
        
    },
    ["pt"] = {
        -- add your localization for the terms in Portuguese
        -- f.e. you can add `["Fish"] = "Peixe",` to transform `Fish` into `Peixe`
        -- you can delete the subtable for this language if you want
        
    },
    ["ru"] = {
        -- add your localization for the terms in Russian
        -- f.e. you can add `["Fish"] = "Рыба",` to transform `Fish` into `Рыба`
        -- you can delete the subtable for this language if you want
        
    },
    ["uk"] = {
        -- add your localization for the terms in Ukrainian
        -- f.e. you can add `["Fish"] = "Риба",` to transform `Fish` into `Риба`
        -- you can delete the subtable for this language if you want
        
    },
    ["zh"] = {
        -- add your localization for the terms in Chinese
        -- f.e. you can add `["Fish"] = "鱼",` to transform `Fish` into `鱼`
        -- you can delete the subtable for this language if you want
        
    },
}

After pasting this text, you can start filling in translations of the terms. Use Module:Tr/db-Coralite as a reference.

You do not have to add all languages. For example, if you want to add only Ukrainian localization, then you can use this placeholder:

return {
    ["uk"] = {
        -- add your localization for the terms in Ukrainian
        -- f.e. you can add `["Fish"] = "Риба",` to transform `Fish` into `Риба`
        -- you can delete the subtable for this language if you want
        
    },
}

You can read more about translation databases here.

Creating pages

All translated pages must be subpages of their respective English versions. This subpage has the same address as the English page but with /<language code> at the end. For example, if the page called My Mod/Prismatic Sword has a Ukrainian translation, it must have this name: My Mod/Prismatic Sword/uk.

First, it is recommended to create the main page of the wiki. You can simply copy the main page in English and translate some elements. You can use {{DISPLAYTITLE:}} magic word to change the title from My Mod/uk to My Mod or even the localized name of the mod.

This naming convention is applied to all pages of the mod, including categories and templates (it is recommended to use {{l10n}} for localization rather than separate templates for different languages, but the content of navigational templates is stored on separate pages for different languages). The only exception to this rule is files: most of the time the same files are used on all localized pages, but in case you need different files for different languages, use this naming convention: File:<Name of English file without mod name> (<Language code>) (<Mod name>).<ext> (example: English file: File:Prismatic Sword (My Mod).png; Ukrainian file: File:Prismatic Sword (uk) (My Mod).png).

Do not forget to add {{Language links}} at the bottom of both the English and localized pages. This template links all localizations of the page.

Using templates

As was said before, many templates on this wiki support i18n. It means that they are adapted to be used in multiple languages. The most noticeable templates are related to creating links:

  • {{item}} — this template translates the text of the link based on the data from the language database.
  • {{modlink}} or {{+}} — this template translates the text of the link based on the data from the language database.
  • {{tgc}} — this template adds a link to the non-English vanilla Terraria Wiki based on the language.

The table below assumes that {{lang}} is set to zh and {{modname|get}} is Coralite. Example of correct and incorrect usages of these templates:

Incorrect usage
Correct usage
Code Result Notes Code Result Notes
{{item}}
{{item|#雪花护符|image=Snowflake Charm (Coralite).png}} Coralite/雪花护符雪花护符 It creates a link to Coralite/雪花护符/zh {{item|#Snowflake Charm}} Coralite/Snowflake Charm雪花护符 The text of the link loads from Module:Tr/db-Coralite
{{item|#雪花护符|lang=en|image=Snowflake Charm (Coralite).png}} Coralite/雪花护符雪花护符 It creates a link to Coralite/雪花护符. It is incorrect because all translated pages must be subpages of their respective English page.
{{item|#Snowflake Charm/zh|lang=en|image=Snowflake Charm (Coralite).png}} Coralite/Snowflake Charm/zhSnowflake Charm/zh This usage links to the correct page, however the text of the link is not translated.
{{item|史莱姆王|image=King Slime.png|maxsize=48px}} 史莱姆王史莱姆王 {{item|King Slime|maxsize=48px}} King Slime史莱姆王 Links to vanilla items also must be in the following format: <Term in English>/<Language code>.
{{item|史莱姆王|lang=en|image=King Slime.png|maxsize=48px}} 史莱姆王史莱姆王
{{modname}} or {{+}}
{{+|雪花护符}} 雪花护符 It creates a link to Coralite/雪花护符/zh {{+|Snowflake Charm}} 雪花护符 The text of the link loads from Module:Tr/db-Coralite
{{+|雪花护符|lang=en}} 雪花护符 It creates a link to Coralite/雪花护符
{{tgc}}
{{tgc|Hardmode}} Hardmode This template does not translate links. {{tgc|困难模式}} 困难模式

There are some other cases where you do not need to transalte terms by yourself. For example, parameter type in Template:Item infobox must be the same as in English version. To translate the text of the link change localization database of your mod or language or add localization key |type:<type in English>=<type in your language> in Template:Item infobox/l10n (you can read more about this in the code of this template or below).

Localizing regular templates

The process of localizing templates and modules on the Terraria Mods Wiki is the same as on the Terraria Wiki. You can read more about it here: tgc:Help:I18n & l10n for templates § Localization.

Localizing mod templates

Due to the principles of work of {{l10n}} template, it is not possible to create /l10n subpage for a mod template. If you want to add localization for mod template, use the following snippet:

<!--

// register l10n
-->{{#if:{{#var:<l10n_key>:l10n:data}}||{{#vardefine:<l10n_key>:l10n:data|y}}<!-- load once per paget

-->{{l10n/register|<l10n_key>|en<!--
-->|<key1>=<value1><!--
-->|<key2>=<value2><!--
-->}}<!--

-->}}<!--

// template's code

-->

Translation databases

  • Localization subtemplates and submodules