Problem using API with plural translations
- cygnusprojects
- Topic Author
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
5 years 1 week ago #4012
by cygnusprojects
Problem using API with plural translations was created by cygnusprojects
Hi there,
I found the following code on this forum to translate my plural term through API calls:and thisI applied this to my code like this:or even this:but all do end in the same error message:Looking at the code using that stacktrace this seems to be the issue:
Any tip/hints on how to get this working?
I'm on Unity 2019.2.13 and I2 localization 2.8.13 f2 according to the readme.
I found the following code on this forum to translate my plural term through API calls:
var dict = new Dictionary<string, int>();
dict["MATCHES_LEFT"] = 5;
string translation = LocalizationManager.GetTranslation( "TERM_FIGHTS" )
LocalizationManager.ApplyParameters(ref translation, dict);
string translation = LocalizationManager.GetTranslation( "TERM_FIGHTS" )
LocalizationManager.ApplyParameters(ref translation, (p)=>{ return p=="MATCHES_LEFT" ? 5 : null; });
string translation = LocalizationManager.GetTranslation(".STARS. needed to unlock");
LocalizationManager.ApplyLocalizationParams(ref translation, (p) => { return p == "NR" ? 5 : 0; });
var dict = new Dictionary<string, object>();
dict["NR"] = Contract.StarsNeed2Unlock;
string translation = LocalizationManager.GetTranslation(".STARS. needed to unlock");
LocalizationManager.ApplyLocalizationParams(ref translation, parameters:dict);
InvalidCastException: Specified cast is not valid.
I2.Loc.LocalizationManager.ApplyLocalizationParams (System.String& translation, I2.Loc.LocalizationManager+_GetParam getParam, System.Boolean allowLocalizedParameters) (at Assets/I2/Localization/Scripts/Manager/LocalizationManager_Parameters.cs:84)
I2.Loc.LocalizationManager.ApplyLocalizationParams (System.String& translation, System.Collections.Generic.Dictionary`2[TKey,TValue] parameters, System.Boolean allowLocalizedParameters) (at Assets/I2/Localization/Scripts/Manager/LocalizationManager_Parameters.cs:46)
ContractUI.OnLocalize () (at Assets/Scripts/UI/ContractUI.cs:67)
var result = (string)getParam(param); where param has the value NR
Any tip/hints on how to get this working?
I'm on Unity 2019.2.13 and I2 localization 2.8.13 f2 according to the readme.
Please Log in or Create an account to join the conversation.
Time to create page: 0.149 seconds