Raised This Month: $81 Target: $400
 20% 

[ANY] Language Selector


Post New Thread Reply   
 
Thread Tools Display Modes
Author
SirDigby
Junior Member
Join Date: Feb 2016
Plugin ID:
8146
Plugin Version:
1.0.1
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    5 
    Plugin Description:
    Set the language used for a player's translations via a menu or commands.
    Old 08-09-2022 , 07:31   [ANY] Language Selector
    Reply With Quote #1

    [ANY] Language Selector


    A plugin that allows players to select the language they want SourceMod to translate text into.
    Translations must be provided by plugins for this to have any effect on them.

    Requires at least SourceMod 1.11.

    Features
    • Configurable menu (modify sourcemod/configs/langselect.cfg and the auto-generated cfg/sourcemod/plugin.langselect.cfg).
    • Saves player language setting across sessions (can be turned off).
    • Optional prompt for new players to select a language (either ask once, or ask until they select something).
    • Full and absolutely overkill translation support.

    How to install

    See the releases tab on GitHub for the latest download.
    Or download the one attached to the post (which could be out of date if I forget to update it).

    Download and extract the archive (.zip or .7z) into addons/sourcemod/
    The LICENSE.txt is not required.

    After loading for the first time, cfg/sourcemod/plugin.langselect.cfg will be generated and can then be configured.

    If upgrading, remember the auto-generated config file may need to be deleted (but only if new ConVars were added).


    Commands

    Like all sm_ commands you can use ! or / too, like !language or /language

    PHP Code:
    // Set your own SourceMod translation language.
    // Not specifying a country code will open the menu.
    // Access: Everyone
    sm_language <Country Code>  or  sm_language     
    sm_lang 
    <Country Code>      or  sm_lang


    // Get a player's SourceMod translation language.
    // Access: Admin_Generic
    sm_getlanguage <Target>
    sm_getlang <Target>


    // Set a player's SourceMod translation language.
    // Access: Admin_Ban
    sm_setlanguage <Target> <Country Code>
    sm_setlang <Target> <Country Code>


    // Reset a player's SourceMod translation language.
    // Access: Admin_Ban
    sm_resetlanguage <Target>
    sm_resetlang <Target
    ConVars
    PHP Code:
    // Allow custom language codes with "sm_language <Code>".
    // If 0, only codes available in the config (or the built-in list if config is disabled) are permitted.
    // -
    // Default: "0"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    langselect_allow_custom "0"

    // Show a "Reset Language" option on the menu.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    langselect_allow_reset "1"

    // Location of the Language Selector config file (relative to the SourceMod directory).
    // -
    // Default: "configs/langselect.cfg"
    langselect_config "configs/langselect.cfg"

    // How should the language selection prompt show to a new player.
    // 0 - On each respawn until a language is selected.
    // 1 - Only once per session.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    langselect_prompt_once "1"

    // Should a player's selected language be saved.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    langselect_save "1"

    // Ask new players to select a language when they spawn.
    // -
    // Default: "0"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    langselect_show_prompt "0"

    // Should the config file be used to set the available languages.
    // If 0, this will use a built-in list of languages.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    langselect_use_config "1" 
    Change Log
    Code:
    1.0.1 - Minor fixes to commands and timers.
    Translations

    If anyone wants to suffer and attempt to translate the gargantuan-sized translation file,
    please share it here and I might add it into the plugin (if it can be at least mostly verified).

    It contains 250+ phrases (mostly the names of languages), so it may be hard to verify your work unless you can show sources or proof.
    Attached Files
    File Type: zip lang-selector-1.0.1.zip (47.3 KB, 98 views)
    File Type: 7z lang-selector-1.0.1.7z (39.4 KB, 70 views)
    __________________

    Last edited by SirDigby; 08-11-2022 at 23:58.
    SirDigby is offline
    Grey83
    Veteran Member
    Join Date: Dec 2014
    Location: Ukraine
    Old 08-10-2022 , 14:03   Re: [ANY] Language Selector
    Reply With Quote #2

    How about this?
    https://forums.alliedmods.net/showthread.php?p=2444363
    __________________
    Grey83 is offline
    SirDigby
    Junior Member
    Join Date: Feb 2016
    Old 08-10-2022 , 22:01   Re: [ANY] Language Selector
    Reply With Quote #3

    Quote:
    Originally Posted by Grey83 View Post
    I saw that plugin and it didn't impress me:
    • Menu doesn't have a reset option.
    • Doesn't translate the names of languages in commands or on the menu (a bit nitpicky but it's useful).
    • Basically doesn't have any translation support at all actually (for a language selection plugin?)
    • Doesn't have admin commands for targeting users.
    • Doesn't properly handle CS:GO/Blade Symphony calling g_ConVarManager.QueryClientConVar() to get the client's language (which is asynchronous so you can't reliably call SetClientLanguage during client connect).
    • Doesn't have the ability to restrict player languages to whats available on the menu.
    • Doesn't reset client languages if the plugin unloads.
    • Doesn't have an optional prompt for new users to select language preference.
    • Doesn't inform you that a language is missing from the languages.cfg or if the code is simply invalid (though to be fair my code makes the assumption that almost all of the language codes are ISO 639-1 which isn't necessarily true).

    You get the idea--my plugin does all of those things.
    __________________

    Last edited by SirDigby; 08-10-2022 at 22:10.
    SirDigby is offline
    Grey83
    Veteran Member
    Join Date: Dec 2014
    Location: Ukraine
    Old 08-11-2022 , 00:30   Re: [ANY] Language Selector
    Reply With Quote #4

    Quote:
    Originally Posted by SirDigby View Post
    Doesn't translate the names of languages in commands or on the menu (a bit nitpicky but it's useful).
    Language names are taken from the file .../addons/sourcemod/configs/languages.cfg.
    Quote:
    Originally Posted by SirDigby View Post
    Basically doesn't have any translation support at all actually (for a language selection plugin?)
    It has no practical meaning: the name in English is clear to everyone, in addition, if accidentally switch to a language unknown to the user, a player may not find the right one (except by brute force).
    Quote:
    Originally Posted by SirDigby View Post
    Doesn't have admin commands for targeting users.
    Does it make sense?
    Quote:
    Originally Posted by SirDigby View Post
    Doesn't have the ability to restrict player languages to whats available on the menu.
    The menu lists only those languages ​​that are available on the server and are registered in the file .../addons/sourcemod/configs/languages.cfg.
    Quote:
    Originally Posted by SirDigby View Post
    Doesn't inform you that a language is missing from the languages.cfg or if the code is simply invalid (though to be fair my code makes the assumption that almost all of the language codes are ISO 639-1 which isn't necessarily true).
    If the language is not on the server, then it will not be in the menu. If the player still chose a language that is not on the server, then he will see messages in the default language.
    __________________
    Grey83 is offline
    SirDigby
    Junior Member
    Join Date: Feb 2016
    Old 08-11-2022 , 21:37   Re: [ANY] Language Selector
    Reply With Quote #5

    A lot to address here.

    TL;DR - The point is, my plugin has a few more features than the other plugin that I think might be helpful to people.


    The language names in languages.cfg don't have translation support--you only get one set of names for the whole server and that by default includes improper names like "TChinese" or "KoreanA".
    My plugin supports translating the displayed names in the menu and in commands via a translation file. So it's per-client, not per-server.

    Although to be clear, only the English translation file exists currently because I don't speak any other language.

    And these translations are appended to the server-configured names, not replacing them.
    So for example, if your language was set to Japanese you could see: 1. English (英語)
    Or maybe if you visited a Russian server with your language set to Greek: 1. Английский (Αγγλικά)

    Yes, it's mostly pointless, but rather than limiting what languages are used it'd be better to support all of them, right?

    Quote:
    Originally Posted by Grey83 View Post
    It has no practical meaning: the name in English is clear to everyone, in addition, if accidentally switch to a language unknown to the user, a player may not find the right one (except by brute force).
    Yes it's well established that everyone speaks English and can read the English names for languages. Translation is just a gimmick invented by google to sell their API. (sarcasm)

    Quote:
    Originally Posted by Grey83 View Post
    Does it make sense?
    Never said it had to I just said I wanted the feature and the other plugin didn't have it \_(ツ)_/

    Quote:
    Originally Posted by Grey83 View Post
    The menu lists only those languages ​​that are available on the server and are registered in the file .../addons/sourcemod/configs/languages.cfg.
    I'm pretty sure the better design is for the plugin to limit the languages, rather than disabling them server-wide.
    But it works fine for hard-restricting people to a few languages, I guess.

    But what if you want the command to allow different languages than what are displayed on the menu?
    Maybe you want the menu to conveniently have the top 3 most common languages for your server, but the !language command to allow any other language that the server technically supports.
    Again I know, not very useful but the functionality is there if somebody wants it.

    Quote:
    Originally Posted by Grey83 View Post
    If the language is not on the server, then it will not be in the menu. If the player still chose a language that is not on the server, then he will see messages in the default language.
    Fair point, the other plugin wouldn't need to know that since it doesn't have its own menu config or command to set it without a menu.
    But I don't think "the other plugin doesn't have a working non-menu command" really counts as being better.
    __________________
    SirDigby is offline
    panikajo
    Member
    Join Date: Jan 2013
    Old 08-26-2022 , 12:18   Re: [ANY] Language Selector
    Reply With Quote #6

    Quote:
    Originally Posted by SirDigby View Post
    A lot to address here.

    TL;DR - The point is, my plugin has a few more features than the other plugin that I think might be helpful to people.


    The language names in languages.cfg don't have translation support--you only get one set of names for the whole server and that by default includes improper names like "TChinese" or "KoreanA".
    My plugin supports translating the displayed names in the menu and in commands via a translation file. So it's per-client, not per-server.

    Although to be clear, only the English translation file exists currently because I don't speak any other language.

    And these translations are appended to the server-configured names, not replacing them.
    So for example, if your language was set to Japanese you could see: 1. English (英語)
    Or maybe if you visited a Russian server with your language set to Greek: 1. Английский (Αγγλικά)

    Yes, it's mostly pointless, but rather than limiting what languages are used it'd be better to support all of them, right?



    Yes it's well established that everyone speaks English and can read the English names for languages. Translation is just a gimmick invented by google to sell their API. (sarcasm)



    Never said it had to I just said I wanted the feature and the other plugin didn't have it \_(ツ)_/



    I'm pretty sure the better design is for the plugin to limit the languages, rather than disabling them server-wide.
    But it works fine for hard-restricting people to a few languages, I guess.

    But what if you want the command to allow different languages than what are displayed on the menu?
    Maybe you want the menu to conveniently have the top 3 most common languages for your server, but the !language command to allow any other language that the server technically supports.
    Again I know, not very useful but the functionality is there if somebody wants it.



    Fair point, the other plugin wouldn't need to know that since it doesn't have its own menu config or command to set it without a menu.
    But I don't think "the other plugin doesn't have a working non-menu command" really counts as being better.
    can create for sm 10?
    panikajo is offline
    SirDigby
    Junior Member
    Join Date: Feb 2016
    Old 08-27-2022 , 08:49   Re: [ANY] Language Selector
    Reply With Quote #7

    Quote:
    Originally Posted by panikajo View Post
    can create for sm 10?
    Nope, I tried it making it work in 1.10 but for CS:GO support 1.11 is required.
    __________________
    SirDigby 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 15:21.


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