Skip to content

Fixed Translation Bug On Task Completeness Question#7208

Open
PiRaNg-1256 wants to merge 1 commit into
hotosm:developfrom
PiRaNg-1256:develop
Open

Fixed Translation Bug On Task Completeness Question#7208
PiRaNg-1256 wants to merge 1 commit into
hotosm:developfrom
PiRaNg-1256:develop

Conversation

@PiRaNg-1256
Copy link
Copy Markdown

@PiRaNg-1256 PiRaNg-1256 commented Mar 31, 2026

What type of PR is this?

Bug Fix

Related Issue

Fixes #7108

Describe this PR

This PR fixes a reported "bizarre" translation issue where Czech users saw incorrect terms like "JOB STATUS" (instead of TASK STATUS), "Again" (instead of Yes), and "Yes" (instead of No).

Root Cause: The application was missing the lang attribute on the element. This caused browsers (specifically Chrome) to attempt auto-detection of the page language. In some cases, the browser incorrectly guessed the language or attempted to auto-translate short strings (like "Ano"/"Ne") into English using incorrect mappings, leading to hallucinations like "Again" and "Yes".

Solution:

index.html: Added a default lang="en" to the tag.
App.js: Added a useEffect hook to dynamically update document.documentElement.lang whenever the application locale changes. This informs the browser exactly what language is being displayed, preventing inappropriate auto-translation triggers.

Review Guide

Open the application and change the language to Czech (or any other language).
Inspect the page source/DOM using Developer Tools.
Verify that the tag has the correct lang attribute (e.g., ).
Switch back to English and verify it updates to .

…entElement.lang and set lang = en as default
@sonarqubecloud
Copy link
Copy Markdown

@PiRaNg-1256 PiRaNg-1256 changed the title Added a useEffect hook in App.js to dynamically update document.docum… Fixed Translation Bug On Task Completeness Question Mar 31, 2026
@ramyaragupathy ramyaragupathy requested a review from sumitdahal7 May 6, 2026 08:59
Copy link
Copy Markdown
Collaborator

@sumitdahal7 sumitdahal7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. This is worth doing since setting the document lang helps prevent browser auto-translation issues and improves accessibility.

A couple of changes before merge:

  1. Please normalize the locale before assigning it to document.documentElement.lang. Some supported
    locales use underscores internally, e.g. nl_NL and zh_TW, but HTML lang expects BCP 47 tags like
    nl-NL and zh-TW.
document.documentElement.lang = locale ? locale.replace(/_/g, '-') : 'en';
  1. App.js already has a root wrapper with lang={locale}. Please either apply the same normalized value
    there too, or remove the div-level lang if is now the source of truth.
  2. Please remove the package-lock.json change. This repo uses Yarn (frontend/yarn.lock), and this fix
    should not require dependency changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] rare translation issue on task completness question

2 participants