Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the index.html to address the i18n issue #12

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 97 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,13 @@ <h3><code>reason</code> member</h3>

<section>
<h2>
<span its-locale-filter-list="en" lang="en"><dfn>Localizable members</dfn></span>
<span its-locale-filter-list="zh-hans" lang="zh-hans"><dfn>可本地化属性</dfn></span>
<span its-locale-filter-list="en" lang="en">Internationalization</span>
<span its-locale-filter-list="zh-hans" lang="zh-hans">国际化方案</span>
</h2>
<section>
<h2>
<span its-locale-filter-list="en" lang="en">Localizable members</span>
<span its-locale-filter-list="zh-hans" lang="zh-hans">可本地化属性</span>
</h2>
<p its-locale-filter-list="en" lang="en">
The following members are localizable and share the same default configuration of <code>dir</code> and <code>lang</code> if not otherwise specified.
Expand All @@ -1121,6 +1126,96 @@ <h2>
<li><a>MiniAppWidgetResource.name</a></li>
</ul>
</section>
<section>
<h2>
<span its-locale-filter-list="en" lang="en">I18n Solution</span>
<span its-locale-filter-list="zh-hans" lang="zh-hans">I18n方案</span>
</h2>
<p its-locale-filter-list="en" lang="en">
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.</p>
<p its-locale-filter-list="zh-hans" lang="zh-hans">
为了支持多语言能力name, short_name, description等参数可以被设置为字符串资源的索引。通常情况下字符串资源被保存在MiniApp包i18n目录下相应的多语言文件中。多语言文件命名规范符合IETF BCP 47。
</p>

<p its-locale-filter-list="en" lang="en">
The following example describes two simple multi-language files:
</p>
<p its-locale-filter-list="zh-hans" lang="zh-hans">
以下例子描述2个简单的多语言文:
</p>

<p>i18n/en-US.json</p>
</div>
<pre class="example json">
Comment on lines +1147 to +1149
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>i18n/en-US.json</p>
</div>
<pre class="example json">
<pre class="example json" title="i18n/en-US.json">

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

<p>i18n/zh-Hans.json</p>
</div>
<pre class="example json">
Comment on lines +1162 to +1164
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>i18n/zh-Hans.json</p>
</div>
<pre class="example json">
<pre class="example json" title="i18n/zh-Hans.json">

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

<p its-locale-filter-list="en" lang="en">
Developers can refer to a resource using the syntax $string:&lsaquo;resource-name&rsaquo;, for example, "decscription": "$string:description_application".
</p>
<p its-locale-filter-list="zh-hans" lang="zh-hans">
用户可以使用$string:&lsaquo;resource-name&rsaquo;的方式引用字符串资源,例如:"decscription": "$string:description_application".
</p>

<p its-locale-filter-list="en" lang="en">
The following example describes a simple manifest fragment that supports multiple languages capability:
</p>
<p its-locale-filter-list="zh-hans" lang="zh-hans">
以下例子描述一个简单的支持多语言的manifest片段:
</p>

<pre class="example json">
{
"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"
}
]
}
</pre>

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

</section>
</section>

<section>
<h2>
Expand Down