[Solved] LocalizedString with Parameters
4 years 11 months ago - 4 years 11 months ago #4111
by impbox
[Solved] LocalizedString with Parameters was created 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"));
```
eg. something equivalent to:
```
LocalizedString foo = "Go To {[Destination]}";
string bar = foo.ToString(("Destination", "test"));
```
Last edit: 4 years 11 months ago by impbox.
Please Log in or Create an account to join the conversation.
4 years 11 months ago #4112
by Frank
Are you
Give I2L
5 stars!
Are you
Please lets us know how to improve it!
Replied by Frank on topic [Solved] LocalizedString with Parameters
Hi,
There is no overload ToString method, but you can apply the parameters by doing:
or if you only need to change 1 parameter:
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
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

Are you

To get the betas as soon as they are ready,
check this out
Please Log in or Create an account to join the conversation.
4 years 11 months ago #4113
by impbox
Replied by impbox on topic [Solved] LocalizedString with Parameters
Awesome! Thanks very much Frank!
Please Log in or Create an account to join the conversation.
Time to create page: 0.213 seconds