[Solved] LocalizedString with Parameters

More
4 months 2 weeks ago - 4 months 2 weeks 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: 4 months 2 weeks ago by impbox.

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

More
4 months 2 weeks 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
4 months 2 weeks 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.181 seconds
Template by JoomlaShine