Before I buy - will I be able to localize lists?

More
8 years 4 months ago - 8 years 4 months ago #1678 by Sarr
Yes, but not sure, I guess I mean something even more simple I guess.
I mean, there's no list. We forget about lists. We just have content of the Text component in Unity Editor stored into variable: player_inventory.
The content would be terms divided be commas: _armor, _shield, _sword, etc. Depends on what is there currently.
So it's just text component already populated with some terms.

Now I just need to perform translation operation of that single Text component - nothing else. So I2 Localization would just check whole content of this text component in search of those terms and if found, translate them.

I would maybe call some function to let your asset know whenver content of the component changed.

Is it possible this way? Or is it done automatically? Or maybe that's not possible and I need to do it like you explained?
Sorry for taking your time :/. But you've assured me to buy this asset, so thank you.
Last edit: 8 years 4 months ago by Sarr.

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

More
8 years 4 months ago #1679 by Frank

Is it possible this way?


Unless I misunderstood you, its the 3 lines I just gave you:

itemText is the Text object that has the list:
var arrayItems = itemsText.text.Split(", ");    // divides the text into each element

var translatedTerms = arrayItems.Select(x=>ScriptLocalization.Get(x)).ToArray();    // translate each of those elements

itemText.text = string.Join(", ", translatedTerms);   // for English, it returns "Sword, Chain mail, Shield"

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 following user(s) said Thank You: Sarr

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

More
8 years 4 months ago - 8 years 4 months ago #1680 by Sarr

Frank wrote:

Is it possible this way?


Unless I misunderstood you, its the 3 lines I just gave you:

itemText is the Text object that has the list:
var arrayItems = itemsText.text.Split(", ");    // divides the text into each element

var translatedTerms = arrayItems.Select(x=>ScriptLocalization.Get(x)).ToArray();    // translate each of those elements

itemText.text = string.Join(", ", translatedTerms);   // for English, it returns "Sword, Chain mail, Shield"

Ok, so that arrayItems is needed just to be able to find terms in this Text character_inventory when they are divided by comma, right?

That's ok I think, but I am a bit surprised there's no solution for Unity that just finds terms on it's own whenever content of text component changes. This should be a new feature I guess.
People would just run one function, and it would search through content of some text component and swap only words that were translated in your asset (in google spreadsheet, for example) :). Or maybe even you could add some script for people to insert, so it would detect any changes in text component of the object to which it was attached and refresh to translate new text.

Anyway, buying now, so thanks again - but I'll ask for such feature to make our work faster.
Last edit: 8 years 4 months ago by Sarr.

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

More
8 years 4 months ago - 8 years 4 months ago #1681 by Frank
Yes,

If you are using that approach for several lists, you could make it function:
public string ParseAndLocalize( string text )
{
      var arrayItems = text.text.Split(", ");    // divides the text into each element
      var translatedTerms = arrayItems.Select(x=>ScriptLocalization.Get(x)).ToArray();    // translate each of those elements
      return string.Join(", ", translatedTerms);   // for English, it returns "Sword, Chain mail, Shield"
}


then in your code:

textObject.text = ParseAndLocalize( textObject.text );


Nonetheless, I just separated the code in 3 lines so it could be easier to understand, but it could be just one :-)

textObject.text = string.Join(", ", textObject.text.Split(", ").Select(x=>ScriptLocalization.Get(x)));

Given that you could have the list in many formats (separated by commas, dashes, newlines, etc), the plugin doesn't parse the text automatically for you. But the takeaway from this is that I2L has simple APIs that could be easily leveraged to localize any format you may have in your game.

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: 8 years 4 months ago by Frank.
The following user(s) said Thank You: Sarr

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

More
8 years 4 months ago #1682 by Sarr
That's ok, maybe I'm just too fresh into c# to understand why you can't just add some function to search through whole content of some component no matter what other symbols are there :).
After I read you perform such rocket-science :D things like translating chat messages, I thought it would be absolutely easy to do :). But yes, I guess the performance of such operation would be much slower than what you showed me - so maybe that's the issue here. Thank you again Frank, you have a new customer.

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

More
8 years 4 months ago #1683 by Frank

People would just run one function, and it would search through content of some text component and swap only words that were translated in your asset.


That will be really slow. If you only have a hundred terms it could work, but some users have spreadsheet with over 400,000 terms. Searching of those terms in every text in your game every time the language changes or a text is enabled, will make the peformance go really slow.

Nonetheless, its really simple to do:
public string ParseAndLocalize( string text )
{
     // Get all terms and if the text has it, then replace it with the translation
     foreach ( var term in LocalizationManager.GetTermsList())
          if (text.Contains(term))
               text = text.Replace(text, ScriptLocalization.Get(term));
     return text;
}


textObject.text = ParseAndLocalize( textObject.text );

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 following user(s) said Thank You: Sarr

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

Time to create page: 0.175 seconds
Template by JoomlaShine