Raised This Month: $ Target: $400
 0% 

Question about Translations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bigbuck
Senior Member
Join Date: Jul 2009
Old 12-12-2009 , 15:10   Question about Translations
Reply With Quote #1

Is it possible to either reverse translate or find what translation phrase a string used when it was translated? I will try to explain what I am doing with an example.

PHP Code:
"L_LAST_STAND"
{
    
"L_LAST_STAND_LIGHTHOUSE"
    
{
        
"file"    "l4d_sv_lighthouse"
    
}

L_LAST_STAND is a translation string and an option. It is translated before being shown to the user via a menu. For the sake of the example I'm going to say the user selected this option which would be shown to the client as Last Stand. Now I take that value and use it to search KeyValues in order to get L_LAST_STAND_LIGHTHOUSE. The problem is since L_LAST_STAND was already translated as Last Stand, the KeyValues won't be able to find it so I need to somehow get it back to how it was before it was translated. I hope that makes sense. Maybe there is a better way to do the whole thing. but I haven't come up with one yet.
Bigbuck is offline
Bigbuck
Senior Member
Join Date: Jul 2009
Old 12-13-2009 , 14:39   Re: Question about Translations
Reply With Quote #2

Anyone have an idea or comment?
Bigbuck is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 12-13-2009 , 18:52   Re: Question about Translations
Reply With Quote #3

if i understand correctly. you could pass the original string through the info string of your menu item. then in the handler, use GetMenuItem to retrieve it before searching your keyvalues.
PHP Code:
decl String:MenuItem[64];
Format(MenuItemsizeof(MenuItem), "%t""L_LAST_STAND");
AddMenuItem(YourMenu"L_LAST_STAND"MenuItem);

// in handler
decl String:info[64]; keyvalue[64];
GetMenuItem(YourMenuparam2infosizeof(info));
KvGetString(YourKVinfokeyvaluesizeof(keyvalue); 
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
Bigbuck
Senior Member
Join Date: Jul 2009
Old 12-13-2009 , 18:56   Re: Question about Translations
Reply With Quote #4

First I find the key values like this.

PHP Code:
LoadCampaignValues(HandlekvHandlecampaign_handle)
{
    
decl Stringcampaign_name[64];
    do
    {
        
// First get the section name
        
KvGetSectionName(kvcampaign_namesizeof(campaign_name));
        
// If it needs to be translated, do so
        
if (StrContains(campaign_name"L_"true) != -1)
        {
            
Format(campaign_namesizeof(campaign_name), "%T"campaign_nameLANG_SERVER);
        }
        
AddMenuItem(campaign_handlecampaign_namecampaign_name);
    } while (
KvGotoNextKey(kv));

Then in the handler I have this.

PHP Code:
// Get the chosen campaign name
GetMenuItem(CampaignMenupositioncampaign_selectedsizeof(campaign_selected)); 
I have campaign_selected be a global string so I can use it in both functions.

The biggest problem is trying to keep it dynamic. It would be fairly easy if I was dealing with a set amount of values.
Bigbuck is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 12-13-2009 , 19:09   Re: Question about Translations
Reply With Quote #5

PHP Code:
LoadCampaignValues(HandlekvHandlecampaign_handle)
{
    
decl String:campaign_name[64], String:campaign_name_trans[64];
    do
    {
        
// First get the section name
        
KvGetSectionName(kvcampaign_namesizeof(campaign_name));
        
// If it needs to be translated, do so
        
if (StrContains(campaign_name"L_"true) != -1)
        {
            
Format(campaign_name_transsizeof(campaign_name_trans), "%T"campaign_nameLANG_SERVER);
            
AddMenuItem(campaign_handlecampaign_namecampaign_name_trans);
        }
        else
            
AddMenuItem(campaign_handlecampaign_namecampaign_name);
    } while (
KvGotoNextKey(kv));

__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
Bigbuck
Senior Member
Join Date: Jul 2009
Old 12-13-2009 , 23:39   Re: Question about Translations
Reply With Quote #6

Ahh I understand now, thank you. I had thought that GetMenuItem retrieved the name not the info string. Makes it much easier now .
Bigbuck 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 22:17.


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