Difference between revisions of "Lng2 File usage"

From Nexus Mods Wiki
Jump to: navigation, search
(Created page with "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 l...")
 
m
 
(5 intermediate revisions by 2 users not shown)
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.
+
You can get the dictionary from here: https://github.com/cstBipBop/MGSV-Lang-Dictionary-Project
  
In lua a string is hashed using the engine function Fox.StrCode32(string)
+
The second entry langId actually resolves from key_poster_3500, but was omitted from the dictionary for this example.
  
Supports string formatting characters, but what it will accept seems dependant on the function. AnnounceLogViewLangId will only accept the string, number, or number, number as it's paramaters, other combinations lock the game up.
+
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.
  
Evidence from other localization strings in lng2 files suggest other functions are less restricted.
+
Localization strings support string formatting characters, in the above entries seen as %s for another langId, %d for a number.  
  
In the above entries the langId/Keys resolve from:
+
What it will accept however seems dependent on the function. AnnounceLogViewLangId will only accept the string, number, or two numbers as it's parameters, other combinations lock the game up.
  
announce_get_gravure and key_poster_3500
+
Evidence from other localization strings in lng2 files suggest other functions are less restricted.
  
 
Lua usage:
 
Lua usage:
Line 39: Line 39:
 
If a langId is called without a matching entry in the particular language lang file it will return empty.
 
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.
+
Fox engine will load all lng2 files from a pack enabling addition of completely new .lng2 files.
 
[[Category:Metal Gear Solid 5]]
 
[[Category:Metal Gear Solid 5]]
[[Category:The Phantom Pain]]
 
 
[[Category:Lua]]
 
[[Category:Lua]]
[[Category:File usage]]
+
[[Category:Scripting]]
 +
[[Category: Mod Creation]]

Latest revision as of 15:05, 15 November 2018

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.

You can get the dictionary from here: https://github.com/cstBipBop/MGSV-Lang-Dictionary-Project

The second entry langId actually resolves from key_poster_3500, but was omitted 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 two numbers as it's parameters, 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 completely new .lng2 files.