Skip to content

i18n settings reset after page refresh / scripts load out of order #12

Description

@li-zhenyu

Bug Description

When using ReactCusdis component, the i18n language settings fail after page refresh. The comment widget reverts to the default language (English) even when a specific language is configured via the lang prop.
Expected Behavior

The widget should display in the language specified by the lang prop consistently across page refreshes.

Actual Behavior

  1. First load works correctly with the specified language
  2. After page refresh, the widget falls back to English
  3. The issue appears to be caused by scripts loading in parallel without guaranteed order

Root Cause Analysis

The current implementation loads both the main script and language script in parallel:

useScript(`${host}/js/cusdis.es.js`)
useScript(props.lang ? `${host}/js/widget/lang/${props.lang}.js` : '')

This causes a race condition where:

  1. The language script may load and execute before the main script
  2. The main script may overwrite the language configuration when it loads later
  3. renderCusdis() may be called before the language script has fully initialized

Steps to Reproduce

  1. Use ReactCusdis component with lang="zh" (or any non-English language)
  2. Load the page initially → language works correctly
  3. Refresh the page → language resets to English

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions