Convert Text failure...

JFD

Kathigitarkh
Joined
Oct 19, 2010
Messages
9,132
Location
The Kingdom of New Zealand
I was hoping to make things easy, and use an existing Popup box to display some information. The problem is this information is dynamic and whilst the text key shows correctly, it fails to localise. Here's my code, to make things clearer:

Code:
function populateInfo()
    local activePlayer = Players[Game.GetActivePlayer()]
    local popupInfo = {Data1 = 800, Type = ButtonPopupTypes.BUTTONPOPUP_TEXT, }
    for row in GameInfo.Civilization_JFD_CulturalObjectives() do
         local civilizationType = row.CivilizationType
         if activePlayer:GetCivilizationType() == GameInfoTypes[civilizationType] then
	    local bonuses = row.Bonuses
            local penalties = row.Penalties
            local briefing = bonuses .. "[NEWLINE]" .. penalties
            popupInfo.Text = Locale.ConvertTextKey(briefing)
	    UI.AddPopup(popupInfo)
	end
      end
end

So is it just a matter of that the popup doesn't have the functionality to support this, or am I missing something?
 
Just at a glance, briefing doesn't look anything like a Text Key. Locale.ConvertTextKey(briefing) will localize briefing if it is a valid text key (that exists). Otherwise, it will just give you briefing string without any conversion.
 
I suppose it just won't convert two separate strings at the same time. In any case, I've just built my own UI for what I need, which is probably the more reliable thing to do anyway. Thanks for the response.
 
Why didn't you just convert the bonuses and penalties textkeys and THEN concatenate them... or just do it inline?

Code:
local briefing = Locale.ConvertTextKey(bonuses) .. "[NEWLINE]" .. Locale.ConvertTextKey(penalties)
 
That's because row.Bonuses and row.Penalties are not valid text keys that actually exist.

(Try to prove me wrong and you will find your problem.)
 
Back
Top Bottom