Jump to content

Localization Support of KSPedia pages and Static files for Mods


JPLRepo

Recommended Posts

The following describes how you can setup your mod to support Localization languages for KSPedia asset bundles and static files.

KSPedia

With only the free version of TMPro available to modders unfortunately this means modders cannot use TMPro/AutoLoc language tags in KSPedia pages.
 

The current solution for modders is to create separate KSPedia asset bundles for each language you wish to support and then to implement your own patching files as per the following patching section below.

Static Files (such as textures)

Static files for Localization cannot be automatically replaced by mods. For Stock KSP this is performed via Steam automatically when the user selects their language. But what modders can do is implement their own patch files to switch and replace static files for different languages. Please refer to the patching section below.

Patching - Windows

Localization patches for KSP Windows version are created using Inno Setup, this software allows you to create installers for Windows (2000 - Win 10) and also includes other very useful options such as multilingual support to create installers.

It is best to create a separate script for each language you want to support.

Here is an example of how to create a patch using Inno Setup:

  1. Download the Unicode version of the program here and install it

  2. Chinese is not officially supported, but the language file can be downloaded from here,  then the file  just needs to be placed in the “Languages” folder located in the Inno Setup installation folder.

  3. To expedite things, here is a full configuration script used to create a language patch for KSP, some parts will be explained (click here to download the file), in any case we recommend to visit the documentation.


Some parts of the configuration script are very straightforward, as mentioned before we recommend you visit the documentation to clarify any concerns or questions you may have.

Here is a brief explanation of the most important aspects to consider:

[Setup] Section

  • OutputBaseFilename=KSP-LANG_PATCH-EN_US; This will the name of the resulting installer

  • PrivilegesRequired=admin; Privileges required to run the patcher

  • SetupIconFile=icons\kspInstIcon.ico; Location of the icon file

  • UninstallDisplayIcon=icons\kerbalIcon.ico; Location of the icon file


[Languages] Section

This part is very important for localization. If you want your resulting installer to be in Japanese for instance, you will need to change the language:

Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"


[Files] Section

Source: "en-us\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

This is the location of the files that will be installed by the patcher app, in this case is the content of the “en-us” folder.

Note: “Default.isl” contains the Messages for the English language


[Run] Section

Here you specify the actions to perform once the installation has completed, in the example case we have configured it to execute the launcher and the Readme file.

 

{CODE} Section

Inno setup offers the possibility to add functionality to your installers, for Stock KSP patchers we needed to be sure that the player has a version of the game that supports the localisation features. We resolved this by validating the build id number contained in the buildid.txt file, and this is precisely what is contained in the code section.

If you don’t want this additional functionality, this entire section can be completely erased from the configuration script.

 

Patching - OSX & Linux

Patching for OSX requires you to write a script .command file to replace KSPedia bundles and static files as per the example below.

Patching for Linux requires you to write a script .sh file to replace KSPedia bundles and static files as per the example below.


Example script (used for KSP Store language patcher)
 

#!/bin/bash

cd "`dirname "$0"`"

if [ -f buildID.txt ];
then
    sed -n '2p' < buildID.txt > temp.txt
    read uno dos tres buildid < temp.txt
    if [ "$buildid" -ge "1730" ];
    then
        rm temp.txt
        printf '\nThis script will patch Kerbal Space Program to translate it to English\n'
        if [ -f KSP-LANG-EN-US.zip ];
        then
            unzip -oq KSP-LANG-EN-US.zip
            echo '   ************************************************************** '
            echo '  ****************************************************************'
            echo '** Kerbal Space Program has been translated to English US **'
            echo '  ****************************************************************'
            echo '   ************************************************************** '
        else
            printf '\nERROR: \nThe ZIP file was not found, please verify that it is located in the same folder as this script...\n\n'
            exit -1
        fi
    else
        rm temp.txt
        printf '\nWarning: \nYou are running a version of KSP that does not support the Localization feature, please go to KSP Store and download the most recent version of the game. \n\n'
    fi    
else
printf '\nLooks like Kerbal Space Program its not stored on this folder...\nMove the Localization files to the folder where Kerbal Space Program is located and run again this script... \n'
fi

Linux
#!/bin/bash

cd "`dirname "$0"`"

if [ -f buildID.txt ];
then
    sed -n '2p' < buildID.txt > temp.txt
    read uno dos tres buildid < temp.txt
    if [ "$buildid" -ge "1730" ];
    then
        printf '\nThis script will patch Kerbal Space Program to translate it to English\n'
        if [ -f KSP-LANG-EN-US.zip ];
        then
            unzip -oq KSP-LANG-EN-US.zip
            echo '   ************************************************************** '
            echo '  ****************************************************************'
            echo '** Kerbal Space Program has been translated to English US **'
            echo '  ****************************************************************'
            echo '   ************************************************************** '
        else
            printf '\nERROR: \nThe ZIP file was not found, please verify that it is located in the same folder as this script...\n\n'
            exit -1
        fi
    else
        printf '\nWarning: \nYou are running a version of KSP that does not support the Localization feature, please go to KSP Store and download the most recent version of the game. \n\n'
    fi    
else
    printf '\nLooks like Kerbal Space Program its not stored on this folder...\nMove the Localization files to the folder where Kerbal Space Program is located and run again this script... \n'
fi

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...