if ((Player getVariable "SpareTime") > 0) then {...
« New to ArmA 2 (Beta): paramsArrayOn the horizon »

CSVtoXML

Permalink 08/25/09 17:59, by jonas, Categories: ArmA

CSVtoXML is a converter to convert a stringtable.csv to a stringtable.xml.

The Biki link should explain the stringtable.csv but sadly nothing exists about the stringtable.xml.

Stringtable.xml?

The stringtable.xml was introduced in ArmA II. The xml file replaces the stringtable.csv. The stringtable.csv is still supported, but I heard rumour that configs prefer the xml format.

...

How does it look like?

XML:


<?xml version="1.0" encoding="utf-8"?>
<Project name="Arma2">
  <Package name="Modules">
    <Container name="AIS_BC_FA">
      <Key ID="str_agonyTakeOutAction">
        <German>Verletzte evakuieren</German>
      </Key>
      <Key ID="bc_addactions.sqf35">
        <German>Tragen</German>
      </Key>
      <Key ID="carrier.sqf0">
        <German>Tragen beenden</German>
      </Key>
      <Key ID="dragger.sqf0">
        <German>Ziehen beenden</German>
      </Key>
    ...
    </Container>
  </Package>
</Project>

This fragment has been taken from the stringtable.xml in language\Modules from a German ArmA II version.
It is a normal xml-file with a main element named Project. Next elements are Packages. BIS used it as a generic group of the keys. Next element is the Container. This is not required, languagecore\stringtable.xml doesn't use it. But all other files use the Container as a more detailed group. The Container element can be nested.
The next to last element is the Key. This contains the string name which is used by localize.
The last element is the language tag. Each key-element contains an element for each language a translation exists.
In the above code str_agonyTakeOutAction has the German translation "Verletzte evakuieren".
So the Key with id str_agonyTakeOutAction contains an element German with the content "Verletzte evakuieren". To add another translation, e.g. English, we add an element English with content "Take out injured".

So what does CSVtoXML?

As said above: It's convert a stringtable.csv to a stringtable.xml &amp;#59;&amp;#41;

Input:

Code:


"LANGUAGE","English","German","French"
"STR_DN_HE_6G30","VOG-25P","VOG-25P","VOG-25P"
"STR_ION_RTE","RealTimeEditor","RealTimeEditor","RealTimeEditor"
"STR_ION_RTE_BETA_CAPTURE","RTE Capture is required when using the beta version","RTE Capture wird für die Betaversion benötigt","RTE Capture est requis lorsque vous utilisez la version beta"
"STR_ION_RTE_BUGREPORT_TEXT","Bug report:","Fehlerbericht:","Rapport de bug"
"STR_ION_RTE_BUGREPORT_TITLE","Send a bug report","Fehlerbericht senden","Envoyez un rapport de bug"

Output:

XML:


<?xml version="1.0" encoding="utf-8"?>
<Project name="Arma2">
  <Package name="ION">
    <Container name="RTE">
      <Key name="STR_DN_HE_6G30">
        <English>VOG-25P</English>
        <German>VOG-25P</German>
        <French>VOG-25P</French>
      </Key>
      <Key name="STR_ION_RTE">
        <English>RealTimeEditor</English>
        <German>RealTimeEditor</German>
        <French>RealTimeEditor</French>
      </Key>
      <Key name="STR_ION_RTE_BETA_CAPTURE">
        <English>RTE Capture is required when using the beta
        version</English>
        <German>RTE Capture wird f&#195;&#188;r die Betaversion
        ben&#195;&#182;tigt</German>
        <French>RTE Capture est requis lorsque vous utilisez la
        version beta</French>
      </Key>
      <Key name="STR_ION_RTE_BUGREPORT_TEXT">
        <English>Bug report:</English>
        <German>Fehlerbericht:</German>
        <French>Rapport de bug</French>
      </Key>
      <Key name="STR_ION_RTE_BUGREPORT_TITLE">
        <English>Send a bug report</English>
        <German>Fehlerbericht senden</German>
        <French>Envoyez un rapport de bug</French>
      </Key>
    </Container>
  </Package>
</Project>

We can see some details: The Package element contains the OFPEC-tag, the Container element contains the project name.

Download-Link

7 comments

Comment from: kju [Visitor]
kjuNice post once again!

I am unsure if there is really a reason to convert csv to xml.
CSV are a bit more strict I think it terms of correct definition.

Personally I find the csv easier to handle, if you have few languages.
08/25/09 @ 22:42
Comment from: jonas [Member] Email
jonashttp://www.ofpec.com/forum/index.php?topic=33924.0

As White Angel reported, in some cases it seems like you need to use the stringtable.xml.
But I'm not sure if you can use the $ instead of the @ to fix the problem.

Nevertheless:
In theory BIS should have made some thoughts before changing the format.
Maybe XML is cooler then CSV ;)
08/25/09 @ 23:07
Comment from: kju [Visitor]
kjuWell if you have many languages, and for non coders,
an xml editor for better usability to add or edit text,
I do see the pros of xml.

Parsing works also.

@ is normally for mission names inside sqm from what I recall.
$STR_ is for anything else.
08/25/09 @ 23:21
Comment from: Chris [Visitor] Email
ChrisThank you very much for the above information! Very helpful, just one thing that confuses me a little. Can you add includes (ex. #include "someNameOfDocument.sqf") to an xml file? Thanks again!
02/01/10 @ 03:55
Comment from: jonas [Member] Email
jonasProbably yes, but I haven't tested it.
02/01/10 @ 22:33
Comment from: MCPXXL [Visitor]
MCPXXLHi Jonas

On Windows 7 the tool just close without a comment and on xp i get an error and will be asked to send it to microsoft.

Any idea ?
02/16/10 @ 23:05
Comment from: mikero [Visitor]
mikerounless i misunderstood, the @ $ issue is irrelevent. @ is used only in script, and the engine looks for it's $ equivalent in the csv
03/14/10 @ 16:34