Module:Msg/doc: Difference between revisions

Created page with "== Module:Msg == This Lua module provides a page-language-aware message lookup system for PokeHero wiki content. === Usage === Use the module in wikitext with: <pre> {{#invoke:Msg|msg|<category>|<last word>|lang=<language>}} </pre> * <code>category</code> – the category of messages: "types", "moves", "items", etc. * <code>last word</code> – the last part of the key. The module constructs the full key internally as: <code>pokehero-<category>-<last word></code>..."
 
 
Line 21: Line 21:


=== Fallback behavior ===
=== Fallback behavior ===
* If the category table does not exist → returns "<full key> (missing category table: <category>)".
* If the category table does not exist → returns <code><full key> (missing category table: <category>)</code>.
* If the key does not exist in the table → returns "<full key> (missing key in category <category>)".
* If the key does not exist in the table → returns <code><full key> (missing key in category <category>)</code>.
* If the translation for the page language does not exist → falls back to English; if English is missing, returns "<full key> (missing translations in category <category>)".
* If the translation for the page language does not exist → falls back to English; if English is missing, returns <code><full key> (missing translations in category <category>)</code>.


=== Extending ===
=== Extending ===
# Add new categories as separate submodules under `Module:Msg/` (plural names: `types`, `moves`, `items`).   
# Add new categories as separate submodules under <code>Module:Msg/</code> (plural names: <code>types</code>, <code>moves</code>, <code>items</code>).   
# Add keys following the format `pokehero-<category>-<last word>` in the respective submodule.   
# Add keys following the format <code>pokehero-<category>-<last word></code> in the respective submodule.   
# The main module automatically loads only the needed table for efficiency.
# The main module automatically loads only the needed table for efficiency.