Is it possible to detect the browser language, and automatically serve the translated website? Basically, we want cn.julialang.org for people who have their browsers set to Chinese.
cc @findmyway @Roger-luo
We also need to set the language in which the site is served - both for english and chinese.
I'm asking the server owner to use cn.julialang.org directly.
@shashi Can you help setup this redirect based on browser language setting? Also, do you think we can have English | Chinese setting on the top to toggle manually?
This work for me, with Chrome.
accept-language: zh-CN,zh;q=0.9

And I think there must be a npm pkg that has already implemented this feature.
@inkydragon Can you submit a PR?
With a little test
Those js code works fine, and it's easy to extend.
<script type="text/javascript">
window.onload = function () {
var userLang = navigator.language || navigator.userLanguage;
if (userLang.startsWith("zh")) {
window.location.href = '//cn.julialang.org/';
}
};
</script>
But, I can't open english test site anymore with those code.
Because my chrome set accept-language: zh-CN,zh;q=0.9, then this js code always redirect me to chinese site.
Maybe Automatic redirect is not a good idea.
Google also advise that
Let the user switch the page language
If you have multiple versions of a page:Consider adding hyperlinks to other language versions of a page. That way users can click to choose a different language version of the page.
Avoid automatic redirection based on the user’s perceived language. These redirections could prevent users (and search engines) from viewing all the versions of your site.—— Managing multi-regional and multilingual sites - Search Console Help
I think we should add a language Multiselect menu first. or just add chinese site link to the footer.
Then when you perfer other lang except english, popup a window and let user choose to jump or not.
Just like mathworks's website (https://au.mathworks.com/ ).

Will it be possible to store language locals for the first time user access the website? e.g apple.com will pop a button to let user choose where they are for the first time they visit the website.

using cookie, the broswer could remember some setting.
If we are going to use cookie, we may need cookie notice or even Privacy Policy.
Cookir notice https://keepass.info/

@inkydragon localStorage can be used instead of cookies, which avoids the problem. Has there been a consensus on what's the best design to be used? Should it be a link somewhere, an alert, an automatic redirect? I'm against the automatic redirect for the reasons @inkydragon described above.
Nothing has been decided. If you have a solution - go for it! I can then request the other language websites to update as well - if we get this working well.
If there are more languages, then a dropdown menu in navbar is probably the best solution. https://getbootstrap.com/docs/4.5/components/dropdowns/
Is there a list of available translations somewhere?
I know there is a korean translation of the older version of the website. I suspect that if we make it easy, more translations will come online.
Perhaps with the browsers having got so good at translation nowadays, this is not as big a deal as it might have been once upon a time.
I think at least for the Chinese version, we actually provide some custom information about how to access resources in Chinese, so I believe there is always a reason for these kinds of website to exist.
I feel this will require i18n support from https://github.com/tlienart/Franklin.jl
FYI. hexo has i18n support which makes things a lot easier.
Yes - I imagine if we need to do this right, Franklin may have to support it. Otherwise, we will continue to have these as different websites that are maintained separately.
@tlienart Thoughts?
Well you can already have a folder say cn and reproduce the file structure there with content in Chinese, (you’d then have /cn/downloads/ etc.
Assuming you’d essentially want to reproduce the main pages, this is trivial to do (just need the translation...) but maybe I’m missing something.
What I could try is if I get told what are up to date translations of specific pages (eg downloads) in Chinese, I can put it in the right place, have that toggle button and we can figure out what more is needed as we go?
Edit: of course the difficulty is that the quantity of content to maintain becomes
Much bigger but I guess more people would help with it too
I think they meant having a i18n-style translation, string by string. In that case, the web page duplication wouldn't be needed, just changing the text strings. However, as far as I can tell, Franklin doesn't allow that much content abstraction, so I'd leave this for some future release.
Do you have an example of this I could have a look at? I’m trying to figure out where the content would live that would be easiest to maintain.
Something like this https://github.com/kurtsson/jekyll-multiple-languages-plugin. In any case, it would require abstracting the strings on the webpage into {{ variable tags }} and then translating the tags in an additional file.
Oh I meant an example of an actual site with translations to see where they put the translated stuff.
But fair enough looking at Hugo for a bit it seems that they’re doing pretty much what I suggest above (a folder with the translated stuff) with, indeed, support for insertion of language dependent names for navigation etc (eg “downloads” / “téléchargement”) the exact same could be accomplished with a bunch of {{fill18 xxx}} peppered in the layout files with an appropriately defined fill18 that would plug the relevant definition, xxx could be a key like :downloads from a global i18n dictionary with value a namedtuple with language as fields that fill18 would extract.
I might be missing something, it just doesn’t seem very hard to have internationalisation assuming you have the translated content and a few additional key words :/ (I’m not saying it’s not a lot of work, you need the translated content after all, but I’m not seeing the difficulty or the specific stuff that Franklin would have to do to support this)
Maybe I could just set this up with a demo page using the content from the current Chinese translation and have it “hidden” (not linked to) and we can discuss further whether that’s worth more effort or not
Right this https://github.com/JuliaLang/www.julialang.org/commit/81d50a5b477e47ade55597cf4a24c7f889d9dd1a shows how it could happen with Franklin. It's reasonably easy (I think).
You can run that branch (tl-i18n-demo) yourself and /cn/downloads and /fr/downloads will work (not linked though). (don't judge my french version, it might be my mother tongue but I'd feel much better if someone literate like Milan would help with it)
So assuming we have each of the main pages with a translation and that we can translate all the buttons and menus by completing i18n.jl this is totally doable as far as I'm concerned.
@zdroid with your experience with Jekyll, could you have a look at that demo and tell me if there's stuff that I may have overlooked? thanks a lot!
That works very well, nice work. :smile:
Jekyll doesn't have the internationalization support pre-included, so the syntax for that depends on the plugin you use. The one that you used is very simple and intuitive.
What I originally meant is that Franklin lacks the more basic abstractions like variable scopes, layouts and the front matter. With those any further abstraction becomes easier. But that is a thing to discuss in the Franklin.jl repo.
Most helpful comment
Oh I meant an example of an actual site with translations to see where they put the translated stuff.
But fair enough looking at Hugo for a bit it seems that they’re doing pretty much what I suggest above (a folder with the translated stuff) with, indeed, support for insertion of language dependent names for navigation etc (eg “downloads” / “téléchargement”) the exact same could be accomplished with a bunch of {{fill18 xxx}} peppered in the layout files with an appropriately defined fill18 that would plug the relevant definition, xxx could be a key like :downloads from a global i18n dictionary with value a namedtuple with language as fields that fill18 would extract.
I might be missing something, it just doesn’t seem very hard to have internationalisation assuming you have the translated content and a few additional key words :/ (I’m not saying it’s not a lot of work, you need the translated content after all, but I’m not seeing the difficulty or the specific stuff that Franklin would have to do to support this)
Maybe I could just set this up with a demo page using the content from the current Chinese translation and have it “hidden” (not linked to) and we can discuss further whether that’s worth more effort or not