[Solved] LocalizedString with Parameters

More
3 years 11 months ago - 3 years 11 months ago #4111 by impbox
Hi, Is it possible to pass parameters when translating a LocalizedString?

eg. something equivalent to:

```
LocalizedString foo = "Go To {[Destination]}";
string bar = foo.ToString(("Destination", "test"));
```
Last edit: 3 years 11 months ago by impbox.

Please Log in or Create an account to join the conversation.

More
3 years 11 months ago #4112 by Frank
Hi,
There is no overload ToString method, but you can apply the parameters by doing:
LocalizedString foo = "Go To {[Destination]}";
string bar = foo;
LocalizationManager.ApplyLocalizationParams(ref bar, new Dictionary<string, object>{{"Destination", "test"}});

or if you only need to change 1 parameter:
LocalizationManager.ApplyLocalizationParams(ref translation, (s)=>"test");

That's the way if you are setting the parameter's value in the function.
But if the parameters are global, then just uncheck the DontLocalizeParameters in the LocalizedString inspector and it will try finding the parameters in the GlobalParameters without having you to call ApplyLocalizationParams.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
3 years 11 months ago #4113 by impbox
Awesome! Thanks very much Frank!

Please Log in or Create an account to join the conversation.

Time to create page: 0.214 seconds
Template by JoomlaShine