-
Notifications
You must be signed in to change notification settings - Fork 166
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
nodejs.org: falling back to english when page hasn't been translated #316
Conversation
This will make all 404's redirect to |
Good question. Got to admit I didn't think about URLs other than the actual On Tuesday, 2 February 2016, Johan Bergström notifications@github.com
|
I assume you would rather see it check the /en/ equivalent exist before doing a redirect, correct? Haven't been able to get that working... Got a trick up your sleeve @jbergstroem? |
To elaborate on what I've tried to accomplish without luck so far:
The biggest challenge here is doing a string replace on the current Anyway the use |
How about going at it the other way? redirecting all other 'known' languages that doesn't exist to en? |
@jbergstroem something like this?
That surely removes the complexity and no if's in sight 👍 |
0a34b07
to
224dcdb
Compare
@jbergstroem just updated the PR with the simplified version posted above ^^ with explicit known languages as you suggested. Also added the english fallback to the |
@jbergstroem any thoughts on this after it got updated? |
Didn't we have something like this for iojs.org? Looks like it does work on iojs.org: https://iojs.org/fa/es6.html Ideally, however, it would not re-write to /en/ so that any future links can still go to the native language? I think? I'm not sure. |
Hmm, looks like we just made redirect static files for each page: https://github.com/nodejs/iojs.org/blob/master/source/static/es6.html |
As a note, 404's don't even work correctly at the current time: https://nodejs.org/ko/404/ - yet we clearly have one for korean: https://github.com/nodejs/nodejs.org/blob/master/locale/ko/404.md |
@@ -45,6 +45,8 @@ server { | |||
} | |||
|
|||
location / { | |||
try_files $uri $uri/ @english_fallback; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Ok I spent some time trying to get the localized 404 pages working today. What I've come up with: location @english_fallback {
if ($uri ~* ^/(it|ko)/) {
set $lang $1;
}
rewrite ^/(it|ko)/(.*)$ /en/$2; # I've used a relative url here for testing, not sure if it should be absolute or not
# No `return 404;` here, I think that makes our page actually return that status code ontop of serving..
} Where we currently declare error_page @404;
# use localized 404 pages if possible
location @404 {
try_files /$lang/404.html /en/404.html;
} |
@phillipj Hopefully you have time to look at this, I'd definitely like to get it live! |
I will follow up here shortly too. |
ebf0e0b
to
e8d291e
Compare
@Fishrock123 awesome, thanks for pitching in here! Just pushed an update which contains your localized 404 hackery 👍 |
if ($uri ~* ^/(it|ko)/) { | ||
set $lang $1; | ||
} | ||
rewrite ^/(it|ko)/(.*)$ /en/$2; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@nodejs/build could some people look at this please? This is really important for website translation and I'd like to get it live ASAP. |
e8d291e
to
ef8b01b
Compare
Rebased to fix merge conflict. Also decided to not go for relative rewrites to do things as before, and not raising more questions than necessary. |
Looks good to me 👍 |
Sorry for the delay -- I just need to do some performance testing (if's are evil yada yada) |
|
@jbergstroem Can we merge this and if it really turns out to be a problem, undo it and have a single, multi-language 404 page? This is badly blocking translation groups as I understand... I know you're busy. :( (I don't really know how to benchmark this... if you just want me to run |
@phillipj I'd suggest having a ubuntu14 machine available and override hosts |
I've been messing with setting up a test machine for you to play with this on, knowing that our ansible scripts are not entirely solid for the web server this was a good chance to try and address that. @phillipj I've put your ssh keys from GitHub into root@107.170.115.122 and it's set up almost identically to the nodejs.org server and you can do what you like with it. Stick For the record: the playbook in this repo for www should be in a better state now, it can be run with |
@Fishrock123 I put your keys in there too if you're interested in shaving this yak |
Noted, looking at it right now. |
Hmm, Indeed it does not appear to be working. Aside: why do we have 2 server configs for both blog.nodejs.org and nodejs.org? It's quite confusing. |
@Fishrock123 legacy, you'll note that all of the blog redirects are contained within the blog.nodejs.org part of the config, which leave the main nodejs.org config with much fewer redirects in its flow. I think that's what you're referring to. Or perhaps you're seeing |
Also, you're welcome to propose improvements to our nginx config, for both readability and actual efficiency. Just be aware of the legacy constraints, things need to continue to work as they do now. Mostly I'm pretty afraid to mess with nginx config too much because it's a bit like playing wac-a-mole. https://github.com/nodejs/build/blob/master/setup/www/resources/config/nodejs.org |
@rvagg thanks for adding my keys! After some trial-n-error, it seems like using relative URLs in the fallback rewrites made a positive impact. I just pushed a commit. Those changes has been made on |
Added |
location / { | ||
try_files $uri $uri/ @english_fallback; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
sgtm but I'm way too gun shy with this nginx config to be comfortable signing off on it. Can others who are comfortable hacking nginx config have a look and try it out on the test host too? @jbergstroem? |
I will follow up shortly to confirm that it works as intended. I wasn't a big fan of how variable scopes were used; but it was indeed nifty. |
At some point we're going to have to just try it. |
... ping again ... |
I'm OK with giving this a try, but only if @jbergstroem is +1 too. We should probably do it during a low traffic period, the weekend I guess, as long as we have people around to revert quickly if need be. |
Not sure which timezone digitalocean runs by, but least amount of traffic occurs in ~13h from now. I can attempt to give it a test around then. |
This has been running for a bit on nodejs.org now and seems to be working as intended. |
Has been running for about 3 days now? I think this can be merged |
I'll merge this! |
@jbergstroem any progress on merging this? nodejs.org just got a new locale (es / spanish), so it would be nice to get this merged before opening a new PR adding spanish as well. |
@phillipj I'll add es/spanish. |
Fall back to english if a page hasn't been translated. Refs: nodejs/nodejs.org#490 PR-URL: #316 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Rod Vagg <rod@vagg.org>
Merged (with the addition of |
Awesome 👍 On Thursday, 28 July 2016, Johan Bergström notifications@github.com wrote:
|
Refs nodejs/nodejs.org#490
Currently translation working groups will have to translate all pages to their respective
language, if not most pages would end in displaying a (english) 404 page. That's a massive
requirement on translation groups, and keeping up with future changes are probably near impossible.
Lowering the barrier and letting translation groups start on the frontpage and work their way
down a couple of page depths, should be alot simpler and more rewarding.
NB! This only affects local development as nodejs.org runs nginx serving strictly static content.
Getting the same behaviour in production requires changes to the nginx config.
Example of the current 404 issue; navigate any of the headers links in the current Korean translation: https://nodejs.org/ko/. I haven't done my dues when it comes to translating (yet), this is one of the main reasons I've decided not to.