Problems accessing Terms by script

More
7 years 11 months ago - 7 years 11 months ago #1420 by Ensutee
Hello!
I am working for a small indie company and we recently bought your i2 localization plugin. The localization using the Localize scripts works perfectly, however, I am having some trouble accessing the language terms by script. From what I can read within the documentation it should simply be Localization.Get("Key") - with the key being the name of the Term (I would presume).

Even though I have set up a series of terms within the I2/Resources/I2Languages.prefab whenever I try to use Localization.Get() it just returns the name of the key with a warning that the key could not be found.

I attempted going into the code and outputting all values of both mOldDictionary (which had a length of 0) and mDictionary, which seemed to contain information from the nGUI example(?). I have attached an image of 3 things:
top left: the console, showing the output of the mDicitonary with each line being the key followed by all it's string[] values. Below the selected debug line is the key Paragraph with a text describing an nGUI example, and below that the warning when I try to get the value assiciated with "Day".
right: the inspector showing the "Language Source" script. In here you can see the Term "Day" that I am attempting to get and it's value "Day OLOLOLO" used as a test.
bottom left: the project hierarchy showing the selection of the I2Languages prefab.

Currently the database is set up to sync with a google spreadsheet and that connection works fine. I have also attempted to export the database to a Localization.csv file in resources, but that didn't help either. I have also not created any other instances of the Language Source script, so the one in the project hierarchy is the only one.

Can you point me in the right direction? Because I am running out of ideas.
Attachments:
Last edit: 7 years 11 months ago by Ensutee. Reason: Realized that the image quality was shit, so uploaded some smaller images

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

More
7 years 11 months ago #1422 by Frank
Hi,

Localize.Get(key) is an API from NGUI, not from I2 Localization. That's why you are getting results from their built-in localization examples.

To access the Script from code, you should use
string text = I2.Loc.ScriptLocalization.Get("MyKEY");

Here are more details:
inter-illusion.com/assets/I2Localization...alizationManual.html

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
7 years 11 months ago - 7 years 11 months ago #1435 by Ensutee
Ahaaa! see that would explain my confusion! F'ing nGUI -.-
Going off of your post I managed to pull out a term \o/

However, I had some issues with the manual that I would like to point out.
1) using ScriptLocalization.Get() I have to write the full path of my Term? e.g. "GeneralTerms/Day". It seems to be the case, and as such, it would have been nice with an example showing this, instead of the one just saying ScriptLocalization.Get("MyKEY").

2) Having a written example of how to use the compile-time variables would have been nice. Having toyed around with it now for a bit it seems super useful and is probably going to be the primary way I'll be using the plugin. However; one or two lines in the "Commonly used Script APIs" part of the manual would have been super helpful.
I am aware that there is an example on the I2 Locallization page, however it is a fairly ambiguous example with two different (fairly generic terms) being called. I believe it would more clearly highlight both of my points by being something akin to
ScriptLocalization.Get("YourCategory/YourTerm");
ScriptLocalization.YourCategory.YourTerm;

But I digress. Thanks a lot for your help! :) Your plugin seems superuseful and now that I've cracked the code so to speak, I imagine it is going to be quite a pleasure to work with.

P.S.
In case you were interested in which game we're using it for, it is for our up-and-comming game Tales From The Void
store.steampowered.com/app/419590
Last edit: 7 years 11 months ago by Ensutee. Reason: Correcting myself where I'm just plain wronge ^^

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

More
7 years 11 months ago #1440 by Frank
Hi,
Thanks a lot for those suggestions.
I just updated the documentation to better explain the Script Tool and how to access terms with categories!

inter-illusion.com/assets/I2Localization...yusedScriptAPIs.html
inter-illusion.com/assets/I2Localization...riptsforsaverac.html

BTW, I added a link to your game in the Showcase thread , I hope that helps you drive a few users into seeing your store page :-)

Thanks!
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
7 years 11 months ago #1457 by Ensutee
Having localized most of our game now I must admit, that the plugin works much better than anticipated. It has been an absolute pleasure to work with :)
Furthermore your response time on this forum is admirably and I appreciate that immensely (especially given that we're rapidly closing in on our deadline ^^).

One thing though to the changes you made to the manual; the categories of the compile time variables are separated by '_' not '.'
i.e.
I2.Loc.ScriptLocalization.FirstCatergory_SecondCategory.Term
instead of
I2.Loc.ScriptLocalization.FirstCategory.SecondCategory.Term

Oh, and thanks for posting our game, every little bit helps :)

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

More
7 years 6 months ago #1766 by CuiCuiStudios
Hi!

I´m trying to do the same thing for a text on my project. Using the Scriptlocalizaton.Get() or The scripting term method, I get a null value from my term. But if I use the term on the Localize Script it works.

I´m trying to access the text on spreadsheet to change text on the "TextFX" plugin. I don´t have any category on my terms but I tried the Ensutee solution of "GeneralTerms/Key" and "Default/Key" and "Terms/Key". All returns me a null value.

I´m using 2.7.7 f6. For everything else, this plugin is the best purchase we ever made. :)

Thanks!

Gabriel.

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

Time to create page: 0.192 seconds
Template by JoomlaShine