Location:Index > News >

Multi-language Configuration for nsNiuniuSkin Plugin

Browsing History: 80Date: 2023-12-04

Today, we bring you the multi-language configuration feature, which can be considered a significant improvement for nsNiuniuSkin. We hope it proves helpful to everyone.

nsNiuniuSkin, through its self-developed multilingual configuration engine, simplifies the process of configuring languages for installers. By directly setting language translation configuration files, complete multi-language support for the entire installer can be achieved effortlessly!

Let's first take a look at the English version of the interface:

Background Introduction

We have always talked about providing multi-language support for the installer beautification component, but there hasn't been much time until now. Nevertheless, many friends have implemented multi-language functionality through script configuration.

A few days ago, after carefully examining the language features implemented by netizens and experimenting with them personally, I found several drawbacks to purely script-based solutions:

nsNiuniuSkin Multilingual Implementation Principle

Based on considerations of these drawbacks, we believe this is not a good multilingual solution. So, I immediately started researching and implementing the multilingual implementation solution for nsNiuniuSkin. Our goal is: under normal circumstances, users do not need to adjust the script manually based on different languages. Instead, all configurations for different languages should be placed in configuration files.

After various attempts, we achieved this goal, minimizing the development workload for installer developers when dealing with multiple languages. To reduce manual intervention in handling multiple languages and script writing, we referred to the NSIS multilingual file configuration and, in combination with nsNiuniuSkin, implemented a new multilingual engine. The core ideas are as follows:

In practical use, you only need to configure the language file to be translated, translate [msgid] for the respective language, and package with a single click.

nsNiuniuSkin Multilingual Configuration Method

After saying so much, let's take a look at the actual configuration process. The following example uses our nsNiuniuSkin interface online design engine installer to illustrate. It only takes a few simple steps:

  1. Define the product name in different languages in the nsi file.

    This product name is relatively rigorous, and subsequent translated text will also reference the product name in different languages, so it needs to be defined carefully.

    # ====================== Custom Macro Product Information ===============================
    !define PRODUCT_NAME           		"利洽科技截图控件"
    !define PRODUCT_NAME_EN           	"Leeqia ScreenCapture"
    
    
  2. In the lang_name.ini file, configure which languages are currently available.

    [lang_names]
    1033=English
    2052=简体中文
    

    We use the LanguageID based on language as the identification KEY in multilingualism (for example, 2052 for Simplified Chinese and 1033 for English), matching the LanguageID obtained by the system. Here, we only provide displays for Chinese and English. If there are more language types, add the corresponding LanguageID and the corresponding language name (there is a lot of information on the internet about the LanguageID of different languages, please refer to it!).

  3. Configure the translation of messages in different languages.

    Chinese translation file (lang_msg_2052.ini) is as follows:

    [lang_msgs]
    msg.title=${PRODUCT_NAME}安装程序
    msg.productname=${PRODUCT_NAME} 
    msg.welcome=欢迎使用
    msg.install=快速安装
    msg.install_short=安装
    msg.cancel=取消
    msg.agree=我已阅读并同意
    msg.agree1=接受<c #0091FF>《用户许可协议》</c>
    msg.licence=《用户许可协议》
    msg.autostart=开机自动启动
    msg.createshortcut=添加桌面快捷方式
    msg.customize=自定义选项
    msg.browse=浏览
    msg.browsetitle=请选择安装路径
    msg.finish=完成
    msg.open=打开
    msg.installing=正在安装...
    msg.back = 返回
    msg.uninstall=卸载
    msg.uninstall_ex="卸载"
    msg.uninstalling=正在卸载...
    msg.welcomeback=感谢使用
    msg.spaceneed=所需空间:
    msg.spcaceleft=剩余空间:
    msg.illegalpath=路径非法
    msg.illegalpath1=路径非法,请使用正确的路径安装!
    msg.alreadyrunwarn=正在运行,请退出后重试!
    msg.spacenotenough=目标磁盘空间不足,请使用其他的磁盘安装!
    msg.downloading=正在下载安装包...
    msg.downloading1=正在下载安装包:
    msg.totalsize=总大小:
    msg.installnotfinish=安装尚未完成,您确定退出安装么?
    msg.uninstallnotfinish=卸载尚未完成,您确定退出卸载么?
    msg.notice=提示
    msg.readconfigfailed=读取配置文件失败
    msg.downloadfailed=下载失败
    msg.wrongdownloadsize=初始设定的安装包大小不正确
    msg.serverstatuserror=服务器状态错误:
    msg.ok=确定
    
    

    English translation file (lang_msg_1033.ini) is as follows:

    [lang_msgs]
    msg.title=${PRODUCT_NAME_EN} Setup
    msg.productname=${PRODUCT_NAME_EN} 
    msg.welcome="Welcome to use "
    msg.install=Install
    msg.install_short=Install
    msg.cancel=Cancel
    msg.agree=I have agreed 
    msg.agree1=Accept<c #0091FF>《License Agreement》</c>
    msg.licence=《License Agreement》
    msg.autostart=Auto Start
    msg.createshortcut=Add Shortcut
    msg.customize=Customize
    msg.browse=Browse
    msg.browsetitle=Please select install path
    msg.finish=Finish
    msg.open=Open
    msg.installing=Installing...
    msg.back = Back
    msg.uninstall=Uninstall
    msg.uninstall_ex="Uninstall "
    msg.uninstalling=Uninstalling...
    msg.welcomeback="Thanks to use "
    msg.spaceneed=Space Required: 
    msg.spcaceleft=Space Left: 
    msg.illegalpath=Illegal Path
    msg.illegalpath1=Illegal path, please use the right path!
    msg.alreadyrunwarn=is running, please close and retry!
    msg.spacenotenough=Splace is not enough, please change to other Disk!
    msg.downloading=Downloading...
    msg.downloading1="Downloaded: "
    msg.totalsize="Total Size: "
    msg.installnotfinish=Install is not finished, quit now?
    msg.uninstallnotfinish=Uninstall is not finished, quit now?
    msg.notice=Notice
    msg.readconfigfailed=Read config failed
    msg.downloadfailed=download failed
    msg.wrongdownloadsize=package size invalid
    msg.serverstatuserror="server status error: "
    msg.ok=OK
    

    Here are a few points to note:

    • When referencing the product name constant, different languages need to reference different constants.

    • If there are more language types, add the corresponding language translation files and translate the text corresponding to the message ID.

    • For translated text with spaces before and after, it needs to be enclosed in double quotes.

    • With the template applied, the first three steps are sufficient; the subsequent steps are completed in the template.

  4. Replace text with message IDs in the script.

    In our template script, all scripts related to displaying text have already been replaced. The following is an example:

    nsNiuniuSkin::SetControlAttribute $hInstallDlg "instinfo" "text" "[msg.productname]"
    
  5. In the XML file of the interface configuration file, add the msgid attribute to controls with fixed text, which will be automatically updated by the engine.

    In our template script, all scripts related to displaying text have already been replaced. The following is an example:

    <CheckBox name="chkAutoRun" width="95" font="0" msgid="msg.autostart" text="Auto Start" />
    <CheckBox name="chkShotcut" padding="20,0,0,0" width="118" font="0" msgid="msg.createshortcut" text="Add Shortcut" />
    

    After this setting, the text on the corresponding controls will be automatically displayed based on the text corresponding to msgid in the language configuration file, without the need for manual settings.

  6. Use the new packaging engine to directly package, and a multi-language installer will be generated.

    During the generation process, we perform some tasks related to language settings, such as:

    • Generate different language texts after expanding constant macros and inject them into the installer engine.
    • Determine whether to display the language selection dropdown based on the configured number of languages.
    • The engine automatically recognizes the selected language and sets the corresponding control text properties.

