Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Is it possible to add termes via a scripts.

Is it possible to add termes via a scripts. 9 months 1 week ago #2797

So I would just like to know how to simply use the (+) add key function thats in the inspector of I2language.prefab but in a script
The administrator has disabled public write access.

Is it possible to add termes via a scripts. 9 months 1 week ago #2799

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 1149
  • Thank you received: 248
  • Karma: 75
You can use the following:
    var termData = LocalizationManager.Sources[0].AddTerm("My New Term");
    termData.Languages[0] = "This is an Example";
    termData.Languages[1] = "Esto es un ejemplo";

     // after adding al the terms
     LocalizationManager.Sources[0].UpdateDictionary();

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
The administrator has disabled public write access.
The following user(s) said Thank You: CavernHead

Is it possible to add termes via a scripts. 9 months 1 week ago #2800

okey that perfect that will spare me alote of time. thanks alot
The administrator has disabled public write access.

Is it possible to add termes via a scripts. 9 months 1 week ago #2802

So i did what you told a manged to add the terms but when it commes to removing them all. I manage but there is an error along the way im not sure im using the right methodes this is what i do.
public static void RemoveAllTerms()
{
while(LocalizationManager.Sources[0].mTerms.Count>0)
{
LocalizationManager.Sources[0].RemoveTerm(LocalizationManager.Sources[0].mTerms[0].Term) ;
}
LocalizationManager.Sources[0].UpdateDictionary();
}
The administrator has disabled public write access.

Is it possible to add termes via a scripts. 9 months 1 week ago #2803

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 1149
  • Thank you received: 248
  • Karma: 75
Can you also post whats the error you are getting. That may give me a better hint.

Also, there is an easy to way to accomplish the Remove All:
var source = LocalizationManager.Sources[0];
source.mTerms.Clear();
source.mDictionary.Clear();
#if UNITY_EDITOR
	UnityEditor.EditorUtility.SetDirty (source);
#endif
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
The administrator has disabled public write access.
The following user(s) said Thank You: CavernHead

Is it possible to add termes via a scripts. 9 months 1 week ago #2804

okey I just did what you suggested but i still get the error. Also now I have another problem its that the terms arn't added in the order i added them. Basicly im using a methode to add each terme from my script. Like this I can transfere my 500 termes from my script to the spread sheet. They seem to re order them selfs alphabetlcly from what i can tell. but the order is important so it doesn't becom a messy in the spreadsheet. I added a pic with the error. Also Im sorry if im not using your scripts in the conventional way : -) .
Attachments:
Last Edit: 9 months 1 week ago by CavernHead.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.159 seconds
Template by JoomlaShine