How to avoid automatic deletion of spaces at the edges of the line for TXT_KEY_?

saigon1983

Chieftain
Joined
Jul 5, 2017
Messages
45
Location
Russia, Saint-Petersburg
Good day to all! I have a problem converting TXT_KEY strings in lua files. Let's say I have this line of code:

sReconHeader = Locale.Lookup("TXT_KEY_CO_STAT_TEXT_12") .. sTargetCityName .. Locale.Lookup("TXT_KEY_CO_STAT_TEXT_13") .. sSpyName

The following tags are defined in the XML file:

<Row Tag="TXT_KEY_CO_STAT_TEXT_12">
<Text>Отчёт об операции в городе </Text>
</Row>
<Row Tag="TXT_KEY_CO_STAT_TEXT_13">
<Text>. Ответственный агент: </Text>
</Row>

Я хочу получить подобное сообщение на выходе:

"Отчёт об операции в городе SomeCity. Ответственный агент: SomeAgent"

And in fact, all the spaces at the end of these tags are automatically deleted, and I get:

"Отчёт об операции в городеSomeCity. Ответственный агент:SomeAgent"

Is there a way to avoid this? Maybe you need to add some special character at the end of the tag? I use Russian, if anything (Language_ru_RU).

And yes, this writing method also removes spaces:

sReconHeader = "{TXT_KEY_CO_STAT_TEXT_12}" .. sTargetCityName .. "{TXT_KEY_CO_STAT_TEXT_13}" .. sSpyName
 
Use Locale.ConvertTextKey() and "placeholders"

Code:
<Row Tag="TXT_KEY_CO_STAT_TEXT_12">
<Text>Отчёт об операции в городе {@1_City}. Ответственный агент: {@2_Spy}</Text>
</Row>

sReconHeader = Locale.ConvertTextKey("TXT_KEY_CO_STAT_TEXT_12", sTargetCityName, sSpyName)


The placeholders don't have to be in order, so you could do

Code:
<Row Tag="TXT_KEY_CO_STAT_TEXT_12">
<Text>Отчёт об операции в городе {@2_City}. Ответственный агент: {@1_Spy}</Text>
</Row>

sReconHeader = Locale.ConvertTextKey("TXT_KEY_CO_STAT_TEXT_12", sSpyName, sTargetCityName)
 
And the fact that no one answered my question about the difference (first part post #5) should tell you all you need to know ... ie that the community doesn't know
 
Back
Top Bottom