Skip to content

Fix i18n by merging plugin translations and using short locale codes#317

Closed
Claude wants to merge 4 commits intomainfrom
claude/fix-hotcrm-internationalization-issue
Closed

Fix i18n by merging plugin translations and using short locale codes#317
Claude wants to merge 4 commits intomainfrom
claude/fix-hotcrm-internationalization-issue

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Mar 24, 2026

Description

Fixed internationalization not working in HotCRM. The API was only returning HR translations instead of all plugin translations, and locale codes were using BCP 47 format (zh-CN, ja-JP) instead of the short codes (zh, ja) expected by the runtime.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • CI/CD update

Related Issues

Resolves internationalization issues reported in deployment.

Changes Made

1. Locale Code Normalization

  • Changed supportedLocales from ['en', 'zh-CN', 'ja-JP'] to ['en', 'zh', 'ja']
  • Renamed translation files: zh-CN.tszh.ts, ja-JP.tsja.ts across all 6 packages
  • Updated translation bundle keys and variable names to use short codes
  • Updated all i18n test expectations

2. Translation Bundle Merging

  • Added mergeTranslationBundles() helper to deep-merge translations from all plugins
  • Previously: 6 separate bundles with same namespace overwrote each other (only HR survived)
  • Now: Single merged bundle contains all translations from CRM, Finance, Marketing, Products, Support, and HR
// Before: Array of bundles (overwrites with same namespace)
translations: [
  CrmTranslations,
  FinanceTranslations,
  // ... only last one (HR) was kept
]

// After: Merged single bundle
const HotCRMTranslations = mergeTranslationBundles(
  CrmTranslations, FinanceTranslations, MarketingTranslations,
  ProductsTranslations, SupportTranslations, HRTranslations
);
translations: HotCRMTranslations

3. Files Modified

  • objectstack.config.ts: Added merge function, updated i18n config
  • api/[[...route]].ts: Same changes for Vercel handler
  • All 6 plugin translation files and tests

Testing

  • Unit tests pass (npm test)
  • Linting passes (npm run lint)
  • Build succeeds (npm run build)
  • Manual testing completed
  • New tests added (if applicable)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

The reference implementation (https://github.com/objectstack-ai/objectui/tree/main/examples/crm) uses short locale codes and a single merged translation object. HotCRM now follows the same pattern. The API endpoint /api/v1/i18n/translations/zh now returns complete translations from all business plugins.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • hotcrm-demo-git-claude-fix-hotcrm-internati-21b469-object-stack.vercel.app
    • Triggering command: /usr/bin/curl curl -s REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

hotcrm 国际化未生效,参考 https://github.com/objectstack-ai/objectui/tree/main/examples/crm

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hotcrm-demo Ready Ready Preview, Comment Mar 24, 2026 5:31am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hotcrm Ignored Ignored Mar 24, 2026 5:31am

Request Review

@Claude Claude AI changed the title [WIP] Fix hotcrm internationalization not functioning Fix i18n not working by adding namespace to configuration Mar 24, 2026
@Claude Claude AI requested a review from hotlong March 24, 2026 03:59
@Claude Claude AI changed the title Fix i18n not working by adding namespace to configuration Fix i18n by switching from BCP 47 locale codes to short codes Mar 24, 2026
Previously, all 6 plugin translation bundles were passed as an array with
the same namespace 'hotcrm', causing them to overwrite each other. Only
the last bundle (HR) was registered, which is why the API only returned
HR translations.

Now, all translation bundles are deep-merged per locale before being
passed to the i18n configuration. This ensures all translations from
CRM, Finance, Marketing, Products, Support, and HR are available under
the 'hotcrm' namespace.

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Agent-Logs-Url: https://github.com/objectstack-ai/hotcrm/sessions/a22ae23a-82f3-489c-b378-d58b20bee874
@Claude Claude AI changed the title Fix i18n by switching from BCP 47 locale codes to short codes Fix i18n by merging plugin translations and using short locale codes Mar 24, 2026
@hotlong hotlong closed this Mar 24, 2026
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.

2 participants