mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-25 16:06:45 -05:00
Add option to disable language autodetect #3830
Closed
opened 2025-11-02 05:27:15 -06:00 by GiteaMirror
·
19 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.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v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#3830
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @markg85 on GitHub (Aug 23, 2019).
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
LANGSandNAMESin thei18nsection, 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
@lunny commented on GitHub (Aug 26, 2019):
@markg85 If you have login, you could chose your favorite language that will not obey browser's chose.
@markg85 commented on GitHub (Aug 26, 2019):
I know, but that's not the request i'm doing here :)
@lafriks commented on GitHub (Aug 26, 2019):
What your browser preferred language string looks like?
@markg85 commented on GitHub (Aug 26, 2019):
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:
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..
@lafriks commented on GitHub (Aug 26, 2019):
You can set preferred languages in browser and Gitea will use it choose default language if you have not set other in user settings
@markg85 commented on GitHub (Aug 26, 2019):
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.
@guillep2k commented on GitHub (Aug 26, 2019):
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: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.iniLANG/NAMES values to the short list you want.Cheers!
@stale[bot] commented on GitHub (Oct 25, 2019):
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.
@markg85 commented on GitHub (Oct 26, 2019):
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.
@guillep2k commented on GitHub (Oct 26, 2019):
@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):
gitwhen you interact with a repository hosted by a Gitea instance.Can you post a picture of the part that's bothering you?
@markg85 commented on GitHub (Oct 26, 2019):
@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.
@guillep2k commented on GitHub (Oct 26, 2019):
OK, it's clear now. Thank you. 😉
@lunny commented on GitHub (Oct 27, 2019):
@markg85 You can remove all other languages from your app.ini. So that this site will only support one language.
@markg85 commented on GitHub (Oct 27, 2019):
Now we're going in circles.
Quote from my first post in this thread:
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.
@mrsdizzie commented on GitHub (Oct 27, 2019):
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:
70fa80df11/templates/base/head.tmpl (L2)@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=xxxSo to force US English for gitea.com regardless of what your browser sends it would be:
https://gitea.com/?lang=en-US
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
@markg85 commented on GitHub (Oct 27, 2019):
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 ;)
@mrsdizzie commented on GitHub (Oct 27, 2019):
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.
@stale[bot] commented on GitHub (Dec 26, 2019):
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.
@stale[bot] commented on GitHub (Jan 9, 2020):
This issue has been automatically closed because of inactivity. You can re-open it if needed.