Skip to content

Custom Extension (Outlook)

The multi-language module of TechUI has reserved complete extension interfaces in its underlying design. Although the official version currently only includes three core language packages—Simplified Chinese, Traditional Chinese, and English—future versions plan to open custom registration and merging strategies to fully adapt the system to business needs.

Design Goals

The expansion functionality is designed to address two core scenarios:

  1. Adding New Languages: When an application needs to support languages not officially included, such as Japanese, French, or German, new language packages can be registered through the expansion interface.
  2. Business Copy Reuse: Developers will be allowed to inject translation copy for business components (such as specific industry terminology) into the TechUI multi-language system. This enables the unified use of the i18n() function throughout the project without needing to introduce third-party i18n libraries.

Expected Mechanisms

Registering New Languages

The system will expose APIs similar to registerLocale or addLocale. Developers can load and register new language data according to TechUI's standard semantic structure or a custom structure.

Once registration is successful, the language will automatically appear in the language switcher's candidate list. The system will also automatically handle the persistence and loading logic for that language.

Overwriting and Merging

For existing languages (such as cn), the extension functionality will support a "deep merge" strategy.

  • Copy Overwriting: If users are not satisfied with TechUI's default "Confirm/Cancel" copy, they can overwrite the official copy by injecting a Key with the same name.
  • Incremental Supplementation: New business nodes (for example, adding a myBusiness node) can be mounted onto the existing language tree without affecting TechUI's original components or universal nodes.

Business Integration

Once the extension functionality is complete, the i18n function will become the sole translation entry point for the entire application.

This means you can call business copy in your own business components just like calling system copy:

javascript
// Assuming you have registered a custom business copy 'order.status.paid'
import { inject } from 'vue';

const { i18n } = inject('$global');

// Unified call, no need to distinguish between TechUI copy and business copy
const statusText = i18n('order.status.paid');

This design ensures highly unified translation logic within the application, reduces maintenance costs, and shares TechUI's existing dynamic interpolation and debugging capabilities.

Released under the MIT License.