Jump to content

MCM translation


Recommended Posts

You can by using $someKey instead of the actual text in your config.json and then providing FO4\Data\Interface\Translations\modName_language.txt files with the text for each language as $someKey[TAB]translated text.

 

Example:

 

.../Data/MCM/Config/MyInternationalMod/config.json

{
	"modName": "MyInternationalMod",
	"displayName": "My International Mod",
	"minMcmVersion": 1,
	"content": [
		{
			"type": "section",
			"text": "$generalSettings"
		},
		{
			"id": "bIsEnabled:general",
			"text": "$isEnabled",
			"type": "switcher",
			"help": "$isEnabled_help",
			"valueOptions": {
				"sourceType": "ModSettingBool"
			}
		}
	]
}

.../Data/Interface/Translations/MyInternationalMod_en.TXT

$generalSettings	General Settings
$isEnabled	Enable My International Mod
$isEnabled_help	Turn this off to disable My International Mod

Key and value are separated with a tab.

Link to comment
Share on other sites

Make sure the txt file has the right encoding. Needs to be UTF-16 Little Endian.

 

You can check the f4se.log file (My Documents/My Games/Fallout 4/F4SE/f4se.log) and look for the "Reading translations" lines. If your file has incorrect encoding it will complain about BOM and encoding.

Link to comment
Share on other sites

Ok, it's working now except for text in between html mark up, if I have e.g.:

"text": "<p>$warning</p>",

and:

$warning If you uninstall this mod the 'AllowAttacks' properties will stay at whatever value you last set them to.

then the menu displays:

$warning

 

but if I put the tags in the tokenised text:

$warning <p>If you uninstall this mod the 'AllowAttacks' properties will stay at whatever value you last set them to.</p>

and:

"text": "$warning",

in the config.json

then the menu displays:

<p>If you uninstall this mod the 'AllowAttacks' properties will stay at whatever value you last set them to.</p>

 

is there a way to get this working?

 

diziet

Link to comment
Share on other sites

I don't know anything about Flash / ActionScript, but after having a quick look at MCM's source code, I'm not sure that the translation is done by MCM itself. MCM even uses a "Translator" helper function in more complex strings that need translated text. And that function basically sets the given string as the text property of a hidden TextField and then just immediately returns the text property of that hidden TextField. Seems to me that the translation / text replacement is happening somewhere else.

 

So what I suspect is happening when combining HTML and translations is this (total guesswork!):

 

In the second case (HTML tags in translation file) the text is added as htmlText, since there are no tags this comes out pretty much as plain text. The "$" is recognized by whatever does the translating and the text gets replaced with the text from the translation file. But I suspect that the translation process adds it as text, not as htmlText. Comparing this to JavaScript's (both languages are based on ECMA) "textContent" (=text) and "innerHTML" (=htmlText) this would mean that after the translation the htmlText look something like this: "<p>If you uninstall this mod the 'AllowAttacks' properties...</p>".

Ok, I just tested this in a barebones Flash project. And setting a text box's "text" property to "<p>If you uninstall</p>" actually ends up with its htmlText property as "<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#0066CC" LETTERSPACING="0" KERNING="0"><p>If you uninstall</p></FONT></P></TEXTFORMAT>". A lot of extra HTML added to it and the tags' angle brackets get escaped as expected.

 

Not quite sure what to make of the first case ("<p>$warning</p>"). If the text is added as htmlText and properly parsed, then the resulting value of the text property should be "$warning" and the first character should be "$" which seemingly should trigger the translation. Testing this in the same Flash project as before confirms this. Maybe whatever does the translation doesn't just look at the first character of the text property after all...

The resulting htmlText in my test project is actually identical for both setting htmlText to "<p>$warning</p>" and setting htmlText to "$warning". Could be that it's just looking at the raw incoming text (whether set via htmlText or text) directly to apply translations.

 

Maybe neanka knows more about this, or someone who worked on the Skyrim MCM. BTW, did translations with HTML tags work in Skyrim MCM?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...