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

Getting built-in (valve_*.txt) Translations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 07-21-2014 , 13:55   Getting built-in (valve_*.txt) Translations
Reply With Quote #1

Hello,

I am currently writing a plugin, which allows the player to customize his/her disconnect message.
Now, the message with the brackets is hardcoded (%N left the game (reason)) and I am looking to make it multilangual.

The best approach would be by getting the built-in translation, replacing the text in brackets and then suppressing the original message.
But, how do I get the built-in Translation?

There are several valve_*.txt ressource files (both on server&client).

Thanks in advance.
__________________
Stopped hosting servers as of November 2018, no longer active around here.

Last edited by pcmaster; 07-21-2014 at 13:57.
pcmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-21-2014 , 14:13   Re: Getting built-in (valve_*.txt) Translations
Reply With Quote #2

Last I checked, Valve doesn't do translations on the server side and instead send events or usermessages (possibly with the translation phrase as an argument). In fact, this particular printout is likely printed by clients after they receive a player_disconnect event.

Having said that, the language files are KeyValues files so, in theory you could figure out in advance which phrases you needed and cache them. That is, provided they don't need any additional information (i.e. the translation doesn't contain %s1 or such).

Slight problem: I'm not sure if the clients do anything else in response to player_disconnect, so hiding the event (by doing a pre-event hook and changing its broadcast setting) may cause issues.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 07-21-2014 , 15:24   Re: Getting built-in (valve_*.txt) Translations
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
[...]Slight problem: I'm not sure if the clients do anything else in response to player_disconnect, so hiding the event (by doing a pre-event hook and changing its broadcast setting) may cause issues.
Every successful community does that. There's no issues to be expected.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 07-21-2014 , 15:40   Re: Getting built-in (valve_*.txt) Translations
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
-snip-
Yea, I first had the idea to simply parse those files as KV's, but it's a bit complex to do (valve uses the full language name, e.g. valve_english.txt and not short codes like EN).
As far as I saw, the leave message includes two parameters: %s1 (playername) and %s2 (reason).
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-21-2014 , 15:41   Re: Getting built-in (valve_*.txt) Translations
Reply With Quote #5

Quote:
Originally Posted by Powerlord View Post
Having said that, the language files are KeyValues files so, in theory you could figure out in advance which phrases you needed and cache them.
Sure, if you want to write a KV parser that supports UTF-16 and conditionals.
__________________
asherkin is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-21-2014 , 17:53   Re: Getting built-in (valve_*.txt) Translations
Reply With Quote #6

https://bugs.alliedmods.net/show_bug.cgi?id=5011
__________________
Peace-Maker is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 07-22-2014 , 14:31   Re: Getting built-in (valve_*.txt) Translations
Reply With Quote #7

Quote:
Originally Posted by Peace-Maker View Post
Welp, seems like this won't be implemented anytime soon.
Too bad there isn't something like ::GetTranslation(char *phrase) on the Server side ..
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-25-2014 , 17:46   Re: Getting built-in (valve_*.txt) Translations
Reply With Quote #8

Quote:
Originally Posted by pcmaster View Post
Welp, seems like this won't be implemented anytime soon.
Too bad there isn't something like ::GetTranslation(char *phrase) on the Server side ..
Well, part of the reason for that is Valve mainly uses the TextMsg usermessage to send translation phrases to clients for them to translate, although others exist for specific uses.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 07-25-2014 , 19:30   Re: Getting built-in (valve_*.txt) Translations
Reply With Quote #9

Quote:
Originally Posted by asherkin View Post
Sure, if you want to write a KV parser that supports UTF-16 and conditionals.
pretty sure it would be enough to convert utf16 to utf8 and use the kv parser on that, at least for 99% of the times. once you remove all those useless null bytes the built-in kv parser should be able to handle it

edit: also replace actual new lines inside open quotes with \n and use kvsetescapesequences
__________________
Taking private C++/PHP/SourcePawn requests, PM me.

Last edited by Zephyrus; 07-25-2014 at 19:31.
Zephyrus 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 02:57.


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