About Store Forum Documentation Contact



Post Reply 
Translation
Author Message
bivit Offline
Member

Post: #1
Translation
Good day. I am new to EE, but as far as possible teach this wonderful engine. But I had a great question - how to implement a system of translation of the words? I have connected to my project LUA and tested several functions, everything works. But how to make the word of "$SETTINGS" (for example) with the aid of Lua script takes given values?
example:
Strings_english.lua
$bNew = New game
$bExit = Exit game
...

It would be very, very comfortable. Especially for multilanguage applications. Help please. Or maybe there is another solution?
I'm sorry for my english =))
10-13-2011 11:50 AM
Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #2
RE: Translation
I'm not using LUA for this. I preffer using simple FileText.

This is my sample file:
Code:
[bNew] = "New Game"
[bExit] = "Exit Game"

and I have function to find a text that I need:

Code:
Str getText(Str ID)
{
   FileText f;

   if(f.read(S + "Data/Lang/pl.dat"))
   {
      for(;f.level();)
      {
          if(f.cur(ID))
          {
              return f.getName();
          }
      }
   }

   return "";
}

It returns the text with given ID (for example "Exit Game" for [bExit]) or returns empty string if the given ID haven't been found.
(This post was last modified: 10-13-2011 03:09 PM by Ogniok.)
10-13-2011 02:04 PM
Find all posts by this user Quote this message in a reply
bivit Offline
Member

Post: #3
RE: Translation
Thank you! Who also interested in this question:
Src:
Code:
/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
Str getText(Str ID)
{
    FileText f;

    if(f.read("Strings.txt"))
    {
       for(;f.level();)
       {
           if(f.cur(ID))
           {
               return f.getName();
           }
       }
    }
    return "";
}
/******************************************************************************/
Str $SAMPLE=getText("$SAMPLE");
/******************************************************************************/
void InitPre()
{
   App.name("Strings");
   Paks.add("../data/engine.pak");
}
/******************************************************************************/
Bool Init()
{
   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   return true;
}
/******************************************************************************/
void Draw()
{
   D.clear(TURQ);
   D.text(0, 0, $SAMPLE);
}
/******************************************************************************/
Strings.txt:
Code:
$SAMPLE = "This is cool!"

Strings.txt optional (* TXT) I connect Strings.lua, in my project is Luabind.
Good luck in all your endeavors)
(This post was last modified: 10-14-2011 08:44 AM by bivit.)
10-14-2011 08:16 AM
Find all posts by this user Quote this message in a reply
Post Reply