Raised This Month: $51 Target: $400
 12% 

Help - Wrong %T syntax?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jonaslissner
Junior Member
Join Date: Jun 2014
Old 12-02-2019 , 06:05   Help - Wrong %T syntax?
Reply With Quote #1

Need help for the translation %T syntax, I tried translating a really simple script I wrote.
As far as I've understood: "%T" starts the translation, and it needs to be followed by 2 arguments: a string (with the correct word) followed by a variablename for the translation??

e.g.:
Code:
PrintToChat(client, "\x02ğ \x10"."%T", "[JML]", JML."-"."%T", "Helpful Commands", HelpfulCommands.":");
I were expecting to get these translation sets;
1. "[JML]" named JML
2. "Helpful Commands" named HelpfulCommands
But all I get is fatal errors, not really helping.

Any help is really appreciated, thanks.
jonaslissner is offline
Chrissy
Member
Join Date: May 2013
Old 12-02-2019 , 07:11   Re: Help - Wrong %T syntax?
Reply With Quote #2

What am I looking at?

You pass the name of the translation for %T and that's it. Why have you got so many parameters?

Code:
PrintToChat(client, "\x02ğ \x10 %T", "Helpful Commands");

Last edited by Chrissy; 12-02-2019 at 07:12.
Chrissy is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-02-2019 , 11:36   Re: Help - Wrong %T syntax?
Reply With Quote #3

Quote:
Originally Posted by Chrissy View Post
What am I looking at?

You pass the name of the translation for %T and that's it. Why have you got so many parameters?

Code:
PrintToChat(client, "\x02ğ \x10 %T", "Helpful Commands");
%T requires the client as a parameter:
Example:
PHP Code:
PrintToChat(client"%T""Helpful Commands"client); 
%T is for Format() function to specify the language of the client. PrintToChat already handles that, so you can use %t in it.

Example:
PHP Code:
PrintToChat(client"%t""Helpful Commands"); 
__________________

Last edited by Ilusion9; 12-02-2019 at 12:53.
Ilusion9 is offline
NomisCZ
AlliedModders Donor
Join Date: Mar 2014
Location: Czech_Republic
Old 12-02-2019 , 12:21   Re: Help - Wrong %T syntax?
Reply With Quote #4

If you want to use %T, don't forget to client parameter. You can also use %t, but then the translation is not client scoped (client language preference).

https://wiki.alliedmods.net/Translat...eMod_Scripting)

