-
How do I get back the ISO 639-1 code for a language? My use case is a text that is turned to HTML and I want to set the Sadly, I'm new to Go, so this is what I have in a test and I always get back EU for English. func TestLanguage(t *testing.T) {
language := lingua.English
if lingua.IsoCode639_1(language) != lingua.EN {
t.Logf("Language: %s, ISO 639-1: %s", language.String(), lingua.IsoCode639_1(language).String())
t.Fail()
}
} Result:
I guess I'm confused about the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Alex, it's as simple as calling Conversely, if you want to get the language for a specific ISO code, just call |
Beta Was this translation helpful? Give feedback.
Hi Alex, it's as simple as calling
lingua.English.IsoCode639_1()
.Conversely, if you want to get the language for a specific ISO code, just call
lingua.GetLanguageFromIsoCode639_1(lingua.EN)
. While I'm thinking about it...it probably makes sense to implementlingua.EN.Language()
for the next version. That would be much more elegant. Thank you for pointing me to this idea. (-: