Thread Tools Display Modes
06-05-23, 06:12 PM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
How to spell out the result of plural UI escape sequences?

Hi, how can I get the interpreted version of a string including plural UI escape sequences?

Lua Code:
  1. local pluralString = "2 |4car:cars;"
  2. -- Do something with pluralString such that the result is what would be printed.
  3. local interpretedPluralString = ???
  4. assert(interpretedPluralString == "2 cars")
Thanks in advance!
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
06-06-23, 01:14 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,324
I believe that's in the C-code renderer for FontStrings, not anything we have access to.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
06-06-23, 02:35 PM   #3
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
I found a way.

Lua Code:
  1. local converterTooltip = CreateFrame("GameTooltip", "converterTooltip", nil, "GameTooltipTemplate")
  2. local function CovertLine(line)
  3.   converterTooltip:ClearLines()
  4.   converterTooltip:AddLine(line)
  5.   return _G[converterTooltip:GetName().."TextLeft1"]:GetText()
  6. end
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
06-06-23, 10:23 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,324
Doesn't it just spit back the UI escape code? You can expose it by doing something like :gsub("|","||"). What this does is escape the identifier so FontStrings will show the raw code.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-06-23 at 10:25 PM.
  Reply With Quote
06-07-23, 04:15 PM   #5
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Hm, it definitely works for the plural escape sequences. E.g. turning "2 |4car:cars;" into "2 cars".
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
06-10-23, 10:56 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,324
Unexpected behavior, but my own tests are confirming it as well. I simplified it down to running through a FontString, which would be where the processing happens, stripping the overhead of the Tooltip code.
Lua Code:
  1. local ProcessLocalizedString; do--  Package persistent FontString object into function prototype's scope
  2.     local ConverterFontString=UIParent:CreateFontString(nil,"BACKGROUND","GameFontNormal");
  3.     function ProcessLocalizedString(text)
  4.         ConverterFontString:SetText(text);
  5.         return ConverterFontString:GetText();
  6.     end
  7. end
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
06-11-23, 02:38 PM   #7
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Nice, this is even better! Thank you!
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to spell out the result of plural UI escape sequences?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off