PHP Code:
PrintToChat(client"[YourPortal] %T""Language Set Force"client); 
translations/my_plugin.phrases.txt
PHP Code:
"Phrases"
{
    
"Menu Title"
    
{
        
"en"            "≡ Language settings \nŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\n"
    
}
    
"Language Set Info"
    
{
        
"#format"        "{1:s}" // File Format - https://wiki.alliedmods.net/Translations_(SourceMod_Scripting)
        
"en"            "› Your language has been automatically set to {1}. To change your language type !lang / !language"
    
}
    
"Language Set Force"
    
{
        
"en"            "You can't change language on this server."
    
}
    
"en"
    
{
        
"en"            "English"
    
}
    
"cze"
    
{
        
"en"            "Czech"
    
}    

my_plugin.sp

PHP Code:
#include <sourcemod>

#define PLUGIN_PREFIX "[MyPlugin]"

#pragma semicolon 1
#pragma newdecls required

char g_sLanguagePref[MAXPLAYERS+1][4];

public 
Plugin myinfo = {
...
}

public 
void OnPluginStart()
{
    
LoadTranslations("my_plugin.phrases");
}

public 
void MyFunction(int client)
{
    
// Basic example - client language preference
    // Result: [MyPlugin] You can't change language on this server.
    
PrintToChat(client"%s %T"PLUGIN_PREFIX"Language Set Force"client);

    
// Or "auto" language preference
    // Sometimes it can cause problems with incorrect translation according to client preference (multicolors include).
    
PrintToChat(client"%s %t"PLUGIN_PREFIX"Language Set Force");

    
// Format example
    // Dynamic translation format depending on the value of the variable
    
char translationString[32];
    
// g_sLanguagePref[client] is "cze" or "en"
    // Result: "Czech" or "English"
    
Format(translationStringsizeof(translationString), "%T"g_sLanguagePref[client], client);

    
// PrintToChat with format {1:s}
    // Phrase also contains one parameter in itself "#format" "{1:s}", so next parameter after client is string - translationString
    // Result: "[MyPlugin] › Your language has been automatically set to Czech/English. To change your language type !lang / !language"
    
PrintToChat(client"%s %T"PLUGIN_PREFIX"Language Set Info"clienttranslationString);

    
// Or "auto" language preference
    
PrintToChat(client"%s %t"PLUGIN_PREFIX"Language Set Info"translationString);

__________________

Last edited by NomisCZ; 12-02-2019 at 12:22.
NomisCZ is offline
jonaslissner
Junior Member
Join Date: Jun 2014
Old 12-03-2019 , 09:32   Re: Help - Wrong %T syntax?
Reply With Quote #5

Quote:
Originally Posted by Chrissy View Post
What am I looking at?

You pass the name of the translation for %T and that's it. Why have you got so many parameters?

Code:
PrintToChat(client, "\x02ğ \x10 %T", "Helpful Commands");
Because I used so many colorcodes everywhere. I thought by seperating it And didn't think commands, phrases and colorcodes

PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo 
{
    
name "Helpful Commands"
    
author "Denaegte"
    
description "Server command robot"
    
version "1.1"
    
url "https://forums.alliedmods.net/member.php?u=250706"
};

public 
void OnPluginStart()
{
    
LoadTranslations("helpful.phrases");
    
RegConsoleCmd("sm_commands"helpful_Commands);
    
RegConsoleCmd("sm_kommando"helpful_Commands);
    
RegConsoleCmd("sm_helpful"helpful_Commands);
    
RegConsoleCmd("sm_hjĉlp"helpful_Commands);
    
RegConsoleCmd("sm_cheat"helpful_Cheat);
    
RegConsoleCmd("sm_cheats"helpful_Cheat);
    
RegConsoleCmd("sm_anticheat"helpful_Cheat);
    
RegConsoleCmd("sm_website"helpful_Website);
    
RegConsoleCmd("sm_ladder"helpful_Website);
    
RegConsoleCmd("sm_report"helpful_Report);
    
RegConsoleCmd("sm_rapport"helpful_Report);
}

// Commmands
public Action helpful_Commands(int clientint args)
{
    
PrintToChat(client"_______________________________________________________________________________________________________________________");
    
PrintToChat(client"\x02ğ \x10"."%T""[JML]" JML."-"."%T""Helpful Commands"HelpfulCommands.":");
    
PrintToChat(client"\x01 1v1"."%T""Preferences"Preferences.": \x02!guns\x01,"."%T""manage voice rooms"ManageVoiceRooms.": \x02!vr\x01,""%T""anti-cheat info"AntiCheatInfo.": \x02!cheat\x01.");
    
PrintToChat(client"\x01"."%T""View your rank"ViewYourRank.": \x02!rank\x01,"."%T""list of top players"ListOfTopPlayers.": \x02!top\x01,"."%T""reset your rank"ResetYourRank.": \x02!resetrank\x01.");
    
PrintToChat(client"\x01"."%T""Skin changer"SkinChanger.": \x02!ws\x01,"."%T""knife changer"KnifeChanger.": \x02!knife\x01,"."%T""glove changer"GloveChanger": \x02!gloves\x01.");
    
PrintToChat(client"\x01"."%T""Challenge someone"ChallengeSomeone.": \x02!chall\x01,"."%T""reset your score".": \x02!rs\x01, %T""report a player"": \x02!report\x01.");
    
PrintToChat(client"\x01...\x08"."%T""you can use"YouCanUse."\x0B '/' \x08"."%T""instead of", InsteadOf."\x0B '!' \x08"."%T""to hide your commands"ToHideYourCommands."!");
    
PrintToChat(client"_______________________________________________________________________________________________________________________");
}

// Anti-cheat
public Action helpful_Cheat(int clientint args)
{
    
PrintToChat(client"\x01ğ \x10"."%T""[JML]"JML"\x01 - ""%T""This server is closely being monitored by"ThisServerIsCloselyBeingMonitoredBy"\x04 "."%T""SMAC"Smac"\x01 and \x04"."%T""SourceBans"SourceBans."\x01.");
}

// Spillerrapportering
public Action helpful_Report(int clientint args)
{
    
PrintToChat(client"\x01ğ \x10[JML] \x0BSpillerrapporteringer indgives her: \x04jml.lissner.dk/forum");
}

// Website
public Action helpful_Website(int clientint args)
{
    
PrintToChat(client"\x01ğ \x10"."%T""[JML]"JML"\x01 - \x08"."%T"" Join the family "JoinOurFamily" @ "."\x0Bjml.lissner.dk/forum");
    
PrintToChat(client"> "."T%""Where the forum, among other things, open up for options like:"WhereTheForum);
    
PrintToChat(client"> "."T%""Expanded leaderboards, clan/team search, map requests, reports, server polls, ideas, application forms and much more."LeaderboardsForumsExpansion);
    
PrintToChat(client"> \x0A"."T%""En komplet liste med forandringer kan tjekkes her"CompleteList." -> "."\x04jml.lissner.dk/forum");

Quote:
Originally Posted by Ilusion9 View Post
%T requires the client as a parameter:
Example:
PHP Code:
PrintToChat(client"%T""Helpful Commands"client); 
%T is for Format() function to specify the language of the client. PrintToChat already handles that, so you can use %t in it.

Example:
PHP Code:
PrintToChat(client"%t""Helpful Commands"); 
So if I add client as parameter at det end of my code, it should work? Or


http://forums.alliedmods.net/attachm...1&d=1575382454



Quote:
Originally Posted by NomisCZ View Post
If you want to use %T, don't forget to client parameter. You can also use %t, but then the translation is not client scoped (client language preference).

https://wiki.alliedmods.net/Translat...eMod_Scripting)

PHP Code:
PrintToChat(client"[YourPortal] %T""Language Set Force"client); 
translations/my_plugin.phrases.txt
PHP Code:
"Phrases"
{
    
"Menu Title"
    
{
        
"en"            "≡ Language settings \nŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\n"
    
}
    
"Language Set Info"
    
{
        
"#format"        "{1:s}" // File Format - https://wiki.alliedmods.net/Translations_(SourceMod_Scripting)
        
"en"            "› Your language has been automatically set to {1}. To change your language type !lang / !language"
    
}
    
"Language Set Force"
    
{
        
"en"            "You can't change language on this server."
    
}
    
"en"
    
{
        
"en"            "English"
    
}
    
"cze"
    
{
        
"en"            "Czech"
    
}    

my_plugin.sp

PHP Code:
#include <sourcemod>

#define PLUGIN_PREFIX "[MyPlugin]"

#pragma semicolon 1
#pragma newdecls required

char g_sLanguagePref[MAXPLAYERS+1][4];

public 
Plugin myinfo = {
...
}

public 
void OnPluginStart()
{
    
LoadTranslations("my_plugin.phrases");
}

public 
void MyFunction(int client)
{
    
// Basic example - client language preference
    // Result: [MyPlugin] You can't change language on this server.
    
PrintToChat(client"%s %T"PLUGIN_PREFIX"Language Set Force"client);

    
// Or "auto" language preference
    // Sometimes it can cause problems with incorrect translation according to client preference (multicolors include).
    
PrintToChat(client"%s %t"PLUGIN_PREFIX"Language Set Force");

    
// Format example
    // Dynamic translation format depending on the value of the variable
    
char translationString[32];
    
// g_sLanguagePref[client] is "cze" or "en"
    // Result: "Czech" or "English"
    
Format(translationStringsizeof(translationString), "%T"g_sLanguagePref[client], client);

    
// PrintToChat with format {1:s}
    // Phrase also contains one parameter in itself "#format" "{1:s}", so next parameter after client is string - translationString
    // Result: "[MyPlugin] › Your language has been automatically set to Czech/English. To change your language type !lang / !language"
    
PrintToChat(client"%s %T"PLUGIN_PREFIX"Language Set Info"clienttranslationString);

    
// Or "auto" language preference
    
PrintToChat(client"%s %t"PLUGIN_PREFIX"Language Set Info"translationString);

Attached Images
File Type: jpg plugin.jpg (64.9 KB, 53 views)
jonaslissner is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 12-03-2019 , 14:22   Re: Help - Wrong %T syntax?
Reply With Quote #6

As a best practise you should use the

PHP Code:
PrintToChat(client"%t""Helpful Commands"); 
I have never had a "client preference language" issue.
__________________

Last edited by Marttt; 12-03-2019 at 14:23.
Marttt is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-04-2019 , 08:59   Re: Help - Wrong %T syntax?
Reply With Quote #7

Quote:
Originally Posted by Marttt View Post
As a best practise you should use the

PHP Code:
PrintToChat(client"%t""Helpful Commands"); 
I have never had a "client preference language" issue.
PHP Code:
PrintToChat(client"%t""Helpful Commands"); 
its the same with:

PHP Code:
PrintToChat(client"%T""Helpful Commands"client); 
Both of them are using the SetGlobalTransTarget function (using the first parameter - the client) with VFormat. The only difference between %t and %T is in Format functions (Format, FormatEx) when you have to use %T and send the client as a parameter.
__________________
Ilusion9 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 12-04-2019 , 14:39   Re: Help - Wrong %T syntax?
Reply With Quote #8

Yep, they are both the same but using "%T" is easier to make mistakes.
__________________
Marttt is offline
Reply



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 04:39.


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