From 875203516e5d1908c38e8b94a2109ce94f3b2366 Mon Sep 17 00:00:00 2001 From: MichaelWangzitao Date: Mon, 8 Mar 2021 15:11:41 +0800 Subject: [PATCH 1/7] Update the index.html to address the i18n issue Update the MiniApp Manifest index.html to address the i18n issues, I rewrite section 6 add a subsection to provide an i18n solution. --- index.html | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/index.html b/index.html index 33c6e16..03e537c 100644 --- a/index.html +++ b/index.html @@ -1102,6 +1102,11 @@

reason member

+
+

+ Internationalization + 国际化方案 +

Localizable members @@ -1121,6 +1126,92 @@

  • MiniAppWidgetResource.name
  • +
    +

    + I18n Solution + I18n方案 +

    +

    + To support the multiple languages, attributes such as name, short_name, and description can be set as a reference to a string resource. Typically, string resources are stored in the corresponding multi-language JSON file in the MiniApp package's i18n directory. The multi-language file’s name complies with IETF BCP 47.

    +

    + 为了支持多语言能力name, short_name, description等参数可以被设置为字符串资源的索引。通常情况下字符串资源被保存在MiniApp包i18n目录下相应的多语言文件中。多语言文件命名规范符合IETF BCP 47。 +

    + +

    + The following example describes two simple multi-language files: +

    +

    + 以下例子描述2个简单的多语言文: +

    + +

    i18n/en-US.json

    +
    {
    +  "strings": { 
    +    "name":"miniapp demo",
    +    "short_name":"MD",
    +    "description_application":"MiniApp Demo",
    +  },
    +  "files": {
    +    "images":"image/en_picture.PNG",
    +  },  
    +} 
    +  
    + +

    i18n/zh-Hans.json

    +
    {
    +  "strings": { 
    +    "name":"小程序试用版",
    +    "short_name":"小程序",
    +    "description_application":"迷你程序试用版本",
    +  },
    +  "files": {
    +    "images":"image/zh_picture.PNG",
    +  },  
    +} 
    +  
    + +

    + Developers can refer to a resource using the syntax $string:‹resource-name›, for example, "decscription": "$string:description_application". +

    +

    + 用户可以使用$string:‹resource-name›的方式引用字符串资源,例如:"decscription": "$string:description_application". +

    + +

    + The following example describes a simple manifest fragment that supports multiple languages capability: +

    +

    + 以下例子描述一个简单的支持多语言的manifest片段: +

    + +
    {
    +  "dir":"ltr",
    +  "lang":"en-US",
    +  "appID":"org.w3c.miniapp",
    +  "name":"$string:name",
    +  "short_name":"$string:short_name",
    +  "versionName":"1.0.0",
    +  "versionCode":"1",
    +  "description":"$string:description_application",
    +  "icons"[
    +    {
    +      "src":"common/icons/icon.png",
    +      "sizes":"48x48",	  
    +	} 
    +  ],
    +  ...  
    +} 
    +  
    + +

    + In this way, when reading the MiniApp Manifest, the MiniApp processor, such as marketplace, can extract the string resource information from the corresponding language file in the MiniApp package's i18n directory according to the configuration information of itself and generates the localized description. For example, if the configuration information of the marketplace is simplified Chinese, the marketplace parses the "name": "$string: name" statement in the manifest and extracts sting: name information from the zh-Hans.json file in the MiniApp package's i18n directory. And then it generates the localized name of the MiniApp: 小程序试用版。 +

    +

    + 通过上述方式,应用市场在读取应用manifest时,会根据自身的配置信息,从i18n目录下相应的语言文件,提取字符串信息,生成本地描述。例如 应用市场配置信息为汉语简体,则应用市场会解析manifest中"name": "$string:name"语句,从i18n目录的zh-Hans.json文件,提取sting:name信息:小程序试用版,并在应用市场生成该应用的本地化名称:小程序试用版。 +

    + +
    +

    From 9e0cc4f9ca3b7e4b992eea8ca207fed4c04f5c0a Mon Sep 17 00:00:00 2001 From: MichaelWangzitao Date: Wed, 17 Mar 2021 14:55:48 +0800 Subject: [PATCH 2/7] Update index.html Fix the format issue on line 1104 --- index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 03e537c..3304ce4 100644 --- a/index.html +++ b/index.html @@ -1102,11 +1102,11 @@

    reason member

    -
    -

    - Internationalization - 国际化方案 -

    +
    +

    + Internationalization + 国际化方案 +

    Localizable members From a8c1bf911229d81589d62c752db960c98957e23d Mon Sep 17 00:00:00 2001 From: MichaelWangzitao Date: Wed, 17 Mar 2021 15:07:14 +0800 Subject: [PATCH 3/7] Update index.html --- index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 3304ce4..cf11174 100644 --- a/index.html +++ b/index.html @@ -1104,13 +1104,13 @@

    reason member

    - Internationalization - 国际化方案 + Internationalization + 国际化方案

    - Localizable members - 可本地化属性 + Localizable members + 可本地化属性

    The following members are localizable and share the same default configuration of dir and lang if not otherwise specified. @@ -1128,8 +1128,8 @@

    - I18n Solution - I18n方案 + I18n Solution + I18n方案

    To support the multiple languages, attributes such as name, short_name, and description can be set as a reference to a string resource. Typically, string resources are stored in the corresponding multi-language JSON file in the MiniApp package's i18n directory. The multi-language file’s name complies with IETF BCP 47.

    From f4856603cc28852605233e9de79399f007c84dac Mon Sep 17 00:00:00 2001 From: MichaelWangzitao Date: Wed, 17 Mar 2021 15:29:29 +0800 Subject: [PATCH 4/7] Update index.html Updated to fix json example format. --- index.html | 69 +++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/index.html b/index.html index cf11174..99fe8c3 100644 --- a/index.html +++ b/index.html @@ -1145,30 +1145,34 @@

    i18n/en-US.json

    -
    {
    -  "strings": { 
    -    "name":"miniapp demo",
    -    "short_name":"MD",
    -    "description_application":"MiniApp Demo",
    -  },
    -  "files": {
    -    "images":"image/en_picture.PNG",
    -  },  
    -} 
    -  
    + +
    +	  {
    +	   "strings": { 
    +       "name":"miniapp demo",
    +       "short_name":"MD",
    +       "description_application":"MiniApp Demo",
    +       },
    +       "files": {
    +       "images":"image/en_picture.PNG",
    +       },  
    +      } 
    +	  

    i18n/zh-Hans.json

    -
    {
    -  "strings": { 
    -    "name":"小程序试用版",
    -    "short_name":"小程序",
    -    "description_application":"迷你程序试用版本",
    +	   
    +	  
    +{
    +  "strings": { 
    +    "name":"小程序试用版",
    +    "short_name":"小程序",
    +    "description_application":"迷你程序试用版本",
       },
    -  "files": {
    -    "images":"image/zh_picture.PNG",
    +  "files": {
    +    "images":"image/zh_picture.PNG",
       },  
     } 
    -  
    +

    Developers can refer to a resource using the syntax $string:‹resource-name›, for example, "decscription": "$string:description_application". @@ -1184,24 +1188,25 @@

    以下例子描述一个简单的支持多语言的manifest片段:

    -
    {
    -  "dir":"ltr",
    -  "lang":"en-US",
    -  "appID":"org.w3c.miniapp",
    -  "name":"$string:name",
    -  "short_name":"$string:short_name",
    -  "versionName":"1.0.0",
    -  "versionCode":"1",
    -  "description":"$string:description_application",
    -  "icons"[
    +	  
    +{
    +  "dir":"ltr",
    +  "lang":"en-US",
    +  "appID":"org.w3c.miniapp",
    +  "name":"$string:name",
    +  "short_name":"$string:short_name",
    +  "versionName":"1.0.0",
    +  "versionCode":"1",
    +  "description":"$string:description_application",
    +  "icons"[
         {
    -      "src":"common/icons/icon.png",
    -      "sizes":"48x48",	  
    +      "src":"common/icons/icon.png",
    +      "sizes":"48x48",	  
     	} 
       ],
       ...  
     } 
    -  
    +

    In this way, when reading the MiniApp Manifest, the MiniApp processor, such as marketplace, can extract the string resource information from the corresponding language file in the MiniApp package's i18n directory according to the configuration information of itself and generates the localized description. For example, if the configuration information of the marketplace is simplified Chinese, the marketplace parses the "name": "$string: name" statement in the manifest and extracts sting: name information from the zh-Hans.json file in the MiniApp package's i18n directory. And then it generates the localized name of the MiniApp: 小程序试用版。 From 6aee4f079146c2d204e099354de90a5940f4d393 Mon Sep 17 00:00:00 2001 From: MichaelWangzitao Date: Wed, 17 Mar 2021 15:40:33 +0800 Subject: [PATCH 5/7] Update index.html Fixed the json example format --- index.html | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index 99fe8c3..91dbc35 100644 --- a/index.html +++ b/index.html @@ -1188,25 +1188,24 @@

    以下例子描述一个简单的支持多语言的manifest片段:

    -
    -{
    -  "dir":"ltr",
    -  "lang":"en-US",
    -  "appID":"org.w3c.miniapp",
    -  "name":"$string:name",
    -  "short_name":"$string:short_name",
    -  "versionName":"1.0.0",
    -  "versionCode":"1",
    -  "description":"$string:description_application",
    -  "icons"[
    -    {
    -      "src":"common/icons/icon.png",
    -      "sizes":"48x48",	  
    -	} 
    -  ],
    -  ...  
    -} 
    -
    +
    +              {
    +                "dir": "ltr",
    +                "lang": "en-US",
    +                "appID": "org.w3c.miniapp",
    +                "name": "$string:name",
    +                "short_name": "string:short_name",
    +                "versionName": "1.0.0",
    +                "versionCode": 1,
    +                "description": "$string:description_application",
    +                "icons": [
    +                  {
    +                    "src": "common/icons/icon.png",
    +                    "sizes": "48x48"
    +                  }
    +                ]
    +              }
    +            

    In this way, when reading the MiniApp Manifest, the MiniApp processor, such as marketplace, can extract the string resource information from the corresponding language file in the MiniApp package's i18n directory according to the configuration information of itself and generates the localized description. For example, if the configuration information of the marketplace is simplified Chinese, the marketplace parses the "name": "$string: name" statement in the manifest and extracts sting: name information from the zh-Hans.json file in the MiniApp package's i18n directory. And then it generates the localized name of the MiniApp: 小程序试用版。 From a92c9642b8e9ffe502a18ffd4aecff4d3ee91a52 Mon Sep 17 00:00:00 2001 From: MichaelWangzitao Date: Wed, 17 Mar 2021 16:50:41 +0800 Subject: [PATCH 6/7] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 91dbc35..42d0a9b 100644 --- a/index.html +++ b/index.html @@ -1208,7 +1208,7 @@

    - In this way, when reading the MiniApp Manifest, the MiniApp processor, such as marketplace, can extract the string resource information from the corresponding language file in the MiniApp package's i18n directory according to the configuration information of itself and generates the localized description. For example, if the configuration information of the marketplace is simplified Chinese, the marketplace parses the "name": "$string: name" statement in the manifest and extracts sting: name information from the zh-Hans.json file in the MiniApp package's i18n directory. And then it generates the localized name of the MiniApp: 小程序试用版。 + In this way, when reading the MiniApp Manifest, the MiniApp processor, such as marketplace, can extract the string resource information from the corresponding language file in the MiniApp package's i18n directory according to the configuration information of itself and generates the localized description. For example, if the configuration information of the marketplace is simplified Chinese, the marketplace parses the "name": "$string: name" statement in the manifest and extracts string: name information from the zh-Hans.json file in the MiniApp package's i18n directory. And then it generates the localized name of the MiniApp: 小程序试用版。

    通过上述方式,应用市场在读取应用manifest时,会根据自身的配置信息,从i18n目录下相应的语言文件,提取字符串信息,生成本地描述。例如 应用市场配置信息为汉语简体,则应用市场会解析manifest中"name": "$string:name"语句,从i18n目录的zh-Hans.json文件,提取sting:name信息:小程序试用版,并在应用市场生成该应用的本地化名称:小程序试用版。 From dfaf775960126e1a98081b16b86a4ecf7d432556 Mon Sep 17 00:00:00 2001 From: MichaelWangzitao Date: Wed, 17 Mar 2021 16:52:55 +0800 Subject: [PATCH 7/7] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 42d0a9b..940a36b 100644 --- a/index.html +++ b/index.html @@ -1211,7 +1211,7 @@

    In this way, when reading the MiniApp Manifest, the MiniApp processor, such as marketplace, can extract the string resource information from the corresponding language file in the MiniApp package's i18n directory according to the configuration information of itself and generates the localized description. For example, if the configuration information of the marketplace is simplified Chinese, the marketplace parses the "name": "$string: name" statement in the manifest and extracts string: name information from the zh-Hans.json file in the MiniApp package's i18n directory. And then it generates the localized name of the MiniApp: 小程序试用版。

    - 通过上述方式,应用市场在读取应用manifest时,会根据自身的配置信息,从i18n目录下相应的语言文件,提取字符串信息,生成本地描述。例如 应用市场配置信息为汉语简体,则应用市场会解析manifest中"name": "$string:name"语句,从i18n目录的zh-Hans.json文件,提取sting:name信息:小程序试用版,并在应用市场生成该应用的本地化名称:小程序试用版。 + 通过上述方式,应用市场在读取应用manifest时,会根据自身的配置信息,从i18n目录下相应的语言文件,提取字符串信息,生成本地描述。例如 应用市场配置信息为汉语简体,则应用市场会解析manifest中"name": "$string:name"语句,从i18n目录的zh-Hans.json文件,提取string:name信息:小程序试用版,并在应用市场生成该应用的本地化名称:小程序试用版。