Skip to content

Mini auto-inline translation silently suppressed for short CJK posts #1531

Description

@FreelimbOO

Site

No response

Version

No response

Instance

No response

Browser

Device 1

  • OS: Android 16
  • Device Motorola Moto G Stylus 2026
  • Browser: Chrome 149.0.7827.103
    Device 2
  • OS: 26.5
  • Device: iPhone 14
  • Browser: Safari

Bug description

Environment

  • Server: GoToSocial (self-hosted)
  • No Translang instances configured
  • Mobile Chrome — 'LanguageDetector' in self and 'Translator' in self both return false
  • Translation backend: MyMemory fallback

What happened

Short Chinese posts (e.g. 4-character posts tagged lang="zh" by GoToSocial) do not show the auto-inline mini translation block in the Home timeline, even when contentTranslationAutoInline is enabled. Longer Chinese posts on the same timeline translate correctly. No error is shown — it silently shows nothing.

Root cause (partially identified)

In translation-block.jsx, the mini render path has this guard:

if (
  !!translatedContent &&
  translatedContent.trim() !== text.trim() &&
  detectedLang !== targetLangText   // ← this can suppress valid translations
) {

When detectedLang ends up equal to targetLangText (both "English" in our case), the block is suppressed even though translatedContent is a valid translation. We were not able to fully pin down why detectedSourceLanguage returned "en" for short Chinese posts in our setup — Chrome AI is absent, posts are correctly tagged zh, and the CJK unicode detection should return 'zh'. The exact trigger remains unclear.

Additional finding

GoToSocial sometimes incorrectly tags Chinese posts as lang="en". The CJK heuristic in detectLang() already guards against this for differentLanguage detection, but it's worth noting for completeness.

What we tried

Removing the detectedLang !== targetLangText condition and relying solely on translatedContent.trim() !== text.trim() fixed the issue for us. However we acknowledge this has its own edge cases:

  • False positive: a wrongly-tagged English post could show a spurious "translation" if MyMemory returns slightly modified text
  • False negative: if MyMemory echoes the input on a soft failure, the mini block is silently suppressed

The mini block is particularly exposed to these edge cases since it targets short posts (≤140 chars) where language detection is least reliable — as the existing code comment notes, both tinyld/light and Chrome's LanguageDetector can misidentify short CJK text.

We're not confident our fix is the right long-term solution — raising this in case you have more context on the intended behaviour or a better fix in mind.

To reproduce

  1. Go to "Settings..." on a mobile browser.
  2. Checked "Auto refresh timeline posts" and "Auto inline translation"
  3. Post "自動中翻英好像壞掉了"
  4. No inline translated into en.

Expected behavior

There must be some English words pop up like "Automatic Chinese translation seems to be broken"

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions