CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.32k stars 4.14k forks source link

Translate 3rd party mod #44225

Closed linonetwo closed 4 years ago

linonetwo commented 4 years ago

Is your feature request related to a problem? Please describe.

I hope I can help translate a third-party mod, but I see currently the only way to translate is to do a full copy and replace strings.

Can there be a way to help community mod translated in a better maintainable way?

Describe the solution you'd like

Maybe allow a "translation mod" which uses "op" to substitute strings inside the original mod, this is the way Starbound and Rimworld uses.

For example, using PatchOperationReplace in the Rimworld translation mod:

<?xml version="1.0" encoding="utf-8"?>
<Patch>
    <Operation Class="PatchOperationFindMod">
        <mods>
            <li>SomeOtherMod</li>
        </mods>
        <match Class="PatchOperationReplace">
            <xpath>/Defs/ThingDef[defName="ExampleDefFromSomeOtherMod"]/isTechHediff</xpath>
            <value>
                <isTechHediff>true</isTechHediff>
            </value>
        </match>
    </Operation>
</Patch>

https://rimworldwiki.com/wiki/Modding_Tutorials/Compatibility_with_defs

But since CDDA has hot language replacement, we need a way to load a correct set of patch depended on current activated language.

Describe alternatives you've considered

Or maybe allow the mod to have a "translations" folder which contains string replacement pairs? As said in https://github.com/CleverRaven/Cataclysm-DDA/issues/29077

Additional context

I don't know why https://github.com/chaosvolt/cdda-arcana-mod gets to move out of the main repo, was there an argument between the mod author and the core team? Since I'm using it, I want to do some translation to it.

CountAlex commented 4 years ago

@BrettDong probably may give you some directions. Might also require some maintenance and scripting.

anothersimulacrum commented 4 years ago

It's not in the main repo because that contributor has had consistently poor behavior and was banned from the repo 4 years ago, but still maintains the mod.

At a glance, it appears that gettext cannot handle multiple .mo files, so the mods would need to provide their own .po files, and the game would need to dynamically generate .mo files either when loading the game or at game start. (Or mods provide their own .mo files for all the game, but that's extremely error prone, though possible right now)

(Note that this is a glance, it's very possible I missed something about gettext)

ZhilkinSerg commented 4 years ago

It is already possible: extract mod strings using existing scripts, translate them, add translated strings to po files and compile updated files to mo.

ZhilkinSerg commented 4 years ago

Duplicate of https://github.com/CleverRaven/Cataclysm-DDA/issues/25566

CountAlex commented 4 years ago

@linonetwo I think there's a solution. Create your own Transifex project for mod, use Python script for strings extraction on mod folder, upload that as a file to your project, then just get translated results and merge them with the right language file.

linonetwo commented 3 years ago

It is already possible: extract mod strings using existing scripts, translate them, add translated strings to po files and compile updated files to mo.

Does this mean, every user of a mod has to compile things by themself? This is beyond most of the players, even is hard for programmers like me, I'm not familiar with this.

I hope mode can provide a po file, and CDDA just does compile in the background, so mod providers just don't need to provide a mo file for every end-user. Or every user doesn't need to learn how to compile mo file just to install a new mod.

linonetwo commented 3 years ago

Or just let us use a mod to patch other mods, so end-users don't need to learn about mo and po, they can just install mod and translate mod.

ZhilkinSerg commented 3 years ago

Does this mean, every user of a mod has to compile things by themself? This is beyond most of the players, even is hard for programmers like me, I'm not familiar with this.

They will only need to compile mo file with translation.

ZhilkinSerg commented 3 years ago

I hope mode can provide a po file, and CDDA just does compile in the background, so mod providers just don't need to provide a mo file for every end-user. Or every user doesn't need to learn how to compile mo file just to install a new mod.

CDDA binary does not have any possibility to compile mo file. While it is possible to add some code to CDDA, so it could run the tool that compiles mo files (or maybe add a script to distribution that runs the tool) it makes very little sense - end user would still need to have necessary tools installed on their end and while user installs these tools - they can also just install the script.

linonetwo commented 3 years ago

Hope install mod can just be drag-and-drop (or even better, like steam, in a click), no code, no cli, no need for running any additional program.

If this is not achievable, as an alternative, can I compile my translation to mo file once, and share that mo file to the end-user? And end-user can have 2-3 translated 3rd-party mod, can they mix 2-3 mo file, (with the main mo file from CDDA), without running any program?

ZhilkinSerg commented 3 years ago

CDDA mod is just a bunch of files and folder which you copy to a designated location so it is already drag-and-drop (depending on your OS).

There is launcher though that allows mod installation in one click - https://github.com/remyroy/CDDA-Game-Launcher/.

There are some mod collections on Github: https://github.com/TheGoatGod/Goats-Mod-Compilation, https://github.com/Szara-ManOfHonor/CDDA-Mods, https://github.com/roaringjohn/CDDA-Mods.

And there is a mod registry spec: https://github.com/cataclysm-mods/registry.

Integrating any network functions into current CDDA fork would probably never happen, but someone should take all these things above and combine them into a fancy mod distribution system, so somebody would add its support into existing (or new) launcher.

P.S.: As for Steam: CDDA is not there yet, but I am waiting someone would add Steam integration and publish game on Steam.

BrettDong commented 3 years ago

As for now I haven't thought of any quick and easy way to load multiple .mo files without making some major overhauls to the infrastructure. Technically sure you can merge your mod translation with the translations of core game content on your machine and compile them to a single .mo file to distribute to end-users, the problem is that as core game content changes, the core game part in your .mo file will become outdated, so probably you need to periodically update your .mo and send them to end-users to keep up with the latest experimental versions.

linonetwo commented 3 years ago

So many 3rd party mods, hope one day they can all have their own translated version...

I finally decided to create a separate mod, and use my own translate script https://github.com/linonetwo/cdda-arcana-mod-chinese/blob/42173df420a60b79f376693756b9b363f867e484/%E7%BF%BB%E8%AF%91.js#L316-L350

I think currently, use a convenient script to generate a translated version of the mod is the easiest way, both for the translator and end-user.