You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would really appreciate possibility to select language by ISO string as part of this library - I plan to load some configuration including ISO string from json and keeping mapping by myself is kind of pain. Something along these lines would be great:
stringToIsoCode639_1 = map[string]IsoCode639_1 {
"AF": AF,
...
}
func GetLanguageFromStringIsoCode639_1(code string) Language {
for _, language := range AllLanguages() {
if language.IsoCode639_1() == stringToIsoCode639_1[code] {
return language
}
}
return -1
}
Also, I noticed that this function is not exactly optimal. It has linear complexity with regards to number of languages. It's probably not noticeable due to relatively small number of languages, but still, it can be also optimized by lookup map:
IsoCode639_1ToLanguage = map[IsoCode639_1]Language {
AF: Afrikaans,
...
}
func GetLanguageFromIsoCode639_1(isoCode IsoCode639_1) Language {
if val, ok := IsoCode639_1ToLanguage[isoCode]; ok {
return val
}
return -1
}
The text was updated successfully, but these errors were encountered:
Right, that's a good idea @kostrahb. I've decided to write the functions GetIsoCode639_1FromValue() and GetIsoCode639_3FromValue() as I don't want to have more large mappings in my code. Golang code is bloated enough already. The difference in performance is negligible imho.
I would really appreciate possibility to select language by ISO string as part of this library - I plan to load some configuration including ISO string from json and keeping mapping by myself is kind of pain. Something along these lines would be great:
Also, I noticed that this function is not exactly optimal. It has linear complexity with regards to number of languages. It's probably not noticeable due to relatively small number of languages, but still, it can be also optimized by lookup map:
The text was updated successfully, but these errors were encountered: