Jump to content

[1.3.0] Automated Static File Localizer BETA (0.1.0)


Nils277

Recommended Posts

Automated Static File Localizer (this mod is only useful for mod creators)

This mod intends to automate the localization of static files for KSP like textures and KSPedia pages.
As most of you already discovered, adding localization to KSPedia or textures is a bit cumbersome and adds more effort for both, mod creators and users.

For more info, see here:

To make the life for all of us easier, this mod automatically switches the files provided by a mod to let KSP load the correct ones.

Warning: Due to multi-threaded loading of KSP, it is possible that this plugin is not able to rename all the files before they are loaded by KSP. It should work however when KSP is started a second time. 

How to use
 

KSPedia entries
For each KSPedia file you want to translate you have to set up a config file with the following content:

KSPediaLocalization
{
    path = GameData/Path/to/KSPedia/
    filename = filename
    default = en-us
}

The path describes the path to your KSPedia files. E.g. GameData/PlanetaryBaseInc/KSPedia/
The filename is the name of your kspedia file. E.g. planetarybaseinc
The default sets which language is set by default when the language of the user is not supported

All three fields are required.

For the files to work, you have to name them according to that scheme:

filename + "_" + language_tag + ".lang" for the files that can be translated into and
filename + "_" + language_tag + ".ksp" for the file that should be used.

in the case of KPBS the folder would look like this:

Quote

planetarybaseinc_es-es.lang   //one of the currently inactive KSPpedia entries (here the one for spanish)
planetarybaseinc_en-us.ksp    //the currently active KSPedia entry (in this case english)
localization.cfg                         //the config file for the localization of KSP

Other static files
BEWARE, this feature is still in development and not fully tested yet! Feedback is welcome.
For each static file you want to translate you have to set up a config file with the following content:

FileLocalization
{
    path = GameData/Path/to/file/
    filename = filename.extension
    default = en-us
    languages = en-us,es-es
}

The path describes the path to your KSPedia files. E.g. GameData/PlanetaryBaseInc/Parts/Utility/
The filename is the name of your static file. E.g. cargobay.dds
The default sets which language is set by default when the language of the user is not supported
The languages field contains all the languages wich are supported for the file. 

For the files to work, you have to name them according to that scheme:

filename + "." + language_tag + ".lang" for the files that can be translated into. You need to provide these files for ALL languages including the one that is delivered as default.
filename for the files that sould be used.

in the case of KPBS the folder would something look like this: (when Spanish and English is supported)

Quote

cargobay.dds.es-es.lang    //The language file for spanish
cargobay.dds.en-us.lang    //The language file for english
cargobay.dds                     //The texture used by the model
cargobay_loc.cfg               //The config file for the static file

Download
Plugin, Source

License
Automated Static File Localizer is licensed under the Apache License 2.0
But honestly, do whatever you like with the code! You can also add it to your project and adapt it instead of using the .dll. Just let me know when you discovered bugs or problems and know a way to fix them. :wink: 

Edited by Nils277
Link to comment
Share on other sites

I just updated the function to localize static files like textures.
It does not need to create a file anymore to save which language is set. It needs a new field in the config though to have a list of all supported languages.

This should make it a more robust when a user just copies over updates of mods instead of deleting the old version of the mod first.

Edited by Nils277
Link to comment
Share on other sites

  • 3 months later...

The KSPedia files do not really need any changes. You need one KSPedia file for each language you want to support and add the Language tag at the end of their name.

E.g.

yourmod_en-us.ksp for the english kspedia.

When you want to support e.g. spanish:

yourmod_es-es.lang

The non default languages have .lang instead of .ksp as ending. The plugin will change it to the .ksp file ending to the resource that fits to the selected language. It is best to take a look at the Feline Utility Rover or Kerbal Planetary Base Systems mods to see how the folders are configured. ;-) 

Link to comment
Share on other sites

Oh I gathered that yes, I was looking at Surface Experiment Pack and @DMagic committed a file with localization strings for the KSPedia and was wondering if there was a way inside Unity to get it to auto generate the AssetBundle in the various languages by referencing external text files with the different languages in.

See: https://github.com/CobaltWolf/Surface-Experiment-Pack/commit/f767c482307d2690d8458d5a41c62db1af8a287f#diff-1af52905758e628e12a23fa9ff7951e8

So to get KSPedia assets translated, people with the linguistic ability and Unity knowledge are required?

Link to comment
Share on other sites

2 minutes ago, Poodmund said:

Oh I gathered that yes, I was looking at Surface Experiment Pack and @DMagic committed a file with localization strings for the KSPedia and was wondering if there was a way inside Unity to get it to auto generate the AssetBundle in the various languages by referencing external text files with the different languages in.

See: https://github.com/CobaltWolf/Surface-Experiment-Pack/commit/f767c482307d2690d8458d5a41c62db1af8a287f#diff-1af52905758e628e12a23fa9ff7951e8

So to get KSPedia assets translated, people with the linguistic ability and Unity knowledge are required?

Sorry for sending you on a wild goose chase. He included those for reference I believe. They aren't really doing anything.

While we are on that subject. If I localize the strings in the KSPedia for GPP, would you compile it for me?

Link to comment
Share on other sites

7 minutes ago, Poodmund said:

Oh I gathered that yes, I was looking at Surface Experiment Pack and @DMagic committed a file with localization strings for the KSPedia and was wondering if there was a way inside Unity to get it to auto generate the AssetBundle in the various languages by referencing external text files with the different languages in.

See: https://github.com/CobaltWolf/Surface-Experiment-Pack/commit/f767c482307d2690d8458d5a41c62db1af8a287f#diff-1af52905758e628e12a23fa9ff7951e8

So to get KSPedia assets translated, people with the linguistic ability and Unity knowledge are required?

Unfortunately yes. You have to have someone able to create the KSPedia entries in unity and another one able to translate.
I also have files simular to the ones @DMagic made in his repository for KPBS and FUR so the person why is translating the texts does not have to get used to two formats when translating.

I just replaced the KSPedia texts in unity with the translated ones identifying them by their id in the translation file by hand.

Maybe this can be done automatically with a new plugin für unity (much like the parttools) but i'm not sure. Nevertheless you'd always have to manually fine tune the KSPedia entries because the translates texts do almost never fit in the original layout.
 

Link to comment
Share on other sites

5 minutes ago, Nils277 said:

Unfortunately yes. You have to have someone able to create the KSPedia entries in unity and another one able to translate.

Hmmm, I was hoping this was not the case but expected as much. Thank you for the confirmation.

5 minutes ago, Nils277 said:

Nevertheless you'd always have to manually fine tune the KSPedia entries because the translates texts do almost never fit in the original layout.

This is very true. I wish the KSPedia was a more dynamic object based system rather than everything being almost baked into a static asset.

Thank you for your help though, Nils. This tool is very useful.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...