Module:Tr/doc

From Infernum Mod Wiki
Jump to navigation Jump to search

This is the documentation page for Module:Tr

This module facilitates translation of game terms and wiki page names between English and other languages. It provides the functionality of the {{tr}} template and can also be used from within other modules.

The module can be called from wikitext with the following functions:

  • {{#invoke:Tr| loadData | <language> }}
This function is generally only intended for {{tr}}. It loads the translation databases for the given language (Module:Tr/db-en, Module:Tr/db-ru, etc. and Module:Tr/vanilla-en, Module:Tr/vanilla-ru, ) and makes all of its contents available as variables. The variables have the prefix _tr:<lang>:mod: or _tr:<lang>:vanilla:, e.g. {{#var:_tr:it:vanilla:Fish}} for the Italian (it) translation of "Fish". The page name translations have the prefix _tr:<lang>:vanilla-link: or _tr:<lang>:mod-link:, e.g. {{#var:_tr:it:vanilla-link:Fish}} for the Italian page for "Fish".
  • {{#invoke:Tr| loadData2e | <language> }}
This function is generally only intended for {{tr2e}}. It loads the reversed translation database for the given language (translation of terms from the language to English) and makes all of its contents available as variables. The variables have the prefix _tr2e:<lang>:vanilla: or _tr2e:<lang>:mod:, e.g. {{#var:_tr2e:it:vanilla:Pesce}} for the English translation of the Italian (it) term "Pesce".
  • {{#invoke:Tr| purge | <language> }}
Purges the cache of the translation database for the given language. This is necessary after making a change to the database. See Module:Tr/loaddata for more details.

The module can be called from another module with the following functions:

  • require('Module:Tr').translate('<englishTerm>', '<language>')
Returns the translation of the given term to the given language. This is the Lua equivalent of {{tr|<englishTerm>|lang=<language>}}.
  • require('Module:Tr').translate('<englishTerm>', '<language>', true)
Returns the translation of the given term to the given language. This is the Lua equivalent of {{tr|<englishTerm>|lang=<language>|vanilla=y}}.
  • require('Module:Tr').translateLink('<englishLink>', '<language>')
Returns the page name translation of the given term to the given language. This is the Lua equivalent of {{tr|<englishLink>|lang=<language>|link=y}}.
  • require('Module:Tr').translateLink('<englishLink>', '<language>', true)
Returns the page name translation of the given term to the given language. This is the Lua equivalent of {{tr|<englishLink>|lang=<language>|link=y|vanilla=y}}.
  • require('Module:Tr').translate2e('<term>', '<language>')
Returns the translation of the given term from the given language to English. This is the Lua equivalent of {{tr2e|<term>|lang=<language>}}.
  • require('Module:Tr').translate2e('<term>', '<language>', true)
Returns the translation of the given term from the given language to English. This is the Lua equivalent of {{tr2e|<term>|lang=<language>|vanilla=y}}.
  • require('Module:Tr').purge('<language>')
Purges the cache of the translation database for the given language. This is necessary after making a change to the database. See Module:Tr/loaddata for more details.