Module:Langue/doc
This is the documentation page for Module:Langue
Module purpose
[jlado]Module:Langue is used to detect, display, and link language variants (for example, Gun (Bénin) and Gun (Gungbe)) in multilingual templates across pages. It helps templates automatically adjust their text or links based on the detected language context — for example, when an article is written in Gungbe versus when it is written in another language.
This module is especially useful for multilingual content and localization of articles, where it ensures consistency and proper language labeling.
Functions
[jlado]The module provides several functions that can be called from templates using `Script error: The function "functionName" does not exist.`.
1. isBJ
[jlado]- Usage:**
…
- Description:**
Checks if the detected language is Gun (Bénin) (based on predefined logic such as site language or page name pattern). It returns the content of the parameter:
- `yes` – if the detected language is Gun (Bénin)
- `no` – if it is not
- Example:**
```wikitext Gun (Gungbe)
Output (depending on language): → Gun (Bénin) or Gun (Gungbe)
=== 2. p2link === Usage:
Gun (Bénin)
Description: Creates a clickable tab or link to switch between two language variants of the same page. The override parameter can be used to specify a target page manually.
Example:
This would create a clickable link for the alternate language tab.
=== 3. alternateLink === Usage:
Script error: The function "alternateLink" does not exist.
Description: Used internally by p2link to determine or generate the alternate page name for the language variant.
Example:
Script error: The function "alternateLink" does not exist.
This returns the appropriate alternate page name or link depending on the language.
=== 4. lang === Usage:
Gungbe
Description: Returns the code or name of the currently detected language. It can be used to show which language version of the article is being viewed.
Example:
|
Cet article est écrit en Gun (Gungbe) |
Output: → Cet article est écrit en Gun (Gungbe) → This article is written in Gun (Gungbe)
Example template usage
[jlado]Template:B
[jlado]This template uses Module:Langue to display two horizontally aligned buttons:
Active tab: Shows the detected language (Gun (Bénin) or Gun (Gungbe))
Clickable tab: Provides a link to the other language version
Underneath, it also displays the message:
> Cet article est écrit en Gun (Gungbe) This article is written in Gun (Gungbe)
See also
[jlado]Template:B – the main visual tab template that uses this module
Module:Langue/testcases – optional subpage for module testing
Help:Lua – for learning more about Lua scripting on MediaWiki
Maintenance
[jlado]Author: User:Medaho
Last updated: 2025-10-09
```