Mentrillum / Slender-Fortress-Modified-Versions

A modification of Team Fortress 2 based on the game Slender: The Eight Pages.
GNU General Public License v3.0
33 stars 22 forks source link

[Suggestion] Localization Improvements #18

Closed MAGNAT2645 closed 2 years ago

MAGNAT2645 commented 3 years ago

Would be good to add proper localization for each client. At least menus in SetupMenus() should be properly localized.

You can use MenuAction_Display to translate menu title and MenuAction_DisplayItem to translate menu items for specific client. It should look like this:

// in SetupMenus()
    g_hMenuMain = new Menu( Menu_Main, MENU_ACTIONS_DEFAULT | MenuAction_Display | MenuAction_DisplayItem );

public int Menu_Main(Menu menu, MenuAction action, int param1, int param2) {
    switch ( action ) {
        case MenuAction_Display: {
            char szTitle[64];
            FormatEx( szTitle, sizeof szTitle, "%T%T\n \n", "SF2 Prefix", param1, "SF2 Main Menu Title", param1 );
            ( view_as< Panel >( param2 ) ).SetTitle( szTitle );
        }
        case MenuAction_DisplayItem: {
            char szItem[128];

            switch ( param2 ) {
                case 0: FormatEx( szItem, sizeof szItem, "%T (!slhelp)",     "SF2 Help Menu Title",           param1 );
                case 1: FormatEx( szItem, sizeof szItem, "%T (!slnext)",     "SF2 Queue Menu Title",          param1 );
                case 2: FormatEx( szItem, sizeof szItem, "%T (!slgroup)",    "SF2 Group Main Menu Title",     param1 );
                case 3: FormatEx( szItem, sizeof szItem, "%T (!slghost)",    "SF2 Ghost Mode Menu Title",     param1 );
                case 4: FormatEx( szItem, sizeof szItem, "%T (!slpack)",     "SF2 Boss Pack Menu Title",      param1 );
                case 5: FormatEx( szItem, sizeof szItem, "%T (!slnextpack)", "SF2 Boss Next Pack Menu Title", param1 );
                case 6: FormatEx( szItem, sizeof szItem, "%T (!slsettings)", "SF2 Settings Menu Title",       param1 );
                case 7: strcopy( szItem, sizeof szItem, "Credits (!slcredits)" ); // we should add translation phrase to this
                case 8: FormatEx( szItem, sizeof szItem, "%T (!slbosslist)", "SF2 Boss View On List Title",   param1 );
            }

            return RedrawMenuItem( szItem );
        }
        case MenuAction_Select: {
            switch ( param2 ) {
                case 0: g_hMenuHelp.Display( param1, 30 );
                case 1: DisplayQueuePointsMenu( param1 );
                case 2: DisplayGroupMainMenuToClient( param1 );
                case 3: Command_GhostMode( param1, 0 ); // we should directly use command callback instead of FakeClientCommand
                case 4: Command_Pack( param1, 0 );      // we should directly use command callback instead of FakeClientCommand
                case 5: Command_NextPack( param1, 0 );  // we should directly use command callback instead of FakeClientCommand
                case 6: g_hMenuSettings.Display( param1, 30 );
                case 7: g_hMenuCredits.Display( param1, MENU_TIME_FOREVER );
                case 8: DisplayBossList( param1 );
            }
        }
    }

    return 0;
}

Also you should increase string size for display_text_chat (specialrounds.cfg) because Cyrillic text gets truncated in chat.

Mentrillum commented 3 years ago

So due to me having to rework the syntax for the menu items and the sheer number of them, this change minus the increased string size won't come until the following update.