Text resource files

From X-Wiki

Jump to: navigation, search

X2 - The Threat and X3 Reunion are storing all game texts in so called Text resource files.

Contents

Description

Text resource files are XML files located in t directory (usually in catalog). Every file has its language id and number.

Example of text resource file from DDRS mod:

<?xml version="1.0" encoding="UTF-8" ?> 

<language id="44">
  <page id="300017" title="Boardcomp. objects" descr="" voice="yes">
    <t id="22001">Odin</t> 
    <t id="22002">The Odin is a variant of the primary Earth Fleet Battlecruiser class, 
                  armed with advanced weaponry and fighter bays. It was designed to be 
                  a mobile base to serve Earth Fleet operations within the Sol system.
    </t> 
    <t id="22003">Grendel</t> 
  </page>
</language>

File name structure

The file name consist of two groups of digits grouped together: LLIIII

where:

  • LL is the two digit language code
  • IIII is four digit file number

Example of file name: 440001.xml (English file with file number 1)

There is no special requirement about the file numbers, however they can affect file loading.

How file loading works

The game will first determine what text resource files to load based on its language setting. Only the files with the correct language ID in their name will be used.

Next the game will load the files in sequence, by starting at 1 and incrementing the file number. As soon as the sequence is broken (no file with the given file number exists), the loading will stop.

Example:

Suppose we have these files:

  • 440001.xml
  • 440002.xml
  • 440004.xml

The game would only load the first two files, because then it would fail to load the file 440003.xml, which does not exist.

If pages with the same Page ID is defined in two (or more) files, then such pages will be merged together. The result would be a single page containing all the texts from both pages.

If there are texts with the same Text IDs in both pages, then the text defined in the file with lower number will be overwritten with the new variant defined in the file with higher number.

File structure

The file must be a valid XML file.

ElementParent ofAttributes
language(none)
pagelanguage
  • id - id of page (used for hyperlinks and in scripts)
  • title - name of the page (only used in X2E and X3E)
  • descr - description of page (only used in X2E and X3E)
  • voice - unknown
tpage
  • id - id of the text (used for hyperlinks and in scripts and T files)

Special control characters

Texts can have special control characters in them:

CharacterFunction
\n Makes new line in text
\t Makes an indentaion (inserts tab)
parenthesis () Parenthesis work as a comments - text in parenthesis is not displayed
(||) Makes a new line

Because Text resource files are in XML format, certain characters are not allowed in them. In particular:

  • < and > (less than and greater than signs)
  • & (ampersand)

You must replace these characters with their respective XML entities in order to make a well formed XML.

Instead of Use this
< &lt;
> &gt;
& &amp;
Note: When using X3 Editor, the characters are automatically translated into their respective entities and back. No special caution is required.

Text inclusion

There is a special feature which allows you to include certain text into another one. This is also sometimes called hyperlinks although it's incorrect.

Example of text inclusion:

<page id="1">
  <t id="1">Hello</t>
</page>

<page id="2">
  <t id="1">{1,1} how are you?</t>
</page>

The text {1,1} how are you? would be displayed as: Hello how are you?.

The text inclusion tag has format:

{Page ID, Text ID}

  • Page ID is the page where is the text you want to include
  • Text ID is the ID of the text you want to include

If both text are in the same Page, then the Page ID may be omitted:

Example:

<page id="1">
  <t id="1">Hello</t>
  <t id="2">{,1} how are you?</t>
</page>

{,1} how are you? - here only the Text ID is used. The program will automatically use the currect Page ID.

X3 Page IDs

In X3, new Page IDs were introduced to hold informations specific to X3.

Example of such Page is:

<page id="300017" title="Boardcomp. objects" descr="" voice="yes">

X3 specific Page IDs are constructed as 300 000 + Page ID

So the above example is in fact Page 17.

X3 does not internally use these high pages. Instead it will merge them with their low counterparts.

It does this by substracting 300 000 from the Page ID (to get base Page ID) and then it will merge it with the base page (if such exist). Text IDs which are defined in the high page and also exist in the low page will be overwritten with the high variant.

When using text inclusion, do not use the high Page IDs - instead use the base IDs

<page id="300017">
  <t id="1">Hello</t>
</page>

<page id="1">
  <t id="1">{17,1} world!</t>
</page>
Note: In X3 Editor, the text inclusion doesn't work correctly for high PageIDs when editing a file. It does however, work when viewing Pages in memory.

See also

Tags and colors explained on Egosoft S&M forum

Personal tools
sections