playMaker

Author Topic: How to translate dynamic text  (Read 1428 times)

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
How to translate dynamic text
« on: February 07, 2017, 09:33:50 AM »
Hi there,

Basically I need to translate quite a lot of text from XML file, all this text is pretty much different so in each level it says something else. I had a look at plugins like "Smart Localization" and "i2 Localization"  but they translate stuff inside UI Text Component... How would I go about translating my text from XML with those plugins? Or perhaps is it easier in this case to create my own system?
« Last Edit: February 07, 2017, 09:35:39 AM by elusiven »

marv

  • Junior Playmaker
  • **
  • Posts: 50
Re: How to translate dynamic text
« Reply #1 on: February 07, 2017, 09:53:47 AM »
Is it possible to "cheat" them by having a UI text component that's not part of your actual UI, parse the text from xml into the text component, use the plugin to translate the content and then read it out again to process further?

I have not the slightest clue what that'd do in terms of performance, but it would probably be my first attempt to somehow frankenstein together a solution.^^

cheers
« Last Edit: February 07, 2017, 10:06:43 AM by marv »

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: How to translate dynamic text
« Reply #2 on: February 07, 2017, 05:45:03 PM »
I made a new script, that reads from XML with xpath, either single or multiple nodes. Then I got the component script that is responsible for translating that has the key variable, on the gameobject I want to translate, and pulled value from xml and just passed it into that component and then refresh the language. Seems a bit dirty work to me though but it works...

Smart Localization has a component script with class LocalizedText, I'm wondering if I can inherit from it and extend it's functionality to accommodate XML. Seems like a cleaner way to do this?

namespace SmartLocalization.Editor {

class LocalizedText
{

}

}

So, maybe I can create a new file LocalizedTest_XML and do something like this

namespace SmartLocalization.Editor {

class  LocalizedText_XML : LocalizedText
{
   // new functionality here, and it will inherit all the old functionality automatically.
}

}

and then all I have to do is just attach the new script... I'm not sure if this would be okay with the plugin though