Draft:Template:Article: Difference between revisions
From AbhiprayaVedi
No edit summary |
No edit summary |
||
| Line 106: | Line 106: | ||
</div> | </div> | ||
<!-- | <!-- ================================================================ | ||
CATEGORIES | |||
NOTE on Malayalam DEFAULTSORT bug: | |||
MediaWiki's DEFAULTSORT cannot sort Malayalam Unicode text correctly — | |||
it only reads the first character, so categories show truncated names. | |||
FIX: We use the "sort key" parameter directly on each [[Category:]] link. | |||
The sort key is the DisplayTitle passed explicitly, which makes the full | |||
title appear correctly in the category listing. | |||
================================================================ --> | |||
[[Category:{{{Category|}}}]] | [[Category:{{{Category|}}}|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
[[Category:Articles]] | [[Category:Articles|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
{{#if:{{{Language|}}}|[[Category:{{{Language}}} articles]]|}} | {{#if:{{{Language|}}}|[[Category:{{{Language}}} articles|{{{DisplayTitle|{{{Title|}}}}}}]]|}} | ||
<!-- English | <!-- English-to-Malayalam parallel categories --> | ||
{{#switch:{{{Category|}}} | {{#switch:{{{Category|}}} | ||
|Politics=[[Category:രാഷ്ട്രീയം]] | |Politics=[[Category:രാഷ്ട്രീയം|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
|Society=[[Category:സമൂഹം]] | |Society=[[Category:സമൂഹം|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
|Culture=[[Category:സംസ്കാരം]] | |Culture=[[Category:സംസ്കാരം|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
|Science=[[Category:ശാസ്ത്രം]] | |Science=[[Category:ശാസ്ത്രം|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
|Literature=[[Category:സാഹിത്യം]] | |Literature=[[Category:സാഹിത്യം|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
|Cinema=[[Category:സിനിമ]] | |Cinema=[[Category:സിനിമ|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
|Environment=[[Category:പരിസ്ഥിതി]] | |Environment=[[Category:പരിസ്ഥിതി|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
|Economics=[[Category:സമ്പദ്വ്യവസ്ഥ]] | |Economics=[[Category:സമ്പദ്വ്യവസ്ഥ|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
|Opinion=[[Category:അഭിപ്രായം]] | |Opinion=[[Category:അഭിപ്രായം|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
}} | }} | ||
{{#if:{{{OriginalAuthor|}}}| | {{#if:{{{OriginalAuthor|}}}| | ||
[[Category:Articles by {{{OriginalAuthor|}}}]] | [[Category:Articles by {{{OriginalAuthor|}}}|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
[[Category:Translations]] | [[Category:Translations|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
[[Category:Translated by {{{Author|}}}]] | [[Category:Translated by {{{Author|}}}|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
| | | | ||
[[Category:Articles by {{{Author|}}}]] | [[Category:Articles by {{{Author|}}}|{{{DisplayTitle|{{{Title|}}}}}}]] | ||
}} | }} | ||
</includeonly> | </includeonly> | ||
<noinclude> | <noinclude> | ||
== | == Ver3: Fix for Category Display Names == | ||
The | === The Malayalam DEFAULTSORT Problem === | ||
`{{DEFAULTSORT:}}` does NOT work correctly with Malayalam (or any Unicode script that is non-Latin). MediaWiki's sort key mechanism only reads the first Unicode code point, which is why categories were showing only the first letter/character of the title. | |||
- Page name | |||
- | === The Fix === | ||
- Category shows | |||
Instead of using `DEFAULTSORT`, we now pass the sort key '''directly on each category link''' using the pipe syntax: | |||
<pre> | |||
[[Category:Articles|{{{DisplayTitle|{{{Title|}}}}}}]] | |||
</pre> | |||
This tells MediaWiki: "place this page in the category, and display it under the sort key equal to the DisplayTitle." Since MediaWiki renders the sort key as the display label in category listings, the full Malayalam title now appears correctly. | |||
=== How it works === | |||
{| class="wikitable" | |||
! Parameter !! Example value | |||
|- | |||
| Page name || <code>Something-In-The-Air</code> | |||
|- | |||
| DisplayTitle || <code>Something in the Air?</code> | |||
|- | |||
| Category shows || '''Something in the Air?''' ✓ | |||
|} | |||
For Malayalam: | For Malayalam: | ||
- Page name | {| class="wikitable" | ||
- | ! Parameter !! Example value | ||
- Category shows | |- | ||
| Page name || <code>Kerala-Climate-Change</code> | |||
|- | |||
| DisplayTitle || <code>കേരളത്തിലെ കാലാവസ്ഥാ വ്യതിയാനം</code> | |||
|- | |||
| Category shows || '''കേരളത്തിലെ കാലാവസ്ഥാ വ്യതിയാനം''' ✓ | |||
|} | |||
[[Category:Templates]] | [[Category:Templates]] | ||
</noinclude> | </noinclude> | ||
Revision as of 23:27, 4 April 2026
Ver3: Fix for Category Display Names
The Malayalam DEFAULTSORT Problem
`` does NOT work correctly with Malayalam (or any Unicode script that is non-Latin). MediaWiki's sort key mechanism only reads the first Unicode code point, which is why categories were showing only the first letter/character of the title.
The Fix
Instead of using `DEFAULTSORT`, we now pass the sort key directly on each category link using the pipe syntax:
[[Category:Articles|{{{DisplayTitle|{{{Title|}}}}}}]]
This tells MediaWiki: "place this page in the category, and display it under the sort key equal to the DisplayTitle." Since MediaWiki renders the sort key as the display label in category listings, the full Malayalam title now appears correctly.
How it works
| Parameter | Example value |
|---|---|
| Page name | Something-In-The-Air
|
| DisplayTitle | Something in the Air?
|
| Category shows | Something in the Air? ✓ |
For Malayalam:
| Parameter | Example value |
|---|---|
| Page name | Kerala-Climate-Change
|
| DisplayTitle | കേരളത്തിലെ കാലാവസ്ഥാ വ്യതിയാനം
|
| Category shows | കേരളത്തിലെ കാലാവസ്ഥാ വ്യതിയാനം ✓ |