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

No support for dash separated locales - en-US, zh-TW, zh-CN etc. #6

Closed
ghost opened this issue May 28, 2016 · 7 comments
Closed

No support for dash separated locales - en-US, zh-TW, zh-CN etc. #6

ghost opened this issue May 28, 2016 · 7 comments
Labels

Comments

@ghost
Copy link

ghost commented May 28, 2016

So I added zh-TW but langswitcher doesn't show it in navigation. zh alone works so I suspect you cover a language but not all locales. Please add them too as I would like to have both Chinese Traditional (zh-TW) and Chinese Simplified (zh-CN) on my site.

@rhukster
Copy link
Member

I'm not sure how this is possible. It simply grabs the languages as they exist in the languages object:

https://github.com/getgrav/grav-plugin-langswitcher/blob/develop/langswitcher.php#L61

and then just loops over them:

https://github.com/getgrav/grav-plugin-langswitcher/blob/develop/templates/partials/langswitcher.html.twig#L4-L16

Can you add a {{ dump(langobj) }} in line 3 of langswitcher.html.twig? You will need to turn on the debugger and the result should show up in the first 'messages' tab.

@ghost
Copy link
Author

ghost commented May 28, 2016

@rhukster thanks for quick reply - appreciate it!
Here is log (pastebin):

http://pastebin.com/kqGKE8Bn

It looks like it's there but for some reason he doesn't display it on front-end.
Its not just Chinese, my en-us which is default locale doesn't show up as well. I tried to wrap it in quotes "" and see whether it solves the problem but no difference. This is how it looks like currently in navigation on front-end - missing en-us and zh-tw - only Korean (ko) and Simplified Chinese (zh) are visible:

screen shot 2016-05-29 at 1 54 26 am

@rhukster
Copy link
Member

what does your supported_languages array look like in system.yaml ?

@ghost ghost changed the title No support for Chinese locales - zh-TW, zh-CN etc. No support for dash separated locales - en-US, zh-TW, zh-CN etc. May 28, 2016
@ghost
Copy link
Author

ghost commented May 28, 2016

@rhukster first 17 lines of my user/config/system.yaml:

absolute_urls: false
param_sep: ':'
wrapped_site: false
reverse_proxy_setup: false
languages:
  supported:
    - en-us
    - ko
    - zh
    - zh-tw
  include_default_lang: false
  translations: true
  translations_fallback: true
  session_store_active: true
  http_accept_language: true
  override_locale: true

@rhukster
Copy link
Member

Yah i don't think Grav likes it when you mix types (ie xx and xx-xx). What happens if you remove ko and zh temporarily ?

@ghost
Copy link
Author

ghost commented May 28, 2016

If I remove ko & zh, none of the languages will show up in navigation. When I inspect element, its just empty <ul class="langswitcher"> </ul>.

I changed the format and made them standing in one array like this - supported: [en-us, ko, zh, zh-tw] but no difference. Still those two are missing. This for sure has something to do with formatting. From Ruby I remember it should solve this problem if you wrap them in quotes (e.g. supported: ["en-us", ko, zh, "zh-tw"] but this doesn't help in this case as well :(

@rhukster
Copy link
Member

Actually.... i think i know the problem, it's a limitation of Grav\Common\Languages\LanguageCodes::getNames() This method only knows how to lookup xx style language codes. This would have to be improved to support xx-xx styles too.

https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Language/LanguageCodes.php

Would you mind opening up an issue here: https://github.com/getgrav/grav/issues for this specifically?

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

No branches or pull requests

1 participant