Total-RP / Total-RP-3

The best roleplaying add-on for World of Warcraft.
http://curse.totalrp.com
Apache License 2.0
33 stars 19 forks source link

Export localization strings globally #913

Closed Meorawr closed 1 week ago

Meorawr commented 1 week ago

Currently using localization strings in XML is a massive pain in the rear with our approach being rather inconsistent. We've got a mixture of code that either sets strings in OnLoad or OnShow handlers, and some code using the "LocalizeTextOnAddOnLoad" genericism added with the icon browser rework.

There's two reasons that we've got such varied approaches;

  1. Translation strings aren't available until ADDON_LOADED thanks to our addon locale setting, that I've railed against as the worst idea since time immemorial.

  2. The various methods for accessing text strings in XML (typically via the text="" attribute) don't support nested lookups, only globals.

The first problem can be mitigated somewhat by moving all of our UI creation tasks until the point that they're needed - which is something that's very slowly happening in the background anyway.

The second problem isn't likely to be solved by Blizzard for us any time soon, so would be entirely on us to resolve.

As such, this commit puts forth the idea of just spilling our guts out all over _G and exporting all of our translation strings with a "TRP3L" prefix. These can be referenced directly in text attributes in XML for all templates and frames that are known to be loaded after we've figured out which locale needs using.

Longer-term, we may want to consider killing the loc table and using the globals consistently everywhere - but stopping short of that now as that would be a cataclysmic change. Would rather evaluate how usable this global approach ends up being first.