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

Fallback Language Support #10

Open
SCKelemen opened this issue Feb 6, 2017 · 5 comments
Open

Fallback Language Support #10

SCKelemen opened this issue Feb 6, 2017 · 5 comments
Assignees

Comments

@SCKelemen
Copy link
Contributor

SCKelemen commented Feb 6, 2017

CLDR has fallback languages for cases in which a localization is unavailable. I would like to add support for this. Any thoughts or recommendations on implementation?

I would create LocaleResolver which takes in a locale ID, and if the ID is support, returns the ID, otherwise it runs through the list of fallback locales, and returns the first one that is supported. I'd probably need to specify a configurable default language value as well.

http://cldr.unicode.org/development/development-process/design-proposals/transform-fallback
http://cldr.unicode.org/development/development-process/design-proposals/languagedistance

@deankarn
Copy link
Contributor

deankarn commented Feb 7, 2017

@SCKelemen I hadn't gotten that far with it yet...But there is already a library that does this https://godoc.org/golang.org/x/text/language

I was hoping to integrate it at some point as a higher level function to the FindTranslator which does do fallback based on the array..So the higher level function would create the array.

@deankarn deankarn self-assigned this Feb 7, 2017
@deankarn
Copy link
Contributor

deankarn commented Feb 7, 2017

Thanks for all your help and suggestions @SCKelemen

I apologize if I'm a little slow getting some of this implemented; my main focus right now is finding a job

@SCKelemen
Copy link
Contributor Author

Do you want help implementing it?

@deankarn
Copy link
Contributor

deankarn commented Feb 7, 2017

Ya I'm all for any help 👍

@deankarn
Copy link
Contributor

deankarn commented Feb 9, 2017

@SCKelemen so basically this library https://godoc.org/golang.org/x/text/ you specify a matcher of supported languages and then match based on preferred languages, say gathered from the Accept-Language header.

But I don't know if there is a nice way to integrate it as of yet to help determine which locales we should look for but ideally when registering locales with this library languages would be added to the matcher and then a function could be added called DetermineLocale(...) and it could accept and array of preferred languages and determine the best matching using the matcher and attempt to return the Translator for the best matched locale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants