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

default_locale did not work #2

Open
jaysneg opened this issue May 23, 2018 · 17 comments
Open

default_locale did not work #2

jaysneg opened this issue May 23, 2018 · 17 comments
Labels
kind:question Further information is requested status:help-wanted Extra attention is needed

Comments

@jaysneg
Copy link

jaysneg commented May 23, 2018

settings.default_locale = "ua" did not work

@faustinoaq
Copy link
Contributor

Maybe related to amberframework/amber#776 @docelic WDYT? 😅

@faustinoaq faustinoaq added status:help-wanted Extra attention is needed kind:question Further information is requested labels May 23, 2018
@docelic
Copy link
Contributor

docelic commented May 23, 2018

Hello Jaysneg!

@faustinoaq based on the description, I assume that the language files were not found, so the setting of "ua" was ignored and defaulted back to "en".

But sure, let's handle #776 first and then we can see. I will submit a PR for #776 maybe even today.

Thanks!

@faustinoaq
Copy link
Contributor

@docelic Oh, ok 👍 BTW, WDYT about moving locales/ directory from src/ to config/ like rails does?

@docelic
Copy link
Contributor

docelic commented May 23, 2018

Sure, sounds good. Will be another PR. I'm working on it, sorry for the previous delay. Thanks!

@docelic
Copy link
Contributor

docelic commented May 23, 2018

@jaysneg as a suggestion for you, please edit lib/citrine-i18n/src/citrine-i18n/handler.cr in your project and uncomment the lines that say:

13 #Amber.logger.debug "Languages available: #{languages.to_s}"
14 #Amber.logger.debug "Language chosen: #{::I18n.locale}"

Then, please observe the logs while you visit the page, and see whether "ua" appears in the list of available languages. Our further advice will depend on whether it does or not.

Thanks!

@jaysneg
Copy link
Author

jaysneg commented May 23, 2018

it works if i put this code to slang template
if i didn't do this some of locales didn't work

  • I18n.locale = "ua"

@jaysneg
Copy link
Author

jaysneg commented May 23, 2018

@docelic if i add this to initializers/i18n.cr
I18n.available_locales

it returns ["en", "ru", "ua"]

@jaysneg
Copy link
Author

jaysneg commented May 23, 2018

it looks like it using javascript for setting this values

@jaysneg
Copy link
Author

jaysneg commented May 23, 2018

01:34:57 Server | Languages available: en-US,en;q=0.9,ru;q=0.8,uk;q=0.7
01:34:57 Server | Language chosen: en

@jaysneg
Copy link
Author

jaysneg commented May 23, 2018

but in src/locales 3 files
en.uml
ru.yml
ua.yml

@docelic
Copy link
Contributor

docelic commented May 23, 2018

@jaysneg right, the "Languages available" is somewhat misleading title. The values displayed there (along with q= preferences) come from the HTTP header Accept-Language which is sent by the browser.

@docelic
Copy link
Contributor

docelic commented May 24, 2018

@jaysneg If I understand it right, the issue here is that the browser is instructing the server to prefer English over other languages, and since "en" is on the list of locales found by Amber, it is naturally chosen instead of the default_locale or other choices.

(This may be somewhat inconvenient for users because users are typically given a choice of language in the web app, and are not used to the model where language preferences are taken from their browser's header Accept-Language.)

Could someone confirm that that's what is happening and advise which path should be taken to solve it?

@jaysneg
Copy link
Author

jaysneg commented May 24, 2018

my iphone default system language Ukrainian

03:31:25 Headers | Accept-Language: ["uk-ua"]

file name uk-ua.yml

and it did not change locale to uk-ua
site still on EN locale

@jaysneg
Copy link
Author

jaysneg commented May 24, 2018

03:44:10 Headers | User-Agent: ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1 Safari/605.1.15"]
03:44:10 Headers | Accept-Language: ["uk-ua"]

in Safari

@jaysneg
Copy link
Author

jaysneg commented May 24, 2018

03:44:59 Headers | Accept-Encoding: ["gzip, deflate, br"]
03:44:59 Headers | Accept-Language: ["en-US,en;q=0.9,ru;q=0.8,uk;q=0.7"]
in Chrome

system on Ukrainian

@docelic
Copy link
Contributor

docelic commented May 24, 2018

@jaysneg ok, thanks for all the input. We're working on merging amberframework/amber#814 and then we can continue on this issue.

@docelic
Copy link
Contributor

docelic commented May 27, 2018

Hey @jaysneg, the above issue was just merged so as soon as I get a chance I'll re-test the functionality from this issue and report back.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:question Further information is requested status:help-wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants