Multi-language
The INFO module serves as the "mouthpiece" of the TechUI Core. It is responsible for managing all text outputs within the Wasm, ensuring that authorization status, error warnings, and legal statements are conveyed to developers or end-users in the correct language and with complete accuracy.
Unlike conventional frontend i18n frameworks (such as vue-i18n), the multi-language system of TechUI Core is independent and closed, designed to ensure that critical information remains tamper-proof.
Core Mechanism
Static Dictionary Construction
Multi-language data structures are constructed at the Rust level using HashMap and are hardcoded into the .wasm binary file during the compilation phase.
- Memory Residency: The dictionary is loaded into linear memory upon module initialization; subsequent text retrievals are nanosecond-level memory addressing operations.
- On-demand Compilation: Utilizing Rust's
#[cfg]feature, different versions of the component library (Prime/Base/Scifi) only include their corresponding text sets. For example, the free version physically lacks the authorization prompt text found in paid versions, thereby reducing the module size.
Language Synchronization Logic
The Wasm module does not directly monitor browser language changes; instead, it maintains synchronization with the host environment through Session Storage.
- Read: Upon initialization, Wasm automatically reads the
sysLangparameter fromsessionStorage. - Match: It supports three standard codes:
cn(Simplified),hk(Traditional), anden(English). - Fallback: If parameters are missing or unsupported, it defaults back to
cn(or as determined by the build configuration).
Text Categories
The text managed by the INFO module is primarily divided into the following three categories:
🎫 Licensing Status
The most critical feedback information used to clarify the current authorization level.
- Free/Paid Distinction: Clearly indicates whether the current state is "Free Version," "Trial Mode," or "Official Authorization".
- Validity Prompts: Such as
[XX] days until expirationorPermanently Valid. - Authorization Chain: Displays the complete legal chain:
This license is authorized by [Authorizer] to [Authorized Party].
🛡️ Errors & Meltdown
When the VALID module detects an anomaly, these texts are called for console warnings.
- Environmental Errors: Such as
Current domain does not match the domain restricted by the licenseorThe current license is only for internal network deployment. - Integrity Errors: Such as
Detected that the native browser methods relied upon by the WASM module have been tampered with. - Configuration Errors: Such as
License configuration key is incorrect or missing.
⚖️ Legal Statements
Hardcoded legal boundaries used to protect intellectual property and avoid compliance risks.
- Copyright Notice: Explicitly prohibits the extraction of assets or source code.
- Compliance Restrictions: Includes blacklist warnings for specific regions, which are special risk control texts based on export controls or anti-fraud strategies.
Information Output Channels
The INFO module does not directly manipulate the DOM to display text (except for watermarks); it typically outputs information through the following methods:
- Console Badge: Prints styled copyright information in the developer tools console.
- tuiCoreInfo(): Returns a complete structured information object when a developer actively calls this function in the console.
- Error Object: When a Panic or Meltdown occurs, the thrown Error Message originates from this module.