Internationalization Support

12009

Overview

The internationalization support of software refers to the ability of the software to provide a localized user experience for users from different languages and regions. This typically involves text translation, date and number formats, currency formats, and calculations of time and dates. In today's globalized world, internationalization support has become increasingly important.

Internationalization support brings the following benefits:

  • Expanding User Base: By providing a localized user experience, more international users can be attracted.
  • Improving User Satisfaction: Users can use familiar languages and formats, which enhances user satisfaction.
  • Compliance with Regulatory Requirements: In certain regions, providing a localized user experience is a regulatory requirement.

Internationalization Support in JianghuJS

Built-in i18n Support

The built-in i18n (internationalization) support allows developers to easily add multilingual support to applications.

Flexible Language Switching

Allows dynamic language switching at runtime, which is very useful for creating multilingual applications.

Rich Localization Options

Supports localized formats for dates, currency, etc., providing users with a localized experience.

  • Date Localization (dayjs)

    // By default, Day.js only includes the English language configuration. You can load other localization language configurations as needed.
    //<script src="https://unpkg.com/dayjs@1.8.21/dayjs.min.js"></script>   integrated in jianghujs
    <script src="https://unpkg.com/dayjs@1.8.21/locale/zh-cn.js"></script>
    
    // Once a language configuration is loaded, it is available. To change the global language configuration, simply call dayjs.locale and pass in the name of a loaded language configuration.
    dayjs.locale('zh-cn') 
    dayjs.locale('en') 
  • Currency Localization (currency.js)

    // Import resources (integrated in jianghu-erp)
    //<script src="https://unpkg.com/currency.js@~2.0.0/dist/currency.min.js"></script>
    
    // Internationalization
    currency(1.23, { separator: " ", decimal: ",", symbol: "€" });
    
    // Set factory functions
    const USD = value => currency(value, { symbol: "$", precision: 2 });
    const JPY = value => currency(value, { symbol: "¥", precision: 0 });
    const GAS = value => currency(value, { precision: 3 });
    
    USD(1234.56).format(); // "$1,234.56"
    JPY(1234.56).format(); // "¥1,235"
    GAS(1234.56).format(); // "$1,234.560"