You are viewing a potentially older version of this package. View all versions.
JustJelly-SubtitlesAPI-0.0.6 icon

SubtitlesAPI

A centralized API for fetching localized subtitles.

Date uploaded 10 months ago
Version 0.0.6
Download link JustJelly-SubtitlesAPI-0.0.6.zip
Downloads 23408
Dependency string JustJelly-SubtitlesAPI-0.0.6

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2100 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2100

README

SubtitlesAPI

A centralized API for fetching localized subtitles.

Feedback

Got any feedback or found bugs? Please do post it in the Github Issues page!

Usage

If you are creating a mod and you want to add subtitles for any custom sounds, it's pretty simple! Add the mod .dll file to your project references, and just add the following code:

using static SubtitlesAPI.SubtitlesAPI;

try
{
  Localization.AddTranslation("CustomSound", "Custom subtitle");
}
catch
{
  Debug.Log("SubtitlesAPI Mod not Found");
}

No need to even require players to use this mod!

Methods

  • SubtitlesAPI.Localization.AddTranslation(string soundFileName, string subtitleText);
  • SubtitlesAPI.Localization.AddTranslation(Dictionary<string, string>);
    • Where Dictionary<string, string> is a dictionary with Key: soundFileName, Value: subtitleText.
  • SubtitlesAPI.Localization.AddDialogueTranslation(string sound, List<(float, string)> subtitles);
  • SubtitlesAPI.Localization.AddDialogueTranslation(Dictionary<string, List<(float, string)>> translationsToAdd);
    • Where Dictionary<string, List<(float, string)>> is a dictionary with Key: soundFileName, Value: subtitles.

The method will return a boolean, or list of booleans for the dictionary.

The result will be true if the mod was able to add the subtitle, and false if not - which is likely due to the translation for the soundFileName already being created. Maybe another mod has the same sound file name?

Contributing

Do you want to add or change any subtitles? Do you want to create a new locale for another language? Please do! Create a fork of this repo, make additions or changes there, and submit a pull request.

Additional Subtitles

Open up the locale you want to modify (ex. EnglishSubtitleLocalization.cs), and add to the dictionary!

SubtitlesAPI.Localization.Translations

The dictionary uses the following format for new entries:

{ "SoundFileName" , "Subtitle to add" },

SubtitlesAPI.Localization.DialogueTranslations

The dictionary uses the following format for new entries:

{
  "F0DaysLeftAlert",
  new()
  {
    (0, "[Company Jingle plays]"),
    (4.969f, "Report to the company building immediately"),
    (7.189f, "to sell your scrap metal and other goods."),
    (9.758f, "You have zero days left to meet the profit quota."),
    (13.085f, "You can use the terminal to route"),
    (14.874f, "the autopilot to the company building."),
  }
},

New Locales

To create new locales, just add a new file in the Locales folder, use the ISubtitleLocalization interface, change the Locale to the one being added, and add translations to the dictionary!

Example Locale

public class EnglishSubtitleLocalization : ISubtitleLocalization
{
  public string Locale => "en";

  public Dictionary<string, string> Translations => new(StringComparer.OrdinalIgnoreCase) {
    { "AirHorn1", "Air horn plays" },
  }

  public Dictionary<string, List<(float, string)>> DialogueTranslations => new(StringComparer.OrdinalIgnoreCase)
    {
      {
        "F0DaysLeftAlert",
        new()
        {
          (0, "[Company Jingle plays]"),
          (4.969f, "Report to the company building immediately"),
          (7.189f, "to sell your scrap metal and other goods."),
          (9.758f, "You have zero days left to meet the profit quota."),
          (13.085f, "You can use the terminal to route"),
          (14.874f, "the autopilot to the company building."),
        }
      },
    };
}

CHANGELOG

Changelog

0.0.6 - 2024-01-17

0.0.5 - 2023-12-10

0.0.4 - 2023-12-10

  • More subtitles for version 45

0.0.3 - 2023-12-09

  • More subtitles

0.0.2 - 2023-12-07

Added

0.0.1 - 2023-12-06

Added

  • Dialogue translations, used for transcribing the dialogue in audio clips.

0.0.0 - 2023-12-06

  • Initial commit