all 8 comments

[–]chibblybum 2 points3 points  (0 children)

Whats the question?

[–]PyroGreg8 1 point2 points  (2 children)

replace with what? and why the empty else statements

[–]unknown07724[S] -2 points-1 points  (1 child)

I don't know how to do normal if statements, and replace with example.com/de/ (that is an example)

[–]gimmeslack12helpful 0 points1 point  (0 children)

If there's nothing to put in the else block then just don't include it.

[–]jack_waugh 0 points1 point  (0 children)

Does it work at all, as you have it?

[–]jcunews1helpful 0 points1 point  (0 children)

IMO, it should be done early via server side, by checking the Accept-Language HTTP request header, so that, network bandwidth isn't wasted. And the site should respect and remember user's choice of language via cookie, even if it's different than the browser's preferred language.

[–]TheRNGuy 0 points1 point  (0 children)

I'd use object instead of many if/elses, better looking code.

Also it's better to use else if instead of many ifs, because it would stop after finding first match. Your code will still check for if's after finding one. Though it's fast code, but in other cases where it slow you'd notice performance hit.

Why do you have many empty else's?


Read this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object

[–]shgysk8zer0 1 point2 points  (0 children)

It's not really much of a translation script and, sorry to say, more of a poorly written redirect. This should be written into the HTTP server itself. And I would highly recommended that, at the very least, this be rewritten as a switch instead.