Smart Site
Home Docs Smart Data Internationalization

Internationalization

Smart SCADA is fully bilingual, supporting English (en-US) and Simplified Chinese (zh-CN) out of the box. The frontend uses vue-i18n, and the backend has its own @ss-node/ss-i18n package for server-side translations.

Interface Screenshot

Internationalization - Language Switcher (12 locales) (English UI)

Captured from the live Smart Site system with the English UI. See the zh-CN counterpart for the Chinese-UI screenshot.

1. Frontend i18n (vue-i18n)

The frontend integrates vue-i18n with two locale message bundles:

  • ss-editor/packages/system/src/locales/zh-CN.json
  • ss-editor/packages/system/src/locales/en-US.json

The active locale is stored in the user's profile and persisted in localStorage. Switching the language in the UI immediately re-renders all visible text without a page reload.

2. Translation Key Conventions

Keys follow a hierarchical module.section.key pattern:

Pattern Scope Example
system.nav.* Sidebar navigation labels system.nav.devices
system.kb.* Knowledge base hints and module names system.kb.hints.devices
system.device.* Device page text system.device.title
system.alarm.* Alarm page text system.alarm.ack
common.* Shared buttons and labels common.save, common.cancel

Critical rule — nav.* keys drive menu item display text; system.xxx.* keys drive in-page text. Both must be added when introducing a new page, otherwise the menu shows the raw key string.

3. Adding Translations

When adding a new UI string:

  1. Pick a key following the convention above
  2. Add it to both zh-CN.json and en-US.json (the files must stay in sync)
  3. Reference it in the template with $t('system.device.title') or in script with t('...')
<template>
  <h1>{{ $t('system.device.title') }}</h1>
  <button>{{ $t('common.save') }}</button>
</template>

4. mergeLocaleMessage

For plugins and feature modules loaded on demand, use mergeLocaleMessage to inject translations at runtime without touching the core locale files:

const { mergeLocaleMessage } = useI18n()

mergeLocaleMessage('en-US', {
  myPlugin: {
    title: 'My Plugin',
    action: 'Run'
  }
})

This is how the editor plugin packages ship their own translations.

5. Backend i18n (ss-i18n)

The @ss-node/ss-i18n package provides server-side translation for:

  • API error messages (returned in the message field of the response envelope)
  • Email / SMS notification templates
  • System event descriptions

The backend resolves the user's language from the JWT lang claim or the Accept-Language header, then looks up the key in the matching JSON bundle. If a key is missing, it falls back to en-US and finally to the raw key.

6. Date, Number, and Unit Formatting

  • Dates use Intl.DateTimeFormat with the active locale
  • Numbers use Intl.NumberFormat for thousands separators
  • Measurement units come from the measurement-units dictionary (see Data Dictionary) and are localized

7. Operational Guidance

7.1 Finding Missing Translations

If a page shows a raw key (e.g. system.nav.databaseOps), the key is missing from one or both locale files. Search the JSON files for the key and add the entry.

7.2 Adding a New Language

  1. Copy en-US.json to <new-lang>.json
  2. Translate every value
  3. Register the locale in the i18n setup (createI18n({ locale, messages }))
  4. Add the language option to the user profile selector
  5. Mirror the data/dicts/<new-lang>/ folder for dictionary translations

8. FAQ

Q: A menu item displays system.nav.xxx instead of the label. A: The nav.xxx key is missing from zh-CN.json / en-US.json. Add it to both files and refresh. See AGENTS.md section 10.5 for the full menu registration checklist.

Q: The backend returns English errors even though the user set Chinese. A: Check that the JWT lang claim is set to zh-CN on login. If it is, confirm the key exists in the backend's zh-CN.json for @ss-node/ss-i18n.

Q: Can I override a translation without editing the core file? A: Yes — use mergeLocaleMessage at app startup or in a plugin to override specific keys. This survives core updates.

Q: How do I switch the default language for new users? A: Set the DEFAULT_LANG system config key (or environment variable) to zh-CN or en-US. New users inherit this default until they change their own preference.