Topic: Add-On Internationalization

OIPUN
Avatar
Topic Opener
Joined: 2020-11-17, 09:34 UTC+1.0
Posts: 337
Ranking
Tribe Member
Location: Czech
Posted at: 2026-01-21, 08:25 UTC+1.0

My add-on "Field Army" is not translated fully. I tried to investigate on my own, but nothing really works. I tried to place the line "addon = "field_army.wad"" everywhere but without any result. The problematic strings are locals wc_desc and wc_desc1. Both strings are in .po file but the translations are not uploaded. What should I do to make it work?


Attachment: image/jpeg
shot0029.jpg

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07 UTC+1.0
Posts: 2241
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2026-01-21, 11:22 UTC+1.0

Only name needs to pass the unlocalized string in the return table, all other strings including description should be already translated in Lua. Delete wc_desc_i18n and add the translation markup to wc_desc instead, then it works.


Top Quote
OIPUN
Avatar
Topic Opener
Joined: 2020-11-17, 09:34 UTC+1.0
Posts: 337
Ranking
Tribe Member
Location: Czech
Posted at: 2026-01-21, 11:49 UTC+1.0

The suggested solution corrects the wc_desc, but wc_desc1 still doesn't work.


Attachment: image/png
shot0029.png

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07 UTC+1.0
Posts: 2241
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2026-01-21, 11:58 UTC+1.0

Since wc_desc1 is a local variable inside a function, you need to surround it with a pair of push_textdomain and pop_textdomain calls like any other translation call.

Also, ngettext returns an already translated string so don't wrap it in another layer of _() translation markup.


Top Quote
OIPUN
Avatar
Topic Opener
Joined: 2020-11-17, 09:34 UTC+1.0
Posts: 337
Ranking
Tribe Member
Location: Czech
Posted at: 2026-01-21, 12:07 UTC+1.0

Thank you.


Top Quote