Auto create terms from a script with strings

More
3 years 1 month ago #1741 by rak2410
Hi,

I just purchased and installed your plugin.
Still getting a hang of it.

But what I want to do is - Auto create terms from a script file consisting of const static strings.
I have created these strings and I refer them from other scripts to access the string value.

So is this possible? Because it would save me a lot of time.

Thanks,
Rakshith,
RedForce Games

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

More
3 years 1 month ago - 3 years 1 month ago #1747 by Frank
Hi,
Sorry, I thought I already answered you, but It seems that I totally forgot to do that. I'm really sorry about that.

If you already have a way to get the strings you need with reflection or by parsing the cs files, its easy to add the terms dynamically, just place the following code in one editor script:
Dictionary<string,string> translatedTerms = ..... get your terms with reflection or by parsing the cs file ...

var I2Languages = I2.Loc.LocalizationManager.Sources[0];
foreach (var kvp in translatedTerms)
{
     var term = kvp.Key;
     var translation = kvp.Value;
     var termData = I2Languages.AddTerm(term, I2.Loc.LanguageSource.eTermType.Text, false);
     termData.Languages[0] = translation;
}

UnityEditor.EditorUtility.SetDirty(I2Languages);
UnityEditor.AssetDatabase.SaveAssets();

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
Last edit: 3 years 1 month ago by Frank.

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

More
3 years 1 month ago #1748 by rak2410
No problem :)

I think this is exactly what I was looking for.
Ill get back to you for more.

Thanks!
Rakshith

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

Time to create page: 0.128 seconds
Template by JoomlaShine