discord / discord-rpc

https://discordapp.com/developers
MIT License
1.04k stars 322 forks source link

Localization #177

Closed codecat closed 6 years ago

codecat commented 6 years ago

Is localization possible, based on the language that a Discord client is set to? So someone using the English Discord client would see my status in English but someone with a Korean Discord client would see it in Korean, etc.

ghost commented 6 years ago

It would be great, or at least have predefined statuses that are correctly translated based on localization.

codecat commented 6 years ago

Predefined strings is how Steam does it, so yeah I was thinking something like that as well.

msciotti commented 6 years ago

Sorry—meant to respond sooner. We don't currently support localization in that way—like passing a key that pulls the right translated value—but we do support UTF-8 characters, so you could send localized strings.

It's on a roadmap to support in the future, but I unfortunately do not have a date/time for this right now.

codecat commented 6 years ago

Just wanted to add that Steam has localized strings as a requirement for their new rich presence display in the new Steam Client Beta. It works really well, and would love to see this on Discord as well in the future.

SlySven commented 6 years ago

How would this be done? The game/other application reporting the user's state to Discord via the Rich Presence would probably use that user's local locale/language setting to choose the language used to generate their "Details", "State" (and Small/Large Icon tool-tips) etc. in the Rich Presence but that text would not be what separate Discord users browsing the members list for a Guild/Server would want to see as they would want it in their locale language setting. Theoretically this would mean that the DiscordRichPresence passed to the Discord_UpdatePresence(...) would have to contain a translation into every locale/language that the Discord application itself offers.

That probably isn't feasible but perhaps there might be a mechanism to at least indicate the locale/language that the originating user has used for the message (at a minimum) and have support for passing several in parallel (better) - so that the Discord end of it can pick the best one for each instance of the Discord application for end users to use for that end user. It may be possible to then use on-line translation tools to attempt to translate a message if it is not in the individual Discord App's end-user language; it would also be wise to allow the latter to have a ranked order of languages and not just a single choice selection...

codecat commented 6 years ago

Client sets state to eg. #State_WaitingInLobby with some optional parameters eg. params["level"] = "Tilted Towers";

Then on Discord's server side you have that string with the params in each language, eg for English, Waiting in lobby (Level: %level%) or so.

Clients who can see the status would then have to receive those localized strings in advance, so that it can show the strings based on the client's settings.

So, the client reporting the presence wouldn't send any real strings, just string identifiers.

JoelTroch commented 6 years ago

How about adding a Discord_GetClientLanguage() in the API that would return the language used in the Discord client (like en_US for American English, fr_FR for French France) and let the game developer handles the rest?

codecat commented 6 years ago

That doesn't make sense - you want the other users to see your state in their language, not your language.

SlySven commented 6 years ago

:thinking: Like what @codecat says - the trouble is that you can send pretty much anything for most of the textual items - but that will only be in one language; there is no mechanism to allow the SDK/user's system that generates the text to supply multiple versions in different languages and indeed no method for the Discord RPC code to tell the Discord Rich Presence supporting application which language strings it would like to have sent to it for other users' systems to have...