Custom language real time translation problem

  • I am building a translator for my language and I quite know how I'm gonna do the rest of the engine, but I am stuck on a problem that I wanted to do first, as the rest of the engine will be easy to programm.

    Works like this: When I type a word into the TextBox, it adds the word (if it's detected) into a Text instance variable called Output. Then it sets the Text to Output.

    Problem: Words getting overwritten; when a user types for example "You are cool", it translates to "i pai" and when I write any of the already used words again, e.g. "You are cool, you", it doesn't add another "you" at the end as it should. *It's because the value is already in the variable.*

    Problem 2: My realtime breaks at the point when I start deleting stuff. It adds a word to a variable when it detects it and then sets the variable equal to the display text, but the strings in the variable don't get removed. Is there a way to find a value in a variable and replace it with "" so that it removes it and the space it took as well?

    My Capx:

    https://ufile.io/kxweq

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • To your first issue, it only shows it once as you only told it to trigger once.

    Scanning it all every tick is basically rereading everything on a 'find'.

    I tried to condition it, but it will always add another 'I' due to the rescanning.

    You would probably do better trying to read and store each word separately, (in an array for example) so then you would know which words you processed and which ones you didn't.

    Using find likely won't work. "I went to the zoo to see the zoo keeper" would not see the second 'to', the second 'the' or the second 'zoo', so your process would fail.

    Storing as an array, you could keep track of each word, and the associated translation.

    EG: You could have an array that has the word and true/false if you've translated it.

    Array:

    English,0="you",1

    English,1="are",1

    English,2="cool",1

    English,3="you",1

    English,4="fascinate",0

    Athron,0="I"

    Athron,1=

    Athron,2="pai"

    Athron,3="I"

    Finally, I'd also suggest something like a JSON table or database to do your lookups, it would be a lot easier to maintain. Making the table online would mean you could update the words without having to make a new release.

    Hope that helps?

  • Interesting idea, especially for the online database part. Think I might do just that! Thanks This helps me quite a lot!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)