Difference between revisions of "Lng2 File usage"

From Nexus Mods Wiki
Jump to: navigation, search
Line 10: Line 10:
  
 
<code>
 
<code>
<Entry Key="956942769" Value="Obtained Poster [%s] [GMP +%d]" />
+
<Entry LangId="announce_get_gravure" Color="5" Value="Obtained Poster [%s] [GMP +%d]" />
  
 
<Entry Key="4191827342" Value="Soviet Soldier" />
 
<Entry Key="4191827342" Value="Soviet Soldier" />
 
</code>
 
</code>
  
The Key is a CityHash64WithSeeds of the lua key string, most commonly reffered to at langId in the lua scripts.
+
The Key is a CityHash64WithSeeds of the lua key string, most commonly refereed to at langId in the lua scripts.
  
See [http://forum.xentax.com/viewtopic.php?f=10&t=12407&p=111415#p111415 StrCode32 Tool] [https://dotnetfiddle.net/mGKGr0 Source] to generate hashes.
+
LangTool supports a dictionary of langIds, and the LangId attribute on the first entry is the result of using the dictionary.
  
Provide it with a text file of strings (1 per line) and it will output same list with hashes appended.
+
The second entry langId actually resolves from key_poster_3500, but was ommitted from the dictionary for this example.
  
In lua a string is hashed using the engine function Fox.StrCode32(string)
+
In lua a string may be hashed using the engine function Fox.StrCode32(string), though there it's mostly used for indexing and engine functions that take langIds do the hashing internally.
  
Supports string formatting characters, in the above entries seen as %s for another langId, %d for a number.  
+
Localization strings support string formatting characters, in the above entries seen as %s for another langId, %d for a number.  
  
 
What it will accept however seems dependent on the function. AnnounceLogViewLangId will only accept the string, number, or number, number as it's paramaters, other combinations lock the game up.
 
What it will accept however seems dependent on the function. AnnounceLogViewLangId will only accept the string, number, or number, number as it's paramaters, other combinations lock the game up.
  
 
Evidence from other localization strings in lng2 files suggest other functions are less restricted.
 
Evidence from other localization strings in lng2 files suggest other functions are less restricted.
 
In the above entries the langId/Keys resolve from:
 
 
announce_get_gravure and key_poster_3500
 
  
 
Lua usage:
 
Lua usage:

Revision as of 18:49, 27 October 2015

lng2 files or lang files are used for localization. Mostly found in Assets\tpp\pack\ui\lang\lang_default_data_<language>.fpk

Language codes - eng,fre,ger,ita,jpn,por,rus,spa


lng2 files be converted to and from editable xml files using LangTool

The converted lng2 xml localization string entries will look like:

<Entry LangId="announce_get_gravure" Color="5" Value="Obtained Poster [%s] [GMP +%d]" />

<Entry Key="4191827342" Value="Soviet Soldier" />

The Key is a CityHash64WithSeeds of the lua key string, most commonly refereed to at langId in the lua scripts.

LangTool supports a dictionary of langIds, and the LangId attribute on the first entry is the result of using the dictionary.

The second entry langId actually resolves from key_poster_3500, but was ommitted from the dictionary for this example.

In lua a string may be hashed using the engine function Fox.StrCode32(string), though there it's mostly used for indexing and engine functions that take langIds do the hashing internally.

Localization strings support string formatting characters, in the above entries seen as %s for another langId, %d for a number.

What it will accept however seems dependent on the function. AnnounceLogViewLangId will only accept the string, number, or number, number as it's paramaters, other combinations lock the game up.

Evidence from other localization strings in lng2 files suggest other functions are less restricted.

Lua usage:

TppUICommand.AnnounceLogViewLangId("announce_get_gravure","key_poster_3500",500)

If a langId is called without a matching entry in the particular language lang file it will return empty.

Fox engine will load all lng2 files from a pack enabling addition of completley new .lng2 files.