SSS Translate

SSS Translate

Mod

A library to add Crowdin Internationalization to your mods

Client LibraryUtility

11 downloads
0 followers
Created8 days ago
Updated5 days ago

Follow Save
Host your Minecraft server on BisectHosting - get 25% off your first month with code MODRINTH.

SSS Translate - a library to add Crowdin Internationalization to your mods

This is a continuation of CrowdinTranslate by GBL for Minecraft versions 1.21 and above.

SSS Translate is a library that's intended to make Internationalization as easy as possible in your mods. The project provides:

  • A main program which you can use to easily download translations from CrowdIn, and distribute these translations to the correct file names in the correct folder

  • A gradle plugin to automate getting translations from your build process

  • A Fabric library mod which you can be an optional dependency or bundled in your own mods which downloads updated translations, and makes them available in a resource pack, to your users, so you don't have to publish a new version of your mod, and people don't need to re-download, when new translations appear

Getting started

Create a CrowdIn project, (if possible, use the same project name as your mod id). Upload your en_us.json, get it translated, build the project. More detailed info below.

You can view available versions in the package registry.

If you're having trouble you can contact me on discord.

Manual usage:

Run java -jar sss_translate_base-<version>.jar <projectname> from the main mod directory to download translations and distribute them to src/main/resources/assets/<projectname>/lang/.

If you weren't able to use your modid for your crowdin project, run java -jar crowdintranslate-<version>.jar <projectname> <modid> instead.

Automatic usage:

In your settings.gradle, add this:

pluginManagement {
    repositories {
        maven {
            name = "SSS Translate"
            url = "https://gitlab.com/api/v4/projects/59105494/packages/maven"
        }
    }
}

Then in build.gradle add:

plugins {
    id 'net.sssubtlety.sss_translate' version '<version>'
}

sssTranslate {
    crowdinProjectName = '<modid>'
    minecraftProjectName = '<modid>'
    verbose = false
}

You can omit the minecraftProjectName if the ids are the same, and you can set verbose to true to see more about what's happening in the build process.

This will give you a new gradle task: gradle downloadSourceTranslations fetches all translations to your src/main/resources/assets/<modid>/lang directory.

To do this automatically when you build the project, add something like this to the end of your build.gradle:

build {
    dependsOn downloadSourceTranslations
}

Have your mod automatically check for new translations

That way your users can get new translations automatically, without you re-publishing your mod, and them having to re-download it.

Add this to your build.gradle:

repositories {
	maven {
		url = "https://gitlab.com/api/v4/projects/59105494/packages/maven"
	}
}
dependencies {
    modImplementation "net.sssubtlety.sss_translate:mod:<version>"
    // include the line below ONLY if you want to bundle the library
    include "net.sssubtlety.sss_translate:mod:<version>"
}

SSS Translate adds a new way to use it at runtime: a custom fabric.mod.json field.
This is the preferred method because you needn't interact with SSS Translate through java at all, so it can be an optional dependency. You can still bundle it if you prefer.

The custom FMJ field has several forms:

  • use your mod id for Crowdin and Minecraft project names
"custom": {
    "sss_translate": true
}
  • use the string value for Crowdin and Minecraft project names
"custom": {
    "sss_translate": "some-mod"
}
  • specify the params for CrowdinTranslate#downloadRuntimeTranslations(String crowdinProjectName, String minecraftProjectName, String sourceFileOverride, boolean verbose); sourceFileOverride, and verbose are optional
"custom": {
    "sss_translate": {
        "crowdin_project_name": "some-other-mod",
        "minecraft_project_name": "some_other_mod",
        "source_file_override": "thing.json",
        "verbose": true
    }
}

You can instead use SSS Translate in your ClientModInitializer like before (don't this if you're already using the custom FMJ field):

SssTranslate.downloadRuntimeTranslations("modid");

for example

public class MyModClass implements ClientModInitializer 
{
    static public final String MODID="modid";
    @Override
    public void onInitializeClient() {
        SssTranslate.downloadRuntimeTranslations(MODID);
    }
}

If your CrowdIn project name does not match your Minecraft Mod ID, you need to use the two parameter form with CrowdIn name first, and mod id second:

SssTranslate.downloadRuntimeTranslations("projectname", "modid");

This will download the translations from https://crowdin.com/project/projectname to assets/modid/lang.

What if I have the translation files for several mods in the same crowdin project?

Since version 1.3, you can override the translation source name that crowdin-translate checks for. So, if your mods are named foo, bar, and baz, you can have one single crowdin project that has them all, and have file names foo.json, bar.json and thisisnotbaz.json for your source.

Assuming your crowdin project name is allmymods, adjust the above use cases like this:

  • manual usage:
java -jar sss_translate_base-<version>.jar allmymods foo foo
java -jar sss_translate_base-<version>.jar allmymods bar bar
java -jar sss_translate_base-<version>.jar allmymods baz thisisnotbaz
  • usage in gradle: add a 'jsonSourceName' parameter
sssTranslate.jsonSourceName = 'thisisnotbaz'
  • usage in your ClientModInitializer: use the 3 argument call:
SssTranslate.downloadRuntimeTranslations("allmymods", "baz", "thisisnotbaz");

Project members

supersaiyansubtlety

Member


Technical information

License
MIT
Client side
required
Server side
unsupported
Project ID