Hi,
While language autodetect often seems like a nice feature to have (and i'd agree if i never had issues with it), it has it's downsides too.
For instance, i've had the issue for years of being detected as German (i'm dutch, was in the netherlands and was not using a proxy). Even google was at one point in German for me...
So... the feature can be damn pesky if it doesn't work as you'd expect it to work.
i know of the trick to just remove all but english from LANGS
and NAMES
in the i18n
section, but that's not what i want. As that removes them entirely. I want to be able to choose, just disabling autoconnect and using English by default.
Cheers,
Mark
@markg85 If you have login, you could chose your favorite language that will not obey browser's chose.
@markg85 If you have login, you could chose your favorite language that will not obey browser's chose.
I know, but that's not the request i'm doing here :)
What your browser preferred language string looks like?
I suppose you mean the output of "navigator.language" which is in fact "nl". I don't know how it determines that as my system language is English. i do use NL for some settings. Like having a 24 hour clock. So to be very detailed:
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=en_NL.UTF-8
LC_TIME=en_NL.UTF-8
LC_COLLATE=en_NL.UTF-8
LC_MONETARY=en_NL.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT=en_NL.UTF-8
LC_IDENTIFICATION="en_US.UTF-8"
But again, i fail to see the point of even telling this. The feature i'm requesting is to have language detection disabled and overruled by the site administrator. Not to debug my browser..
You can set preferred languages in browser and Gitea will use it choose default language if you have not set other in user settings
You can set preferred languages in browser and Gitea will use it choose default language if you have not set other in user settings
Please stop.
Sure, that works but is a workaround and not the feature i'm asking for.
I'd be happy to explain the feature i'm asking for in more detail if it isn't clear (i think it is).
On the other hand, if you can point me to the code that does handle this in Go and the requirements to make the requested feature acceptable then i'd like to give Go a shot and try to implement this.
I hope you don't mind if I give you this information; if it's not useful to you, please ignore it. I'm also annoyed by auto-detect in many web sites, but I have no problems with Gitea.
In my server, in /etc/gitea/app.ini
, I have the following:
[i18n]
LANGS = en-US,es-ES
NAMES = English, Espa帽ol
This prevents Gitea from choosing any language other than English and Spanish, which are the languages spoken in my company.
Then, as I prefer English, while I'm logged in I click here:
I'm not aware of Gitea doing any kind of auto-detection based on browser/client data (e.g. ip address database). I've sought all around the source code and I've only found the code I'd expect (e.g. related to user settings).
You can disable all offending languages by setting the /etc/gitea/app.ini
LANG/NAMES values to the short list you want.
Cheers!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Nope, not stale. The issue as described is still there. Some might consider it a feature, i consider it a bug.
@guillep2k thank you for your comment, but that is exactly what i described only in text. You added nice pictures to it ;) Anyhow, that's not what i'm looking for.
@markg85 I keep reading your description and it's still unclear to me what do you actually want. I think that Gitea doesn't autodetect language for the logged in user, so I'm trying to understand your exact problem. Yes, I've read the title, but your message only describes your frustration with software in general. 馃
There's some context here that I'm missing. For instance, you might be referring to one of the following (there are more):
git
when you interact with a repository hosted by a Gitea instance.Can you post a picture of the part that's bothering you?
@guillep2k oke.
Follow my words exactly!
I installed gitea and am not logged in. Then i visit my gitea instance.
again, all not logged in!!!!
Now the site shows in Dutch for me. something somehow somewhere in the Gitea codebase uses some heuristic to detect my language and display the site in that language. i want to disable that feature and force it to always be english. Everything else should remain as-is.
So why do i want that? Why do i hate this "feature"?
Well, in Dutch technical sites like github, gitea, codelab, etc.. look soooo freaking weird. With "attempted translations" of technical terms that are just better explained in English.
I get that some people consider this a "feature". I just hate it.
Again, i need to stress this over and over and over again. I'm not logged on. Yes, there is a language dropdown, even when i'm not logged on, but that is not the point. The point is that an attempt is made to show a localized site. I want to disable that attempt.
OK, it's clear now. Thank you. 馃槈
@markg85 You can remove all other languages from your app.ini. So that this site will only support one language.
@markg85 You can remove all other languages from your app.ini. So that this site will only support one language.
Now we're going in circles.
Quote from my first post in this thread:
i know of the trick to just remove all but english from LANGS and NAMES in the i18n section, but that's not what i want. As that removes them entirely. I want to be able to choose, just disabling autoconnect and using English by default.
I guess the technical term is that i want to disable i18n on the main site without removing the localized translations. I just want to force an overruling default.
By default Macaron (Web framework Gitea uses) looks at the "Accept-Language" header sent by the browser if nothing is specified otherwise (so for a non-logged in user), and the code for that is here:
https://gitea.com/macaron/i18n/src/branch/master/i18n.go#L183
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language
And then Gitea uses that here:
@lafriks point remains that Gitea isn't auto-detecting anything, it is just responding to the browsers specific request for language. The Browser is saying "Send this page in Dutch" (in this example). There isn't a heuristic or anything like that on the Gitea end that makes it guess a language, it just responds with what the browser specifically asks for in the request header. What you'd really be asking for is "Ignore language request my browser sends".
As requested, above are the links to the specific code where Gitea eventually uses the header the browser sends if you are interested in modifying it.
With the current code you can also force a different language by adding this to the URL query: lang=xxx
So to force US English for gitea.com regardless of what your browser sends it would be:
That should be enough to then set that language in the users Cookie for other pages, but I haven't tested that in very much detail at all.
Alternatively, a custom header template that would force the lang tag to something specific if a user isn't signed in
{{if .IsSigned}}<html lang="{{.Language}}">{{else}}<html lang="en-US">{{end}}
Thank you @mrsdizzie !
I might play a bit with this to get it to my liking. But then again, the inconvenience is really minor. So it's not all that important.
Just curious, if i make a feature to set a default i18n override when the user hasn't picked anything, would that be acceptable as a feature for Gitea? Or as you phrased it: "Ignore language request my browser sends". If it is, i might try to make a patch for it. If it's not.. well... why would i bother ;)
Great glad that helps!
Personally I think the two separate workarounds above for this should be enough in this case where somebody wants to ignore what the browser has sent and it wouldn't be worth complicating the code further to add another option.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
This issue has been automatically closed because of inactivity. You can re-open it if needed.
Most helpful comment
Nope, not stale. The issue as described is still there. Some might consider it a feature, i consider it a bug.
@guillep2k thank you for your comment, but that is exactly what i described only in text. You added nice pictures to it ;) Anyhow, that's not what i'm looking for.