Raised This Month: $32 Target: $400
 8% 

Solved Attaching a translation file to a vote menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-11-2017 , 02:52   Attaching a translation file to a vote menu
Reply With Quote #1

Hey guys, can anyone help me add a translation file to this? I want the menu title and options to be translatable but I don't know the proper format for attaching a translation file to these lines.

PHP Code:
public Action Command_Warp(int clientint args)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_teleport_enable.BoolValue || !l4d_ass_teleport_vote.BoolValue || l4d_ass_teleport_auto.BoolValue || NumTanks3)
        return;
    if(!
l4d_ass_teleport_tank.BoolValue)
        
CountTanks();
    if(
l4d_ass_teleport_vote.BoolValue)
    {
        
char cmEntry[8];
        
Menu chooseMenu CreateMenu(chooseMenuHandler2);
        
SetVoteResultCallback(chooseMenuchooseMenuResults2);
        
chooseMenu.SetTitle("Teleport speedrunners?");
        
IntToString(0cmEntrysizeof(cmEntry));
        
chooseMenu.AddItem(cmEntry"Yes");
        
IntToString(1cmEntrysizeof(cmEntry));
        
chooseMenu.AddItem(cmEntry"No");
        
SetMenuPagination(chooseMenuMENU_NO_PAGINATION);
        
int totalHumanshumanPlayers[MAXPLAYERS+1];
        for(
int i 1<= MaxClientsi++)
        {
            if(!
IsValidClient(i))
                continue;
            
humanPlayers[totalHumans++] = i;
        }

        
VoteMenu(chooseMenuhumanPlayerstotalHumans30);
    }

I tried this but it didn't work:

PHP Code:
        chooseMenu.SetTitle("%T""TeleportSpeedrunners");
        
chooseMenu.AddItem(cmEntry"%T""YesOption");
        
chooseMenu.AddItem(cmEntry"%T""NoOption"); 
__________________

Last edited by Psyk0tik; 12-11-2017 at 05:42. Reason: Marked as [Solved]
Psyk0tik is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-11-2017 , 05:05   Re: Attaching a translation file to a vote menu
Reply With Quote #2

Not tested

PHP Code:
        char buffer[64];
        
Format(buffersizeof(buffer), "%T""TeleportSpeedrunners");
        
chooseMenu.SetTitle(buffer); 
        
Format(buffersizeof(buffer), "%T""YesOption");
        
chooseMenu.AddItem(cmEntry"Yes"buffer);
        
Format(buffersizeof(buffer), "%T""NoOption");
        
chooseMenu.AddItem(cmEntry"No"buffer); 
__________________
8guawong is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-11-2017 , 05:16   Re: Attaching a translation file to a vote menu
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
Not tested

PHP Code:
        char buffer[64];
        
Format(buffersizeof(buffer), "%T""TeleportSpeedrunners");
        
chooseMenu.SetTitle(buffer); 
        
Format(buffersizeof(buffer), "%T""YesOption");
        
chooseMenu.AddItem(cmEntry"Yes"buffer);
        
Format(buffersizeof(buffer), "%T""NoOption");
        
chooseMenu.AddItem(cmEntry"No"buffer); 
The compiler says that these lines have an "argument type mismatch (argument 4)"

PHP Code:
        chooseMenu.AddItem(cmEntry"Yes"buffer);
        
chooseMenu.AddItem(cmEntry"No"buffer); 
This is how I implemented your code:

PHP Code:
        char buffer[64], cmEntry[8];
        
Menu chooseMenu CreateMenu(chooseMenuHandler2);
        
SetVoteResultCallback(chooseMenuchooseMenuResults2);
        
Format(buffersizeof(buffer), "%T""TeleportSpeedrunners");
        
chooseMenu.SetTitle(buffer); 
        
Format(buffersizeof(buffer), "%T""YesOption");
        
chooseMenu.AddItem(cmEntry"Yes"buffer);
        
Format(buffersizeof(buffer), "%T""NoOption");
        
chooseMenu.AddItem(cmEntry"No"buffer);  
        
SetMenuPagination(chooseMenuMENU_NO_PAGINATION);
        
int totalHumanshumanPlayers[MAXPLAYERS+1]; 
__________________
Psyk0tik is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-11-2017 , 05:19   Re: Attaching a translation file to a vote menu
Reply With Quote #4

not used to new syntax XD
below should work

PHP Code:
        chooseMenu.AddItem("Yes"buffer); 
        
chooseMenu.AddItem("No"buffer); 
__________________

Last edited by 8guawong; 12-11-2017 at 05:20.
8guawong is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-11-2017 , 05:30   Re: Attaching a translation file to a vote menu
Reply With Quote #5

Quote:
Originally Posted by 8guawong View Post
not used to new syntax XD
below should work

PHP Code:
        chooseMenu.AddItem("Yes"buffer); 
        
chooseMenu.AddItem("No"buffer); 
It compiles now, but in-game it gives errors saying that these are incorrectly formatted:

PHP Code:
        Format(buffersizeof(buffer), "%T""TeleportSpeedrunners");
        
Format(buffersizeof(buffer), "%T""YesOption");
        
Format(buffersizeof(buffer), "%T""NoOption"); 
__________________
Psyk0tik is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-11-2017 , 05:33   Re: Attaching a translation file to a vote menu
Reply With Quote #6

use %t
__________________
8guawong is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-11-2017 , 05:41   Re: Attaching a translation file to a vote menu
Reply With Quote #7

Quote:
Originally Posted by 8guawong View Post
use %t
I was able to make it work:

PHP Code:
public Action Command_Warp(int clientint args)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_teleport_enable.BoolValue || !l4d_ass_teleport_vote.BoolValue || l4d_ass_teleport_auto.BoolValue || NumTanks3)
        return;
    if(!
l4d_ass_teleport_tank.BoolValue)
        
CountTanks();
    if(
l4d_ass_teleport_vote.BoolValue)
    {
        
char buffer[64];
        
int totalHumanshumanPlayers[MAXPLAYERS+1];
        for(
int i 1<= MaxClientsi++)
        {
            if(!
IsValidClient(i))
                continue;
            
humanPlayers[totalHumans++] = i;
        }

        for(
int i 1<= MaxClientsi++)
        {
            if(
IsValidClient(i))
            {
                
Menu chooseMenu CreateMenu(chooseMenuHandler2);
                
SetVoteResultCallback(chooseMenuchooseMenuResults2);
                
Format(buffersizeof(buffer), "%T""TeleportSpeedrunners"i);
                
chooseMenu.SetTitle(buffer); 
                
Format(buffersizeof(buffer), "%T""YesOption"i);
                
chooseMenu.AddItem("Yes"buffer);
                
Format(buffersizeof(buffer), "%T""NoOption"i);
                
chooseMenu.AddItem("No"buffer); 
                
SetMenuPagination(chooseMenuMENU_NO_PAGINATION);
                
VoteMenu(chooseMenuhumanPlayerstotalHumans30);
            }
        }
    }

Thank you for your help!
__________________
Psyk0tik is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-11-2017 , 13:55   Re: Attaching a translation file to a vote menu
Reply With Quote #8

For menu translations, you can just create the menu once, then...
  • use the MenuAction_Display callback to translate the menu title using Format / SetPanelTitle.
  • use the MenuAction_DisplayItem callback to translate menu items using Format / RedrawMenuItem.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 12-11-2017 at 13:57.
Powerlord is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-11-2017 , 16:44   Re: Attaching a translation file to a vote menu
Reply With Quote #9

Quote:
Originally Posted by Crasher_3637 View Post
I was able to make it work:

PHP Code:
public Action Command_Warp(int clientint args)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_teleport_enable.BoolValue || !l4d_ass_teleport_vote.BoolValue || l4d_ass_teleport_auto.BoolValue || NumTanks3)
        return;
    if(!
l4d_ass_teleport_tank.BoolValue)
        
CountTanks();
    if(
l4d_ass_teleport_vote.BoolValue)
    {
        
char buffer[64];
        
int totalHumanshumanPlayers[MAXPLAYERS+1];
        for(
int i 1<= MaxClientsi++)
        {
            if(!
IsValidClient(i))
                continue;
            
humanPlayers[totalHumans++] = i;
        }

        for(
int i 1<= MaxClientsi++)
        {
            if(
IsValidClient(i))
            {
                
Menu chooseMenu CreateMenu(chooseMenuHandler2);
                
SetVoteResultCallback(chooseMenuchooseMenuResults2);
                
Format(buffersizeof(buffer), "%T""TeleportSpeedrunners"i);
                
chooseMenu.SetTitle(buffer); 
                
Format(buffersizeof(buffer), "%T""YesOption"i);
                
chooseMenu.AddItem("Yes"buffer);
                
Format(buffersizeof(buffer), "%T""NoOption"i);
                
chooseMenu.AddItem("No"buffer); 
                
SetMenuPagination(chooseMenuMENU_NO_PAGINATION);
                
VoteMenu(chooseMenuhumanPlayerstotalHumans30);
            }
        }
    }

Thank you for your help!
Here's what I believe is a cleaner version of your code:

PHP Code:
public Action Command_Warp(int clientint args)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_teleport_enable.BoolValue || !l4d_ass_teleport_vote.BoolValue || l4d_ass_teleport_auto.BoolValue || NumTanks3)
        return;
    if(!
l4d_ass_teleport_tank.BoolValue)
        
CountTanks();
    if(
l4d_ass_teleport_vote.BoolValue)
    {
        
char buffer[64];
        
int totalHumanshumanPlayers[MAXPLAYERS+1];
        for(
int i 1<= MaxClientsi++)
        {
            if(!
IsValidClient(i))
                continue;
            
humanPlayers[totalHumans++] = i;
        }

        for(
int i 1<= MaxClientsi++)
        {
            if(
IsValidClient(i))
            {
                
Menu chooseMenu CreateMenu(chooseMenuHandler2);
                
SetVoteResultCallback(chooseMenuchooseMenuResults2);

                
SetGlobalTransTarget(i); // Set translation target for "%t" translation format specifier.

                
Format(buffersizeof(buffer), "%t""TeleportSpeedrunners");
                
chooseMenu.SetTitle(buffer); 
                
Format(buffersizeof(buffer), "%t""YesOption");
                
chooseMenu.AddItem("Yes"buffer);
                
Format(buffersizeof(buffer), "%t""NoOption");
                
chooseMenu.AddItem("No"buffer); 

                
SetMenuPagination(chooseMenuMENU_NO_PAGINATION);
                
VoteMenu(chooseMenuhumanPlayerstotalHumans30);
            }
        }
        
SetGlobalTransTarget(LANG_SERVER); // If this fails compile, replace it with client #0
    
}

__________________

Last edited by WildCard65; 12-11-2017 at 16:44.
WildCard65 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode