Jump to content

SKSE text substitution


Recommended Posts

In my MCM script file I have:

debug.notification("$version_update{"+ver+"}")

and in the translation file I have:

$version_update{}	Version updated to {}.

all the other translations work, but none of them are using the {} ;

what is displayed is:

$version_update{2}

where the variable 'ver' is in fact '2' and a string.

Now I know this {} format works with the ShowMessage() function while an MCM menu is diplayed, but is it not meant to work with debug.notification even in an MCM script?  I am tired at the moment, so perhaps I'm overlooking something really obvious:)

 

diziet

Link to comment
Share on other sites

This gets weirder, to eliminate the use of debug.notification as the problem I added this to the MCM menu:

AddTextOptionST("state_test", "$version_update"+" "+"$placeholder{"+ver+"}", "string text", 0)

and:

$version_update	Version updated to
$placeholder{}	{}

in the translation file, with 'ver' already set to 2 this shows in the menu as:

$version_update "$placeholder2

now every other MCM menu entry has the substitution working e.g.

AddToggleOptionST("state_debug", "$ShowDebugMessages", allowdebugstatus)

with, in the translation file:

$ShowDebugMessages	Show Notification Messages

shows as:

Show Notification Messages

The things is I've only done this {} thing before with ShowMessage() so maybe I shouldn't be expecting it to work outside of that context?

The conflict part of the MCM script works fine:

	msg = "$KeyMapConflict{" + conflictControl + "}"
			EndIf
			continue = ShowMessage(msg, True, "$Yes_text", "$No_text")

but that is using ShowMessage, and the substitution is presumably in a SkyUI translation file

 

diziet

edit:

this in the script:

AddTextOptionST("state_test", "$version_update"+" " + "$placeholder{" + ver + "}", "string text", 0)
AddTextOptionST("state_test2", "$placeholder{"+ver+"}", "also string text", 0)
AddTextOptionST("state_test3", "$version_update", "this is string text", 0)

looks like this:

MIBZWIC.png

Link to comment
Share on other sites

Ok, this is what I seem to find:

debug.notification("$token")   works,

debug.notification("$token"+stringvariable)  does not work,

debug.notification("$token"+"2")   does not work

debug.notification"$token{"+stringvariable+"}" does not work, no matter how the translation file reads.

It seems that the SKSE translation file facility only works for exact tokens outside of SkyUI context - even in MCM menu scripts, because this:

((Quest As Form) As UiLib_1).ShowNotification("$token{"+stringvariable+"}")  does work,

UILib being of course part of the SkyUI code.  However UILib messes with the size of notifications in my testing (which is why I have a mod to replace the swf file!) so I wouldn't want to wish it on anyone without good reason.

It seems that the use of {} is only a SkyUI/UILib thing, which is why ShowMessage("$token{"+stringvariable+"}")  works.

 

diziet

Link to comment
Share on other sites

  • 2 months later...

Localising a Mod

Info for starters: this is SKSE add on from 1.6.0 and it has these prerequisites

Quote

- support for additional interface translation files (same as Translate_ENGLISH.txt)
    If your mod is named MyMod.esp, place files in Data/Interface/Translations/MyMod_<LANGUAGE>.txt,
        i.e. MyMod_RUSSIAN.txt
    Files must use the same encoding as the original Translate_*: UTF16 LE with BOM aka UCS-2 LE
        and contain $key<TAB>value pairs. Loading them from .BSA files is supported, too

I get it to work anywhere, MCM, Quest Scripts, Magic Effects etc. The use of placeholder is standard, use it just like any other language

But since the author stated it does work in the MCM let me post this 

    If(a_conflictControl != "")
        String sMsg
        If(a_conflictName != "")
            sMsg = "$DQ3_KeyMappedTo{" + a_conflictControl + "}_{" + a_conflictName + "}Continue"
        Else
            sMsg = "$DQ3_KeyMappedTo{" + a_conflictControl + "}WantToContinue"
        EndIf
        Return Self.ShowMessage(sMsg)
    EndIf

ModName_ENGLISH.txt

#IsKeyCodeFree
$DQ3_KeyMappedTo{}_{}Continue	This key is already mapped to:\n'{}'\n({})\n\nAre you sure you want to continue?
$DQ3_KeyMappedTo{}WantToContinue	This key is already mapped to:\n'{}'\n\nAre you sure you want to continue?

ModName_ITALIAN.txt

#IsKeyCodeFree
$DQ3_KeyMappedTo{}_{}Continue	Questa chiave è già mappata a:\n'{}'\n({})\n\nSei sicuro di voler continuare?
$DQ3_KeyMappedTo{}WantToContinue	la sua chiave è già mappata su:\n'{}'\n\nSei sicuro di voler continuare?

I am even using escape sequences, if you cannot get it to work play with it, it is user error, btw I can confirm it works from BSA 

Get the key tab and encoding right, the hash is for comments, there was a webpage dedicated on how to do this, many many many many many years ago. I tried my best to find it, it is where I learnt how to do this, I could not find, it may not even still exist.

Read the SKSE "skse_whatsnew.txt" version section 1.6.0 if you like see it with your own eyes, but if you get errors they will be user errors, do better. Do not do pointless /  unnecessary concatenations, and cry it does not work, keep it simple stupid

Follow my lead and do not use white space in the key ¯\_(ツ)_/¯ no idea why I did that, it was 9 years ago, but there must be a reason

EVERY IMPORTANT if your mod is just English with no localisation, backtrack to keep it simple stupid and explain to me like talking to baby why you need this, and keep repeating it until I understand 🙏🏽

Always check the encoding when saving 

Yes I also know how to do the Binary strings, I create them with xEdit decompile them into xml files and create the other languages xml files, translate them, compile them back into Foreign languages binary strings, I do not use a tool except for compiling/decompiling, and all my translating is in a text format, and yes I really love it when I just hand a text document to someone who spoke the language. LOL wonder if that tool still exists, I remember the LOOT guy made made it, maybe the old old old LOOT guy now 😉😉😉😉😉 yes it supported cyrillic characters too, if I am allows to say that in this day and age

That how you localise a mod. 

Edit

https://www.nexusmods.com/skyrim/mods/28365

that String Edit, found it 😉  localising binary strings is vanilla and does not require SKSE

Link to comment
Share on other sites

  • Recently Browsing   0 members

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