• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 多语言支持<a name="ZH-CN_TOPIC_0000001164290702"></a>
2
3基于开发框架的应用会覆盖多个国家和地区,开发框架支持多语言能力后,可以让应用开发者无需开发多个不同语言的版本,就可以同时支持多种语言的切换,为项目维护带来便利。
4
5开发者仅需要通过[定义资源文件](#zh-cn_topic_0000001173324681_section733935013515)和[引用资源](#zh-cn_topic_0000001173324681_section522111116527)两个步骤,就可以使用开发框架的多语言能力;如果需要在应用中获取当前系统语言,请参考[获取语言](#zh-cn_topic_0000001173324681_section2872192475310)。
6
7## 定义资源文件<a name="zh-cn_topic_0000001173324681_section733935013515"></a>
8
9资源文件用于存放应用在多种语言场景下的资源内容,开发框架使用JSON文件保存资源定义。在[文件组织](js-framework-file.md)中指定的i18n文件夹内放置语言资源文件,其中语言资源文件的命名是由语言、文字、国家或地区的限定词通过中划线连接组成,其中文字和国家或地区可以省略,如zh-Hant-HK(中国香港地区使用的繁体中文)、zh-CN(中国使用的简体中文)、zh(中文)。命名规则如下:
10
11```
12language[-script-region].json
13```
14
15限定词的取值需符合下表要求。
16
17**表 1**  限定词取值要求
18
19<a name="zh-cn_topic_0000001173324681_table18887936123715"></a>
20<table><thead align="left"><tr id="zh-cn_topic_0000001173324681_row1288893623719"><th class="cellrowborder" valign="top" width="16.3%" id="mcps1.2.3.1.1"><p id="zh-cn_topic_0000001062847941_p933162572513"><a name="zh-cn_topic_0000001062847941_p933162572513"></a><a name="zh-cn_topic_0000001062847941_p933162572513"></a>限定词类型</p>
21</th>
22<th class="cellrowborder" valign="top" width="83.7%" id="mcps1.2.3.1.2"><p id="zh-cn_topic_0000001062847941_p0331102502517"><a name="zh-cn_topic_0000001062847941_p0331102502517"></a><a name="zh-cn_topic_0000001062847941_p0331102502517"></a>含义与取值说明</p>
23</th>
24</tr>
25</thead>
26<tbody><tr id="zh-cn_topic_0000001173324681_row198881636143719"><td class="cellrowborder" valign="top" width="16.3%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001062847941_p5331192542519"><a name="zh-cn_topic_0000001062847941_p5331192542519"></a><a name="zh-cn_topic_0000001062847941_p5331192542519"></a>语言</p>
27</td>
28<td class="cellrowborder" valign="top" width="83.7%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001062847941_p19331625202513"><a name="zh-cn_topic_0000001062847941_p19331625202513"></a><a name="zh-cn_topic_0000001062847941_p19331625202513"></a>表示设备使用的语言类型,由2~3个小写字母组成。例如:zh表示中文,en表示英语,mai表示迈蒂利语。</p>
29<p id="zh-cn_topic_0000001062847941_p633232516255"><a name="zh-cn_topic_0000001062847941_p633232516255"></a><a name="zh-cn_topic_0000001062847941_p633232516255"></a>详细取值范围,请查阅<strong id="zh-cn_topic_0000001062847941_b4332142515256"><a name="zh-cn_topic_0000001062847941_b4332142515256"></a><a name="zh-cn_topic_0000001062847941_b4332142515256"></a>ISO 639</strong>(ISO制定的语言编码标准)。</p>
30</td>
31</tr>
32<tr id="zh-cn_topic_0000001173324681_row5888133693714"><td class="cellrowborder" valign="top" width="16.3%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001062847941_p14332112518252"><a name="zh-cn_topic_0000001062847941_p14332112518252"></a><a name="zh-cn_topic_0000001062847941_p14332112518252"></a>文字</p>
33</td>
34<td class="cellrowborder" valign="top" width="83.7%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001062847941_p9332192522510"><a name="zh-cn_topic_0000001062847941_p9332192522510"></a><a name="zh-cn_topic_0000001062847941_p9332192522510"></a>表示设备使用的文字类型,由1个大写字母(首字母)和3个小写字母组成。例如:Hans表示简体中文,Hant表示繁体中文。</p>
35<p id="zh-cn_topic_0000001062847941_p20332152582517"><a name="zh-cn_topic_0000001062847941_p20332152582517"></a><a name="zh-cn_topic_0000001062847941_p20332152582517"></a>详细取值范围,请查阅<strong id="zh-cn_topic_0000001062847941_b16332162512255"><a name="zh-cn_topic_0000001062847941_b16332162512255"></a><a name="zh-cn_topic_0000001062847941_b16332162512255"></a>ISO 15924</strong>(ISO制定的文字编码标准)。</p>
36</td>
37</tr>
38<tr id="zh-cn_topic_0000001173324681_row1888143616376"><td class="cellrowborder" valign="top" width="16.3%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001062847941_p18332825152513"><a name="zh-cn_topic_0000001062847941_p18332825152513"></a><a name="zh-cn_topic_0000001062847941_p18332825152513"></a>国家或地区</p>
39</td>
40<td class="cellrowborder" valign="top" width="83.7%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001062847941_p133212251255"><a name="zh-cn_topic_0000001062847941_p133212251255"></a><a name="zh-cn_topic_0000001062847941_p133212251255"></a>表示用户所在的国家或地区,由2~3个大写字母或者3个数字组成。例如:CN表示中国,GB表示英国。</p>
41<p id="zh-cn_topic_0000001062847941_p5332925172513"><a name="zh-cn_topic_0000001062847941_p5332925172513"></a><a name="zh-cn_topic_0000001062847941_p5332925172513"></a>详细取值范围,请查阅<strong id="zh-cn_topic_0000001062847941_b633242532515"><a name="zh-cn_topic_0000001062847941_b633242532515"></a><a name="zh-cn_topic_0000001062847941_b633242532515"></a>ISO 3166-1</strong>(ISO制定的国家和地区编码标准)。</p>
42</td>
43</tr>
44</tbody>
45</table>
46
47当开发框架无法在应用中找到系统语言的资源文件时,默认使用en-US.json中的资源内容。
48
49资源文件内容格式如下:
50
51en-US.json
52
53```
54{
55    "strings": {
56        "hello": "Hello world!",
57        "object": "Object parameter substitution-{name}",
58        "array": "Array type parameter substitution-{0}",
59        "symbol": "@#$%^&*()_+-={}[]\\|:;\"'<>,./?"
60    },
61
62    "files": {
63        "image": "image/en_picture.PNG"
64    }
65}
66```
67
68由于不同语言针对单复数有不同的匹配规则,在资源文件中使用“zero”“one”“two”“few”“many”“other”定义不同单复数场景下的词条内容。例如中文不区分单复数,仅存在“other”场景;英文存在“one”、“other”场景;阿拉伯语存在上述6种场景。
69
70en-US.jsonar-AE.json为例,资源文件内容格式如下:
71
72en-US.json
73
74```
75{
76    "strings": {
77        "people": {
78            "one": "one person",
79            "other": "{count} people"
80        }
81    }
82}
83```
84
85ar-AE.json
86
87```
88{
89    "strings": {
90        "people": {
91            "zero": "لا أحد",
92            "one": "وحده",
93            "two": "اثنان",
94            "few": "ستة اشخاص",
95            "many": "خمسون شخص",
96            "other": "مائة شخص"
97        }
98    }
99}
100```
101
102## 引用资源<a name="zh-cn_topic_0000001173324681_section522111116527"></a>
103
104在应用开发的页面中使用多语言的语法,包含简单格式化和单复数格式化两种,都可以在hml或js中使用。
105
106-   简单格式化方法
107
108    在应用中使用$t方法引用资源,$t既可以在hml中使用,也可以在js中使用。系统将根据当前语言环境和指定的资源路径(通过$t的path参数设置),显示对应语言的资源文件中的内容。
109
110    **表 2**  简单格式化
111
112    <a name="zh-cn_topic_0000001173324681_table10506333184710"></a>
113    <table><thead align="left"><tr id="zh-cn_topic_0000001173324681_row1250615336479"><th class="cellrowborder" valign="top" width="10.24%" id="mcps1.2.6.1.1"><p id="zh-cn_topic_0000001173324681_p14506163314479"><a name="zh-cn_topic_0000001173324681_p14506163314479"></a><a name="zh-cn_topic_0000001173324681_p14506163314479"></a>属性</p>
114    </th>
115    <th class="cellrowborder" valign="top" width="15.040000000000001%" id="mcps1.2.6.1.2"><p id="zh-cn_topic_0000001173324681_p205076333474"><a name="zh-cn_topic_0000001173324681_p205076333474"></a><a name="zh-cn_topic_0000001173324681_p205076333474"></a>类型</p>
116    </th>
117    <th class="cellrowborder" valign="top" width="24%" id="mcps1.2.6.1.3"><p id="zh-cn_topic_0000001173324681_p250773354718"><a name="zh-cn_topic_0000001173324681_p250773354718"></a><a name="zh-cn_topic_0000001173324681_p250773354718"></a>参数</p>
118    </th>
119    <th class="cellrowborder" valign="top" width="13.600000000000001%" id="mcps1.2.6.1.4"><p id="zh-cn_topic_0000001173324681_p5742204362716"><a name="zh-cn_topic_0000001173324681_p5742204362716"></a><a name="zh-cn_topic_0000001173324681_p5742204362716"></a>必填</p>
120    </th>
121    <th class="cellrowborder" valign="top" width="37.12%" id="mcps1.2.6.1.5"><p id="zh-cn_topic_0000001173324681_p105079331472"><a name="zh-cn_topic_0000001173324681_p105079331472"></a><a name="zh-cn_topic_0000001173324681_p105079331472"></a>描述</p>
122    </th>
123    </tr>
124    </thead>
125    <tbody><tr id="zh-cn_topic_0000001173324681_row1550713344719"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.6.1.1 "><p id="zh-cn_topic_0000001173324681_p185071433174714"><a name="zh-cn_topic_0000001173324681_p185071433174714"></a><a name="zh-cn_topic_0000001173324681_p185071433174714"></a>$t</p>
126    </td>
127    <td class="cellrowborder" valign="top" width="15.040000000000001%" headers="mcps1.2.6.1.2 "><p id="zh-cn_topic_0000001173324681_p10507193304718"><a name="zh-cn_topic_0000001173324681_p10507193304718"></a><a name="zh-cn_topic_0000001173324681_p10507193304718"></a>Function</p>
128    </td>
129    <td class="cellrowborder" valign="top" width="24%" headers="mcps1.2.6.1.3 "><p id="zh-cn_topic_0000001173324681_p69461437131511"><a name="zh-cn_topic_0000001173324681_p69461437131511"></a><a name="zh-cn_topic_0000001173324681_p69461437131511"></a>请见<a href="#zh-cn_topic_0000001173324681_table1161115496137">表3</a></p>
130    </td>
131    <td class="cellrowborder" valign="top" width="13.600000000000001%" headers="mcps1.2.6.1.4 "><p id="zh-cn_topic_0000001173324681_p1991117447"><a name="zh-cn_topic_0000001173324681_p1991117447"></a><a name="zh-cn_topic_0000001173324681_p1991117447"></a>是</p>
132    </td>
133    <td class="cellrowborder" valign="top" width="37.12%" headers="mcps1.2.6.1.5 "><p id="zh-cn_topic_0000001173324681_p1150753310476"><a name="zh-cn_topic_0000001173324681_p1150753310476"></a><a name="zh-cn_topic_0000001173324681_p1150753310476"></a>根据系统语言完成简单的替换:this.$t('strings.hello')</p>
134    </td>
135    </tr>
136    </tbody>
137    </table>
138
139    **表 3**  $t参数说明
140
141    <a name="zh-cn_topic_0000001173324681_table1161115496137"></a>
142    <table><thead align="left"><tr id="zh-cn_topic_0000001173324681_row1061274917131"><th class="cellrowborder" valign="top" width="12%" id="mcps1.2.5.1.1"><p id="zh-cn_topic_0000001173324681_p166121249131312"><a name="zh-cn_topic_0000001173324681_p166121249131312"></a><a name="zh-cn_topic_0000001173324681_p166121249131312"></a>参数</p>
143    </th>
144    <th class="cellrowborder" valign="top" width="17.119999999999997%" id="mcps1.2.5.1.2"><p id="zh-cn_topic_0000001173324681_p261213498139"><a name="zh-cn_topic_0000001173324681_p261213498139"></a><a name="zh-cn_topic_0000001173324681_p261213498139"></a>类型</p>
145    </th>
146    <th class="cellrowborder" valign="top" width="8.32%" id="mcps1.2.5.1.3"><p id="zh-cn_topic_0000001173324681_p15612124910139"><a name="zh-cn_topic_0000001173324681_p15612124910139"></a><a name="zh-cn_topic_0000001173324681_p15612124910139"></a>必填</p>
147    </th>
148    <th class="cellrowborder" valign="top" width="62.56%" id="mcps1.2.5.1.4"><p id="zh-cn_topic_0000001173324681_p1061274951318"><a name="zh-cn_topic_0000001173324681_p1061274951318"></a><a name="zh-cn_topic_0000001173324681_p1061274951318"></a>描述</p>
149    </th>
150    </tr>
151    </thead>
152    <tbody><tr id="zh-cn_topic_0000001173324681_row15612749191317"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.2.5.1.1 "><p id="zh-cn_topic_0000001173324681_p161215495131"><a name="zh-cn_topic_0000001173324681_p161215495131"></a><a name="zh-cn_topic_0000001173324681_p161215495131"></a>path</p>
153    </td>
154    <td class="cellrowborder" valign="top" width="17.119999999999997%" headers="mcps1.2.5.1.2 "><p id="zh-cn_topic_0000001173324681_p176121049101318"><a name="zh-cn_topic_0000001173324681_p176121049101318"></a><a name="zh-cn_topic_0000001173324681_p176121049101318"></a>string</p>
155    </td>
156    <td class="cellrowborder" valign="top" width="8.32%" headers="mcps1.2.5.1.3 "><p id="zh-cn_topic_0000001173324681_p8612144917136"><a name="zh-cn_topic_0000001173324681_p8612144917136"></a><a name="zh-cn_topic_0000001173324681_p8612144917136"></a>是</p>
157    </td>
158    <td class="cellrowborder" valign="top" width="62.56%" headers="mcps1.2.5.1.4 "><p id="zh-cn_topic_0000001173324681_p161254911314"><a name="zh-cn_topic_0000001173324681_p161254911314"></a><a name="zh-cn_topic_0000001173324681_p161254911314"></a>资源路径</p>
159    </td>
160    </tr>
161    <tr id="zh-cn_topic_0000001173324681_row861264931319"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.2.5.1.1 "><p id="zh-cn_topic_0000001173324681_p15612449181316"><a name="zh-cn_topic_0000001173324681_p15612449181316"></a><a name="zh-cn_topic_0000001173324681_p15612449181316"></a>params</p>
162    </td>
163    <td class="cellrowborder" valign="top" width="17.119999999999997%" headers="mcps1.2.5.1.2 "><p id="zh-cn_topic_0000001173324681_p496164415306"><a name="zh-cn_topic_0000001173324681_p496164415306"></a><a name="zh-cn_topic_0000001173324681_p496164415306"></a>Array|Object</p>
164    </td>
165    <td class="cellrowborder" valign="top" width="8.32%" headers="mcps1.2.5.1.3 "><p id="zh-cn_topic_0000001173324681_p861284917131"><a name="zh-cn_topic_0000001173324681_p861284917131"></a><a name="zh-cn_topic_0000001173324681_p861284917131"></a>否</p>
166    </td>
167    <td class="cellrowborder" valign="top" width="62.56%" headers="mcps1.2.5.1.4 "><p id="zh-cn_topic_0000001173324681_p20612194931313"><a name="zh-cn_topic_0000001173324681_p20612194931313"></a><a name="zh-cn_topic_0000001173324681_p20612194931313"></a>运行时用来替换占位符的实际内容,占位符分为两种:</p>
168    <a name="zh-cn_topic_0000001173324681_ul0124131652619"></a><a name="zh-cn_topic_0000001173324681_ul0124131652619"></a><ul id="zh-cn_topic_0000001173324681_ul0124131652619"><li>具名占位符,例如{name}。实际内容必须用Object类型指定,例如:$t('strings.object', <strong id="zh-cn_topic_0000001173324681_b1013035383112"><a name="zh-cn_topic_0000001173324681_b1013035383112"></a><a name="zh-cn_topic_0000001173324681_b1013035383112"></a>{ name: 'Hello world' }</strong>)。</li><li>数字占位符,例如{0}。实际内容必须用Array类型指定,例如:$t('strings.array', <strong id="zh-cn_topic_0000001173324681_b0314143473110"><a name="zh-cn_topic_0000001173324681_b0314143473110"></a><a name="zh-cn_topic_0000001173324681_b0314143473110"></a>['Hello world']</strong>)。</li></ul>
169    </td>
170    </tr>
171    </tbody>
172    </table>
173
174-   简单格式化示例代码
175
176    ```
177    <!-- xxx.hml -->
178    <div>
179      <!-- 不使用占位符,text中显示“Hello world!” -->
180      <text>{{ $t('strings.hello') }}</text>
181      <!-- 具名占位符格式,运行时将占位符{name}替换为“Hello world” -->
182      <text>{{ $t('strings.object', { name: 'Hello world' }) }}</text>
183      <!-- 数字占位符格式,运行时将占位符{0}替换为“Hello world” -->
184      <text>{{ $t('strings.array', ['Hello world']) }}</text>
185      <!-- 先在js中获取资源内容,再在text中显示“Hello world” -->
186      <text>{{ hello }}</text>
187      <!-- 先在js中获取资源内容,并将占位符{name}替换为“Hello world”,再在text中显示“Object parameter substitution-Hello world” -->
188      <text>{{ replaceObject }}</text>
189      <!-- 先在js中获取资源内容,并将占位符{0}替换为“Hello world”,再在text中显示“Array type parameter substitution-Hello world” -->
190      <text>{{ replaceArray }}</text>
191
192      <!-- 获取图片路径 -->
193      <image src="{{ $t('files.image') }}" class="image"></image>
194      <!-- 先在js中获取图片路径,再在image中显示图片 -->
195      <image src="{{ replaceSrc }}" class="image"></image>
196    </div>
197    ```
198
199    ```
200    // xxx.js
201    // 下面为在js文件中的使用方法。
202    export default {
203      data: {
204        hello: '',
205        replaceObject: '',
206        replaceArray: '',
207        replaceSrc: '',
208      },
209      onInit() {
210        this.hello = this.$t('strings.hello');
211        this.replaceObject = this.$t('strings.object', { name: 'Hello world' });
212        this.replaceArray = this.$t('strings.array', ['Hello world']);
213        this.replaceSrc = this.$t('files.image');
214      },
215    }
216    ```
217
218-   单复数格式化方法
219
220    **表 4**  单复数格式化
221
222    <a name="zh-cn_topic_0000001173324681_table12722349115211"></a>
223    <table><thead align="left"><tr id="zh-cn_topic_0000001173324681_row11723204985215"><th class="cellrowborder" valign="top" width="7.68%" id="mcps1.2.6.1.1"><p id="zh-cn_topic_0000001173324681_p9723749145217"><a name="zh-cn_topic_0000001173324681_p9723749145217"></a><a name="zh-cn_topic_0000001173324681_p9723749145217"></a>属性</p>
224    </th>
225    <th class="cellrowborder" valign="top" width="13.28%" id="mcps1.2.6.1.2"><p id="zh-cn_topic_0000001173324681_p1372374910528"><a name="zh-cn_topic_0000001173324681_p1372374910528"></a><a name="zh-cn_topic_0000001173324681_p1372374910528"></a>类型</p>
226    </th>
227    <th class="cellrowborder" valign="top" width="23.84%" id="mcps1.2.6.1.3"><p id="zh-cn_topic_0000001173324681_p1272314496527"><a name="zh-cn_topic_0000001173324681_p1272314496527"></a><a name="zh-cn_topic_0000001173324681_p1272314496527"></a>参数</p>
228    </th>
229    <th class="cellrowborder" valign="top" width="8%" id="mcps1.2.6.1.4"><p id="zh-cn_topic_0000001173324681_p39561320202915"><a name="zh-cn_topic_0000001173324681_p39561320202915"></a><a name="zh-cn_topic_0000001173324681_p39561320202915"></a>必填</p>
230    </th>
231    <th class="cellrowborder" valign="top" width="47.199999999999996%" id="mcps1.2.6.1.5"><p id="zh-cn_topic_0000001173324681_p12723124915528"><a name="zh-cn_topic_0000001173324681_p12723124915528"></a><a name="zh-cn_topic_0000001173324681_p12723124915528"></a>描述</p>
232    </th>
233    </tr>
234    </thead>
235    <tbody><tr id="zh-cn_topic_0000001173324681_row167231749155214"><td class="cellrowborder" valign="top" width="7.68%" headers="mcps1.2.6.1.1 "><p id="zh-cn_topic_0000001173324681_p15723184945217"><a name="zh-cn_topic_0000001173324681_p15723184945217"></a><a name="zh-cn_topic_0000001173324681_p15723184945217"></a>$tc</p>
236    </td>
237    <td class="cellrowborder" valign="top" width="13.28%" headers="mcps1.2.6.1.2 "><p id="zh-cn_topic_0000001173324681_p1372310494525"><a name="zh-cn_topic_0000001173324681_p1372310494525"></a><a name="zh-cn_topic_0000001173324681_p1372310494525"></a>Function</p>
238    </td>
239    <td class="cellrowborder" valign="top" width="23.84%" headers="mcps1.2.6.1.3 "><p id="zh-cn_topic_0000001173324681_p3645417495"><a name="zh-cn_topic_0000001173324681_p3645417495"></a><a name="zh-cn_topic_0000001173324681_p3645417495"></a>请见<a href="#zh-cn_topic_0000001173324681_table1856962321614">表5</a></p>
240    </td>
241    <td class="cellrowborder" valign="top" width="8%" headers="mcps1.2.6.1.4 "><p id="zh-cn_topic_0000001173324681_p1589916493474"><a name="zh-cn_topic_0000001173324681_p1589916493474"></a><a name="zh-cn_topic_0000001173324681_p1589916493474"></a>是</p>
242    </td>
243    <td class="cellrowborder" valign="top" width="47.199999999999996%" headers="mcps1.2.6.1.5 "><p id="zh-cn_topic_0000001173324681_p1080910112617"><a name="zh-cn_topic_0000001173324681_p1080910112617"></a><a name="zh-cn_topic_0000001173324681_p1080910112617"></a>根据系统语言完成单复数替换:this.$tc('strings.people')</p>
244    <div class="note" id="zh-cn_topic_0000001173324681_note44962033184817"><a name="zh-cn_topic_0000001173324681_note44962033184817"></a><a name="zh-cn_topic_0000001173324681_note44962033184817"></a><span class="notetitle"> 说明: </span><div class="notebody"><p id="zh-cn_topic_0000001173324681_p1456045614402"><a name="zh-cn_topic_0000001173324681_p1456045614402"></a><a name="zh-cn_topic_0000001173324681_p1456045614402"></a>定义资源的内容通过json格式的key为“zero”、“one”、“two”、“few”、“many”和“other”区分。</p>
245    </div></div>
246    </td>
247    </tr>
248    </tbody>
249    </table>
250
251    **表 5**  $tc参数说明
252
253    <a name="zh-cn_topic_0000001173324681_table1856962321614"></a>
254    <table><thead align="left"><tr id="zh-cn_topic_0000001173324681_row13569122391616"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.1"><p id="zh-cn_topic_0000001173324681_p135698238163"><a name="zh-cn_topic_0000001173324681_p135698238163"></a><a name="zh-cn_topic_0000001173324681_p135698238163"></a>参数</p>
255    </th>
256    <th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.2"><p id="zh-cn_topic_0000001173324681_p17569152311168"><a name="zh-cn_topic_0000001173324681_p17569152311168"></a><a name="zh-cn_topic_0000001173324681_p17569152311168"></a>类型</p>
257    </th>
258    <th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.3"><p id="zh-cn_topic_0000001173324681_p1569523171613"><a name="zh-cn_topic_0000001173324681_p1569523171613"></a><a name="zh-cn_topic_0000001173324681_p1569523171613"></a>必填</p>
259    </th>
260    <th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.4"><p id="zh-cn_topic_0000001173324681_p2569192341613"><a name="zh-cn_topic_0000001173324681_p2569192341613"></a><a name="zh-cn_topic_0000001173324681_p2569192341613"></a>描述</p>
261    </th>
262    </tr>
263    </thead>
264    <tbody><tr id="zh-cn_topic_0000001173324681_row056919234163"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="zh-cn_topic_0000001173324681_p175691923171610"><a name="zh-cn_topic_0000001173324681_p175691923171610"></a><a name="zh-cn_topic_0000001173324681_p175691923171610"></a>path</p>
265    </td>
266    <td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="zh-cn_topic_0000001173324681_p11569182319162"><a name="zh-cn_topic_0000001173324681_p11569182319162"></a><a name="zh-cn_topic_0000001173324681_p11569182319162"></a>string</p>
267    </td>
268    <td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="zh-cn_topic_0000001173324681_p93611250151616"><a name="zh-cn_topic_0000001173324681_p93611250151616"></a><a name="zh-cn_topic_0000001173324681_p93611250151616"></a>是</p>
269    </td>
270    <td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="zh-cn_topic_0000001173324681_p145691323171620"><a name="zh-cn_topic_0000001173324681_p145691323171620"></a><a name="zh-cn_topic_0000001173324681_p145691323171620"></a>资源路径</p>
271    </td>
272    </tr>
273    <tr id="zh-cn_topic_0000001173324681_row1569142351616"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="zh-cn_topic_0000001173324681_p956911235161"><a name="zh-cn_topic_0000001173324681_p956911235161"></a><a name="zh-cn_topic_0000001173324681_p956911235161"></a>count</p>
274    </td>
275    <td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="zh-cn_topic_0000001173324681_p7569182321618"><a name="zh-cn_topic_0000001173324681_p7569182321618"></a><a name="zh-cn_topic_0000001173324681_p7569182321618"></a>number</p>
276    </td>
277    <td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="zh-cn_topic_0000001173324681_p6377550111614"><a name="zh-cn_topic_0000001173324681_p6377550111614"></a><a name="zh-cn_topic_0000001173324681_p6377550111614"></a>是</p>
278    </td>
279    <td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="zh-cn_topic_0000001173324681_p1556962371614"><a name="zh-cn_topic_0000001173324681_p1556962371614"></a><a name="zh-cn_topic_0000001173324681_p1556962371614"></a>要表达的值</p>
280    </td>
281    </tr>
282    </tbody>
283    </table>
284
285-   单复数格式化示例代码
286
287    ```
288    <!--xxx.hml-->
289    <div>
290      <!-- 传递数值为0时: "0 people" 阿拉伯语中此处匹配key为zero的词条-->
291      <text>{{ $tc('strings.people', 0) }}</text>
292      <!-- 传递数值为1时: "one person" 阿拉伯语中此处匹配key为one的词条-->
293      <text>{{ $tc('strings.people', 1) }}</text>
294      <!-- 传递数值为2时: "2 people" 阿拉伯语中此处匹配key为two的词条-->
295      <text>{{ $tc('strings.people', 2) }}</text>
296      <!-- 传递数值为6时: "6 people" 阿拉伯语中此处匹配key为few的词条-->
297      <text>{{ $tc('strings.people', 6) }}</text>
298      <!-- 传递数值为50时: "50 people" 阿拉伯语中此处匹配key为many的词条-->
299      <text>{{ $tc('strings.people', 50) }}</text>
300      <!-- 传递数值为100时: "100 people" 阿拉伯语中此处匹配key为other的词条-->
301      <text>{{ $tc('strings.people', 100) }}</text>
302    </div>
303    ```
304
305
306## 获取语言<a name="zh-cn_topic_0000001173324681_section2872192475310"></a>
307
308获取语言功能请参考[应用配置](apis/js-apis-system-configuration.md)。
309
310