View Single Post
Author Message
MsDysphie
AlliedModders Donor
Join Date: Dec 2017
Old 07-27-2021 , 22:11   [ANY] Map Translator (Multilingual map texts)
Reply With Quote #1



Map Translator

Translates map texts via translation files, allowing players to see messages in their preferred language.


The following texts are supported:

- [ANY] game_text
- [ANY] env_hudhint
- [ZPS] Objective text
- [NMRiH] Objective text
- [NMRiH] point_message_multiplayer
- [TF2] game_text_tf

Installation

- Install Sourcemod 1.11.6924 or higher.
- Grab the latest release ZIP and extract to `addons/sourcemod`.
- Refresh your plugins (`sm plugins refresh` in server console)

Usage

- Navigate to `cfg/sourcemod` and open `plugin.map-translator.cfg`
Note: it's `plugin.nmrih-map-translator.cfg` in NMRiH for backward compatibility

- Set `mt_autolearn_langs` to a space-separated list of language codes you wish to generate translations for.

PHP Code:
// Example for English, Spanish and Korean
mt_autolearn_langs "en es ko" 
Note: You can see the full list of language codes at `addons/sourcemod/configs/languages.cfg`


- The plugin will now create translation files for maps as they're loaded.
They're stored in `addons/sourcemod/translations/_maps`

PHP Code:
"Phrases"
{
    
"edf566344eb9f2cb892e073e70c70181"
    
{
        
"en"        "Destroy the puppet"
        "es"        "Destroy the puppet"
        "ko"        "Destroy the puppet"
    
}

You can then edit these files to change the message printed for each language.

PHP Code:
"Phrases"
{
    
"edf566344eb9f2cb892e073e70c70181"
    
{
        
"en"        "Get rid of the puppet"
        "es"        "Destruye la marioneta"
        "ko"        "인형을 파괴해"
    
}


Admin Commands

PHP Code:
// Learns objective messages for every map without loading them in
mt_bulk_learn_nmo

// Forces your client language to the given language code. Useful for debugging
mt_forcelang <code>

// Only available in NMRiH, learns all .nmo files at once without having to load the maps in
mt_bulk_learn_nmo

// Forces the plugin to export all pending translations instead of waiting for a map change
mt_force_export 

CVars

CVars are read from `cfg/sourcemod/plugin.map-translator.cfg`

PHP Code:
// Don't translate or learn fully numerical messages such as codes, countdowns, etc. (Default: 1)
mt_ignore_numerical 1

// Space-separated list of language entries to include in auto generated translation files, for example: en es ko (Default: en)
mt_autolearn_langs "en es ko"

// Clients whose language is not translated will see messages in this language (Default: en)
mt_fallback_lang "en"

// Whether the game will learn text entities that have been modified during gameplay. This can improve detection on maps with VScript, but it can also increase memory usage and the size of the generated translation file (Default: 0)
mt_extended_learning 0 
Notes

- You must escape quotes with a backslash (`\`) to prevent parsing errors.

PHP Code:
    // Example 
    
"en" "Destroy \"Robert\" the puppet" 
- This plugin is incompatible with Multilingual Objectives and Multilingual Objective Beta.
- You are not expected to manually add new entries, only edit existing — if a specific text is not getting picked up, please create an issue.
However, nothing will break if you do, the section name (e.g. `edf566344eb9f2cb892e073e70c70181`) is just an MD5 hash of the original text.

Full info: https://github.com/dysphie/sm-map-translator#readme
Download: https://github.com/dysphie/sm-map-translator/releases
Source code: https://github.com/dysphie/sm-map-translator
__________________
Discord: @dysphie
Donations: ko-fi.com/dysphie

Last edited by MsDysphie; 08-26-2023 at 22:22.
MsDysphie is offline