-
Notifications
You must be signed in to change notification settings - Fork 68
Option to write the default locale to a subdirectory also. #60
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
Comments
Using that workaround, do you notice any problems? The way polyglot is designed, I would suggest you keep using that workaround. It makes sense to me that it gets the job done effectively. |
I haven't had any problems with it yet to be honest, just felt a bit hackey. However, happy for you to close this, and at least people can search and perhaps find this issue if they want to figure out more about using Content Negotiation with polyglot. |
In the future if our script that writes out typemaps becomes unmaintainable, I might see about submitting a PR which includes a config option to generate Apache2 mod_negotiation TypeMaps in the webroot. But that is a story for another day and out of scope of this issue. |
I hope this solution continues to work out. It's a very smart approach that I want to look into more, and see where else it can be leveraged. |
Okay, so after continuing experimentation with our site, I've come across a bit of a blocker for the approach I outlined above. If I mark a file/directory as I thought I'd toy with the idea of a PR which still writes these files to the webroot, but it isn't something which I can see how to do cleanly. Specifically, with my "no |
Hmm, now I think about it, perhaps this would work:
I'd be happy to prepare a MR with this functionality. However, note that it may seem strange to users who don't realise that it is a requirement for people wanting to use Apache2 + mod_negotiation in the way that we (and the Apache2 folks themselves) are using it. Does this seem sane and worthy of a PR? |
How does #65 look? If you can, please clone down the polyglot repo and switch to the branch, and run the |
That works a treat. Thanks very much for the quick response and fix. |
#65 has been merged in, and the feature is now available in polyglot v1.3.0. Thanks for your help @pserwylo making this release happen! I left your name in the credits on the polyglot website. Cheers! |
I'm using |
@krzysztofmajewski here is the nginx documentation for configuring response to the but you might want to open a new issue to discuss this :) |
Uh oh!
There was an error while loading. Please reload this page.
Problem
The webserver should be able to render the appropriate language based on the clients
Accept-Language
header. This is difficult when thedefault_lang
from polyglot renders directly to the webroot, rather than aLANG/
subdirectory.Case study
We are currently internationalizing the F-Droid website using polyglot. After chatting to the folks at Apache, we took our inspiration from the way in which the Apache webserver documentation translates their site and renders the correct language automatically to the user using content negotiation.
Specifically:
mod_negotiation
to inspect yourAccept-Language
header and select the correct.html
file.mod_negotiation
and goes directly to thefr/
version of the site.Here is their config for reference.
Required webroot layout
For the purpose of connecting Apache
mod_negotiation
(or equivalent) and its support for theAccept-Language
header sent by the client, it is helpful if polyglot can output the following:webroot/
en/
index.html
about.html
de/
index.html
about.html
fr/
index.html
about.html
Of course the webroot here is now empty, but then we run a script which iterates over each language directory, and outputs the following:
webroot/
index.html.en -> en/index.html
index.html.de -> de/index.html
index.html.fr -> fr/index.html
index.html
about.html
and every other .html file)Where the top level
index.html
file is actually an Apache TypeMap with the following:Work around
In order to prevent the
default_lang
from populating the top level of the webroot, we're currently using this in our Jekyll sites_config.yml
, but it feels a bit hackey:Originally I tried iterating over each file in
fr/
, finding the corresponding default version in the webroot, and moving it intoen/
manually. This was not a solution though, because all of the links in theen/
pages link to the top level of the website, not theen/
subdirectory. By settingdefault_lang
to nonsense, then theen/
directory gets created the same way as each other directory. That is, it also prefixes all of the links withen/
as required.The text was updated successfully, but these errors were encountered: