Add a variable text, right behind a localized label

Hello all,

my aim is actually quite simple. I want to show the following information:

"Speed: X"

Where Speed should be a localized label and X is obviously a dynamic value.

Without localization I would have choosen this approach:

currentSpeed.text = "Speed: " + tmpSpeed.ToString("0");

But now I would like to add the localization here.
I have just installed the localization package and played around a bit.

My idea: Can I somehow use a reference to the key words I defined within the localization table?

Somehow like this:

currentSpeed.text = LocalizationKeyWord + tmpSpeed.ToString("0");

Or is there another meaningful approach?


You would make your localized string include a placeholder for the score value

English would look like

“Speed {0}”

you would then call localizedString.GetStringAsync(tmpSpeed.ToString(“0”));

If the speed is something thats global and not specific to one area then you could also use a global variable and store the speed using that. When the value changes any text that uses it will automatically update.

Thanks for your response.

It is probably simply too late, but I do not get how the connection between the localization tables and the localizedString is created…

That is my entry in the localization table:

And I have a script which updates a UI Text object:

txt_CurrentSpeed.text = "Speed: " + tmpSpeed.ToString("0")

Please give me another hint how I have to use the localizedString method here.

I was missing many central information in the official documentation in order to understand how I get all the loose ends together but fortunately I found a very useful tutorial which explains in detail many different options the Localization Package offers:

Maybe it helps others too.

Search for “Accessing Localized Strings from Scripts” if you had the same question like me, but there are also many other very useful options described.