Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactions: Locale #1072

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions interactions.go
Expand Up @@ -150,6 +150,12 @@ type Interaction struct {
// Make sure to check for `nil` before using this field.
User *User `json:"user"`

// The selected language of the invoking user
// NOTE: This is available on all interaction types except InteractionPing.
Locale Locale `json:"locale"`
// The guild's preferred locale, if invoked in a guild
GuildLocale *Locale `json:"guild_locale"`

Token string `json:"token"`
Version int `json:"version"`
}
Expand Down
102 changes: 102 additions & 0 deletions locale.go
@@ -0,0 +1,102 @@
package discordgo

type Locale string

func (l Locale) String() string {
switch l {
case LocaleGerman:
return "German"
case LocaleEnglishUK:
return "English, UK"
case LocaleEnglishUS:
return "English, US"
case LocaleSpanish:
return "Spanish"
case LocaleFrench:
return "French"
case LocaleCroatioan:
return "Croatioan"
case LocaleItalian:
return "Italian"
case LocaleLithuanian:
return "Lithuanian"
case LocaleHungarian:
return "Hungarian"
case LocaleDutch:
return "Dutch"
case LocaleNorwegian:
return "Norwegian"
case LocalePolish:
return "Polish"
case LocalePortuguese:
return "Portuguese, Brazilian"
case LocaleRomanian:
return "Romanian, Romania"
case LocaleFinnish:
return "Finnish"
case LocaleSwedish:
return "Swedish"
case LocaleVietnamese:
return "Vietnamese"
case LocaleTurkish:
return "Turkish"
case LocaleCzech:
return "Czech"
case LocaleGreek:
return "Greek"
case LocaleBulgarian:
return "Bulgarian"
case LocaleRussian:
return "Russian"
case LocaleUkrainian:
return "Ukrainian"
case LocaleHindi:
return "Hindi"
case LocaleThai:
return "Thai"
case LocaleChinese:
return "Chinese, China"
case LocaleJapanese:
return "Japanese"
case LocaleTaiwan:
return "Chinese, Taiwan"
case LocaleKorean:
return "Korean"
}

return "Unknown"
}

// All known locales
const (
LocaleGerman Locale = "de"
LocaleEnglishUK Locale = "en-GB"
LocaleEnglishUS Locale = "en-US"
LocaleSpanish Locale = "es-ES"
LocaleFrench Locale = "fr"
LocaleCroatioan Locale = "hr"
LocaleItalian Locale = "it"
LocaleLithuanian Locale = "lt"
LocaleHungarian Locale = "hu"
LocaleDutch Locale = "nl"
LocaleNorwegian Locale = "no"
LocalePolish Locale = "pl"
LocalePortuguese, LocaleBrazilian Locale = "pt-BR", "pt-BR"
LocaleRomanian, LocaleRomania Locale = "ro", "ro"
LocaleFinnish Locale = "fi"
LocaleSwedish Locale = "sv-SE"
LocaleVietnamese Locale = "vi"
LocaleTurkish Locale = "tr"
LocaleCzech Locale = "cs"
LocaleGreek Locale = "el"
LocaleBulgarian Locale = "bg"
LocaleRussian Locale = "ru"
LocaleUkrainian Locale = "uk"
LocaleHindi Locale = "hi"
LocaleThai Locale = "th"
LocaleChinese, LocaleChina Locale = "zh-CN", "zh-CN"
LocaleJapanese Locale = "ja"
LocaleTaiwan Locale = "zh-TW"
LocaleKorean Locale = "ko"
LocaleUnknown Locale = ""
)