Users don't have to worry about handling UI differences when configuring one or more languages; our multilingual engine handles it automatically. We will only display the language selection dropdown when configuring two or more languages.

Isn't the overall operation process simple? During the uninstallation process, the language used during installation is automatically recognized, and the corresponding language pack is used to display the uninstallation interface!

In different language switches, in fact, the code our NSIS script needs to handle is very minimal, mainly for setting the window title, resetting the license agreement, etc. To add a new language, you no longer need to adjust the script, just add a new language and translate the text.

Function ResetUIByLanguage
   nsNiuniuSkin::GetCurrentLangId
   Pop $0
   nsNiuniuSkin::ResetLicenseFile $hInstallDlg "licence_$0.rtf"
   # Get the real product name through the plugin, which will be used for subsequent actions such as writing to the registry and adding shortcuts.
   nsNiuniuSkin::TranslateMsg "[msg.productname]"
   Pop $PRODUCT_NAME
   nsNiuniuSkin::TranslateMsg "[msg.uninstall_ex]"
   Pop $UNINSTALL_NAME
   
   nsNiuniuSkin::AutoChangeControlTextByLanguage

   # Set some functional items to be modified on the start page.
   nsNiuniuSkin::SetControlAttribute $hInstallDlg "instinfo" "text" "[msg.productname]"
   nsNiuniuSkin::SetControlAttribute $hInstallDlg "welcomeinfo" "text" "[msg.welcome][msg.productname]"
   nsNiuniuSkin::SetControlAttribute $hInstallDlg "title" "text" "[msg.productname]"
   nsNiuniuSkin::SetWindowTitle $hInstallDlg "[msg.title]"
   
   Call ResetUIByLanguageEx
FunctionEnd

nsNiuniuSkin Multilingual Installer Effect

Based on the above configuration, the effects of the packaged installer are as follows:

Installation interface, automatically recognizes the current language, and supports switching to different languages (the carousel image is not replaced):

Uninstallation interface, automatically recognizes and applies the language used during installation:

You can also directly install the nsNiuniuSkin interface online design engine to see the actual effect:

http://www.ggniu.com/download/NSNiuniuSKin_DuiDesigner_Setup.exe

Conclusion

During the installation process, a beautiful UI often leaves a more lasting impression on customers about the installed product, reflecting the software service provider's focus and care on user experience! We hope our efforts can make installer creation a bit easier and more enjoyable!

May there be no difficult installers in the world!

Copyright © 2015 - 2023 SHENZHEN LEEQIA TECHNOLOGY CO., LTD All Rights Reserved