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

[SOLVED] String array & translation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 04-05-2016 , 14:57   [SOLVED] String array & translation
Reply With Quote #1

Why I can use
PHP Code:
new String:sName[][] = {
"First",
"Second",
"Third",
...
"Last"
};
...
Format(Itemsizeof(Item), "%s%t"sName[i], sText); 
but can't use
PHP Code:
Format(Itemsizeof(Item), "%t%t"sName[i], sText); 
or
PHP Code:
new String:sNewString[] = sName[i];
Format(Itemsizeof(Item), "%t%t"sNewStringsText); 
or
PHP Code:
new String:sNewString[some_num]
Format(sNewStringsizeof(sNewString), "%s"sName[i]);
Format(Itemsizeof(Item), "%t%t"sNewStringsText); 

What am I doing wrong?

Solved:
PHP Code:
Format(MenuItemsizeof(MenuItem), "%T%T"sColorName[i], clientcurrPref == "(Selected)" "none"client); 
__________________

Last edited by Grey83; 04-06-2016 at 09:02.
Grey83 is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-05-2016 , 16:07   Re: [HELP] String array & translation
Reply With Quote #2

%t refers to the translation file. %s refers to the string "First", "Second", ...

A little confused on what you want. Do you want to print "First", "Second", ... or do you want to print what the translation is referenced to.
__________________
Chaosxk is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-06-2016 , 00:26   Re: [HELP] String array & translation
Reply With Quote #3

if you Format string, you need upper case %T and give client index after. Read wiki doc about formating.

https://wiki.alliedmods.net/Translat...ge_in_a_Plugin
__________________
Do not Private Message @me

Last edited by Bacardi; 04-06-2016 at 00:29.
Bacardi is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 04-06-2016 , 04:04  
Reply With Quote #4

i need it not for players.
Bacardi, I've read this article, but the necessary information there and not found. So wrote here
I edit my plugin Laser Aim and want to reduce the amount of code in it.
You can't just use text from the array to create a menu with translation.
Spoiler
__________________

Last edited by Grey83; 04-06-2016 at 04:06.
Grey83 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-06-2016 , 08:09   Re: [HELP] String array & translation
Reply With Quote #5

..read wiki again.

PHP Code:
Format(buffersizeof(buffer), "%T""your translated phrase"client); 
PHP Code:
Format(MenuItemsizeof(MenuItem), "%T""Laser_Aim_Control"client); 
PHP Code:
Format(MenuItemsizeof(MenuItem), "%T%T""Red"clientcurrPref == "(Selected)" "none"client); 

Spoiler
__________________
Do not Private Message @me

Last edited by Bacardi; 04-06-2016 at 08:13.
Bacardi is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 04-06-2016 , 08:28   Re: [HELP] String array & translation
Reply With Quote #6

Or, if you want to translate phrase to server's language, use
PHP Code:
LANG_SERVER 
instead of a client index.
WildCard65 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 04-06-2016 , 08:59  
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
PHP Code:
Format(MenuItemsizeof(MenuItem), "%T%T""Red"clientcurrPref == "(Selected)" "none"client); 
Thanks for the help.
Now I can update the plugin.
__________________
Grey83 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 23:37.


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