Jump to content

Custom text's for getText()


turbotutone

Recommended Posts

Hello,

 

Ive noticed the frequent use of the getText() function that, if im not mistaken, refers to a global java function of some sort that handles correct language display.

 

An example of the function call in some random lua file:

local doorOption = subMenu:addOption(getText("ContextMenu_Door"), worldobjects, nil);

Ive also noticed that, for example, the english language files required for this function seem to be residing in:

media/lua/Translate/EN/

 

So, i have tried adding a custom textfile with custom identifiers, using the same formatting as these files found in above mentioned directory, to my_mod_directory/media/lua/Translate/EN/:

MyMod_EN.txtMyMod_EN = {	MyMod_TitleDisplay = "MyMod Title!!!",}

but this did not seem to work.

 

Thus my question; is there at this moment a way to properly utilize this getText() funtion for you mod?

 

Regards,

Turbo

Link to comment
Share on other sites

From: zombie.core.Translator 

  public static void loadFiles()  {    moodles = new THashMap();    ui = new THashMap();    survivalGuide = new THashMap();    items = new THashMap();    contextMenu = new THashMap();    farming = new THashMap();    recipe = new THashMap();    igui = new THashMap();    tooltip = new THashMap();    fillMapFromFile("Tooltip", tooltip);    fillMapFromFile("IG_UI", igui);    fillMapFromFile("Recipes", recipe);    fillMapFromFile("Farming", farming);    fillMapFromFile("ContextMenu", contextMenu);    fillMapFromFile("SurvivalGuide", survivalGuide);    fillMapFromFile("UI", ui);    fillMapFromFile("Items", items);    fillMapFromFile("Moodles", moodles);  }  private static void fillMapFromFile(String file, THashMap<String, String> map) {    InputStream fis = null;    try {      fis = new FileInputStream("media/lua/Translate/" + getLanguage().toString() + "/" + file + "_" + getLanguage().toString() + ".txt");      parseFile(fis, map);    } catch (FileNotFoundException e) {      try {        if (language != defaultLanguage)        {          fis = new FileInputStream("media/lua/Translate/" + defaultLanguage.toString() + "/" + file + "_" + defaultLanguage.toString() + ".txt");          parseFile(fis, map);        }      }      catch (Exception localException)      {      }      try      {        if (fis != null)          fis.close();      }      catch (IOException e)      {        e.printStackTrace();      }    }    finally    {      try      {        if (fis != null)          fis.close();      }      catch (IOException e)      {        e.printStackTrace();      }    }  }

as you can see, those files in media\lua\Translate are being loaded into Hash Tables using SPECIFIC lines of code in PZ Java. The only way to get your file to load would be to edit the Java. Create a new Hash Table called mymod then call the fillMapFromFile() method & after looking at that method you can see that you would need a "MyMod_" .. LanguageAbbreviation .. ".txt" in each of those directories otherwise running your mod with another default language set would throw a FileNotFoundException.

I'm sure there's more to it than this but that's all right there at the top of Translator.class

 

So...... short answer no. There are a few things like this I would like to control from lua (AngelCodeFonts & changing the read directory of getFileReader() are BIG ones as far as I'm concerned) but as of yet there is no way to do so

 

EDIT:

 

after re-reading that, it sounded like I was saying "edit the Java"...... DONT EDIT THE JAVA :P

Link to comment
Share on other sites

Thank you for the excellent answer ExcentriCreation, and thanks for letting us know theres a option for modders becoming available soon RobertJohnson.

 

For the meanwhile ive cooked up a little function override that lets people use getText in their lua files already instead of strings all over the place :P I shall post it in the resources section.

 

- posted here:

http://theindiestone.com/forums/index.php/topic/3706-custom-gettext-a-temporary-fix/

 

Regards,

Turbo

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...