JavaScript error: Uncaught RangeError: Incorrect locale information provided #11043

Open
opened 2025-11-02 09:25:56 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @hiifong on GitHub (Jun 17, 2023).

Description

When the language of gitea is Chinese, using the Google Translate page and then using the detected language will cause problems。

image

https://github.com/go-gitea/gitea/assets/89133723/06fb8503-00c5-4249-bd73-94b9436deffb

Gitea Version

v1.20+

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

./gitea web

Database

None

Originally created by @hiifong on GitHub (Jun 17, 2023). ### Description When the language of gitea is Chinese, using the Google Translate page and then using the detected language will cause problems。 ![image](https://github.com/go-gitea/gitea/assets/89133723/2a1d6940-f5d3-4107-8df8-b4361233f312) https://github.com/go-gitea/gitea/assets/89133723/06fb8503-00c5-4249-bd73-94b9436deffb ### Gitea Version v1.20+ ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? ./gitea web ### Database None
GiteaMirror added the issue/confirmedtype/bug labels 2025-11-02 09:25:56 -06:00
Author
Owner

@silverwind commented on GitHub (Jun 18, 2023):

Video does not work for me. Is this cause by Google Translate modifying the page? Is it a browser addon?

@silverwind commented on GitHub (Jun 18, 2023): Video does not work for me. Is this cause by Google Translate modifying the page? Is it a browser addon?
Author
Owner

@hiifong commented on GitHub (Jun 18, 2023):

Video does not work for me. Is this cause by Google Translate modifying the page? Is it a browser addon?

You can try to download the video locally and view it

@hiifong commented on GitHub (Jun 18, 2023): > Video does not work for me. Is this cause by Google Translate modifying the page? Is it a browser addon? You can try to download the video locally and view it
Author
Owner

@silverwind commented on GitHub (Jun 18, 2023):

Ah, yes, for whatever reason the video stayed black but it works after downloading.

The bug may be in https://github.com/github/relative-time-element. GitHub uses the same element, can you try to reproduce on github.com and check the console?

@silverwind commented on GitHub (Jun 18, 2023): Ah, yes, for whatever reason the video stayed black but it works after downloading. The bug may be in https://github.com/github/relative-time-element. GitHub uses the same element, can you try to reproduce on github.com and check the console?
Author
Owner
@hiifong commented on GitHub (Jul 11, 2023): https://github.com/go-gitea/gitea/assets/89133723/66d08ba2-15d6-4354-9b70-7c9fec07215b
Author
Owner
@hiifong commented on GitHub (Jul 11, 2023): https://github.com/go-gitea/gitea/assets/89133723/dc32306e-20c0-43ab-80fd-583d2bc18a62
Author
Owner

@wxiaoguang commented on GitHub (Jul 11, 2023):

If you only post videos without a single word, I don't know what you are talking about.

And, I can not reproduce it.

@wxiaoguang commented on GitHub (Jul 11, 2023): If you only post videos without a single word, I don't know what you are talking about. And, I can not reproduce it.
Author
Owner

@wxiaoguang commented on GitHub (Jul 11, 2023):

I will help to complete this issue's information:

Reproducible steps:

  1. Use Chrome to open a page with "relative-time" component, eg: the signed-in homepage try.gitea.io or a repo's home page like https://try.gitea.io/wxiaoguang/test
  2. Switch the language to a non-English one
  3. Click "Translate to ...." in the page's right-click context menu
  4. Then switch to the "Detected language"
  5. Then the "lang" attribute in <html> becomes "auto" (it's changed by the Google's translate plugin), it breaks https://github.com/github/relative-time-element

Screenshot of the bug:

image


How to fix:

  1. Let google fix its plugin (lang=auto seems incorrect)
  2. Let relative-time-element accept "auto"
  3. Add an extra (stable) "lang" attribute on <body>, then relative-time-element will find it by its this.closest('[lang]')?.getAttribute('lang')
@wxiaoguang commented on GitHub (Jul 11, 2023): I will help to complete this issue's information: Reproducible steps: 1. Use Chrome to open a page with "relative-time" component, eg: the signed-in homepage try.gitea.io or a repo's home page like https://try.gitea.io/wxiaoguang/test 2. Switch the language to a non-English one 3. Click "Translate to ...." in the page's right-click context menu 4. Then switch to the "Detected language" 5. Then the "lang" attribute in `<html>` becomes "auto" (it's changed by the Google's translate plugin), it breaks https://github.com/github/relative-time-element * https://github.com/github/relative-time-element/blob/3a8f30f1a66edbe8d4e76c721ff1767c49b0ed27/src/relative-time-element.ts#L84-L90 * https://github.com/github/relative-time-element/blob/3a8f30f1a66edbe8d4e76c721ff1767c49b0ed27/src/relative-time-element.ts#L121-L130 Screenshot of the bug: <details> ![image](https://github.com/go-gitea/gitea/assets/2114189/7a63bb1c-a291-45af-9722-e6f255e00959) </details> ---- How to fix: 1. Let google fix its plugin (lang=auto seems incorrect) 2. Let relative-time-element accept "auto" 3. Add an extra (stable) "lang" attribute on `<body>`, then relative-time-element will find it by its `this.closest('[lang]')?.getAttribute('lang')`
Author
Owner

@yp05327 commented on GitHub (Mar 21, 2024):

It seems that this is not a bug from Gitea side, but from upstream?
Do we need to add the report-upstream label back?

@yp05327 commented on GitHub (Mar 21, 2024): It seems that this is not a bug from Gitea side, but from upstream? Do we need to add the `report-upstream` label back?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11043