{"id":189018,"date":"2022-05-20T04:37:12","date_gmt":"2022-05-19T20:37:12","guid":{"rendered":"https:\/\/www.idc.net\/help\/189018\/"},"modified":"2022-05-20T04:37:12","modified_gmt":"2022-05-19T20:37:12","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91angular%e6%95%99%e7%a8%8b%ef%bc%9aangular-%e5%87%86%e5%a4%87%e7%bf%bb%e8%af%91%e6%a8%a1%e6%9d%bf","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/189018\/","title":{"rendered":"\u540e\u6d6a\u4e91Angular\u6559\u7a0b\uff1aAngular \u51c6\u5907\u7ffb\u8bd1\u6a21\u677f"},"content":{"rendered":"<h2>\u51c6\u5907\u7ffb\u8bd1\u7ec4\u4ef6 <\/h2>\n<p>\u8981\u51c6\u5907\u7ffb\u8bd1\u9879\u76ee\uff0c\u8bf7\u5b8c\u6210\u4ee5\u4e0b\u64cd\u4f5c\u3002<\/p>\n<ul>\n<li>\u4f7f\u7528&nbsp;\u200b<code>i18n<\/code>\u200b&nbsp;\u5c5e\u6027\u6807\u8bb0\u7ec4\u4ef6\u6a21\u677f\u4e2d\u7684\u6587\u672c<\/li>\n<li>\u4f7f\u7528&nbsp;\u200b<code>i18n-<\/code>\u200b&nbsp;\u5c5e\u6027\u5728\u7ec4\u4ef6\u6a21\u677f\u4e2d\u6807\u8bb0\u5c5e\u6027\u6587\u672c\u5b57\u7b26\u4e32<\/li>\n<li>\u4f7f\u7528\u5e26&nbsp;\u200b<code>$localize<\/code>\u200b&nbsp;\u6807\u8bb0\u7684\u6d88\u606f\u5b57\u7b26\u4e32\u6807\u8bb0\u7ec4\u4ef6\u4ee3\u7801\u4e2d\u7684\u6587\u672c\u5b57\u7b26\u4e32<\/li>\n<\/ul>\n<h2>\u5728\u7ec4\u4ef6\u6a21\u677f\u4e2d\u6807\u8bb0\u6587\u672c <\/h2>\n<p>\u5728\u7ec4\u4ef6\u6a21\u677f\u4e2d\uff0ci18n&nbsp;\u5143\u6570\u636e\u5c31\u662f&nbsp;\u200b<code>i18n&nbsp;<\/code>\u200b\u5c5e\u6027\u7684\u503c\u3002<\/p>\n<pre><code>&lt;element i18n=\"{i18n_metadata}\"&gt;{string_to_translate}&lt;\/element&gt;<\/code><\/pre>\n<p>\u4f7f\u7528&nbsp;\u200b<code>i18n&nbsp;<\/code>\u200b\u5c5e\u6027\u5728\u7ec4\u4ef6\u6a21\u677f\u4e2d\u6807\u8bb0\u9759\u6001\u6587\u672c\u6d88\u606f\u4ee5\u8fdb\u884c\u7ffb\u8bd1\u3002\u5c06\u5b83\u653e\u5728\u6bcf\u4e2a\u5305\u542b\u8981\u7ffb\u8bd1\u7684\u56fa\u5b9a\u6587\u672c\u7684\u5143\u7d20\u6807\u7b7e\u4e0a\u3002<\/p>\n<blockquote>\n<p>\u200b<code>i18n&nbsp;<\/code>\u200b\u5c5e\u6027\u662f\u4f9b&nbsp;Angular&nbsp;\u5de5\u5177\u548c\u7f16\u8bd1\u5668\u8bc6\u522b\u7684\u81ea\u5b9a\u4e49\u5c5e\u6027\u3002<\/p>\n<\/blockquote>\n<h3>i18n&nbsp;\u793a\u4f8b <\/h3>\n<p>\u4e0b\u9762\u7684&nbsp;\u200b<code>&lt;h1&gt;<\/code>\u200b&nbsp;\u6807\u7b7e\u663e\u793a\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u82f1\u8bed\u95ee\u5019\u8bed\uff1a\u201cHello&nbsp;i18n\uff01\u201d\u3002<\/p>\n<pre><code>&lt;h1&gt;Hello i18n!&lt;\/h1&gt;<\/code><\/pre>\n<p>\u8981\u5c06\u95ee\u5019\u8bed\u6807\u8bb0\u4e3a\u5f85\u7ffb\u8bd1\uff0c\u8bf7\u5c06&nbsp;\u200b<code>i18n&nbsp;<\/code>\u200b\u5c5e\u6027\u6dfb\u52a0\u5230&nbsp;\u200b<code>&lt;h1&gt;<\/code>\u200b&nbsp;\u6807\u8bb0\u3002<\/p>\n<pre><code>&lt;h1 i18n&gt;Hello i18n!&lt;\/h1&gt;<\/code><\/pre>\n<h3>\u7ffb\u8bd1\u6ca1\u6709&nbsp;HTML&nbsp;\u5143\u7d20\u7684\u5185\u8054\u6587\u672c <\/h3>\n<p>\u4f7f\u7528&nbsp;\u200b<code>&lt;ng-container&gt;<\/code>\u200b&nbsp;\u5143\u7d20\u6765\u4e3a\u7279\u5b9a\u6587\u672c\u5173\u8054\u7ffb\u8bd1\u884c\u4e3a\uff0c\u800c\u4e0d\u4f1a\u6539\u53d8\u6587\u672c\u7684\u663e\u793a\u65b9\u5f0f\u3002<\/p>\n<blockquote>\n<p>\u6bcf\u4e2a&nbsp;HTML&nbsp;\u5143\u7d20\u90fd\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684&nbsp;DOM&nbsp;\u5143\u7d20\u3002\u8981\u60f3\u907f\u514d\u521b\u5efa\u65b0\u7684&nbsp;DOM&nbsp;\u5143\u7d20\uff0c\u8bf7\u5c06\u6587\u672c\u5305\u88f9\u5728&nbsp;\u200b<code>&lt;ng-container&gt;<\/code>\u200b&nbsp;\u5143\u7d20\u4e2d\u3002\u4ee5\u4e0b\u793a\u4f8b\u663e\u793a\u4e86\u5982\u4f55\u5c06&nbsp;\u200b<code>&lt;ng-container&gt;<\/code>\u200b&nbsp;\u5143\u7d20\u8f6c\u6362\u4e3a\u4e0d\u663e\u793a\u7684&nbsp;HTML&nbsp;\u6ce8\u91ca\u3002<\/p>\n<pre><code>&lt;ng-container i18n&gt;I don't output any element&lt;\/ng-container&gt;<\/code><\/pre>\n<\/blockquote>\n<h2>\u6807\u8bb0\u7ffb\u8bd1\u7684\u5143\u7d20\u5c5e\u6027 <\/h2>\n<p>\u5728\u7ec4\u4ef6\u6a21\u677f\u4e2d\uff0ci18n&nbsp;\u7684\u5143\u6570\u636e\u662f&nbsp;\u200b<code>i18n-{attribute_name}<\/code>\u200b&nbsp;\u5c5e\u6027\u7684\u503c\u3002<\/p>\n<pre><code>&lt;element i18n-{attribute_name}=\"{i18n_metadata}\" {attribute_name}=\"{attribute_value}\" \/&gt;<\/code><\/pre>\n<p>HTML&nbsp;\u5143\u7d20\u7684\u5c5e\u6027\u5305\u62ec\u90a3\u4e9b\u8981\u548c\u7ec4\u4ef6\u6a21\u677f\u4e2d\u663e\u793a\u7684\u5176\u5b83\u6587\u672c\u4e00\u8d77\u7ffb\u8bd1\u7684\u6587\u672c\u3002<\/p>\n<p>\u5c06&nbsp;\u200b<code>i18n-{attribute_name}<\/code>\u200b&nbsp;\u4e0e\u4efb\u4f55\u5143\u7d20\u7684\u4efb\u4f55\u5c5e\u6027\u4e00\u8d77\u4f7f\u7528\uff0c\u5e76\u5c06&nbsp;\u200b<code>{attribute_name}<\/code>\u200b&nbsp;\u66ff\u6362\u4e3a\u8be5\u5c5e\u6027\u7684\u540d\u79f0\u3002\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u5206\u914d\u542b\u4e49\u3001\u63cf\u8ff0\u548c\u81ea\u5b9a\u4e49&nbsp;ID\u3002<\/p>\n<pre><code>i18n-{attribute_name}=\"{meaning}|{description}@@{id}\"<\/code><\/pre>\n<h3>i18n-title&nbsp;\u793a\u4f8b <\/h3>\n<p>\u8981\u7ffb\u8bd1\u56fe\u50cf\u7684\u6807\u9898\uff0c\u8bf7\u67e5\u770b\u6b64\u793a\u4f8b\u3002\u4ee5\u4e0b\u793a\u4f8b\u663e\u793a\u5177\u6709&nbsp;\u200b<code>title&nbsp;<\/code>\u200b\u5c5e\u6027\u7684\u56fe\u50cf\u3002<\/p>\n<pre><code>&lt;img [src]=\"logo\" title=\"Angular logo\" alt=\"Angular logo\"&gt;<\/code><\/pre>\n<p>\u8981\u6807\u8bb0\u51fa\u5f85\u7ffb\u8bd1\u7684\u6807\u9898\u5c5e\u6027\uff0c\u8bf7\u5b8c\u6210\u4ee5\u4e0b\u64cd\u4f5c\u3002<\/p>\n<ol>\n<li>\u6dfb\u52a0&nbsp;\u200b<code>i18n-title<\/code>\u200b&nbsp;\u5c5e\u6027<\/li>\n<p>\u4e0b\u9762\u7684\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u901a\u8fc7\u6dfb\u52a0&nbsp;\u200b<code>i18n-title<\/code>\u200b&nbsp;\u6765\u6807\u8bb0\u51fa&nbsp;\u200b<code>img&nbsp;<\/code>\u200b\u6807\u7b7e\u4e0a\u7684&nbsp;\u200b<code>title&nbsp;<\/code>\u200b\u5c5e\u6027\u3002<\/p>\n<pre><code>&lt;img [src]=\"logo\" i18n-title title=\"Angular logo\" alt=\"Angular logo\"\/&gt;<\/code><\/pre>\n<\/ol>\n<h2>\u5728\u7ec4\u4ef6\u4ee3\u7801\u4e2d\u6807\u8bb0\u6587\u672c <\/h2>\n<p>\u5728\u7ec4\u4ef6\u4ee3\u7801\u4e2d\uff0c\u7ffb\u8bd1\u6e90\u6587\u672c\u548c\u5143\u6570\u636e\u88ab\u53cd\u5f15\u53f7&nbsp;(\u200b<code>`<\/code>\u200b)&nbsp;\u5b57\u7b26\u5305\u56f4\u3002<\/p>\n<p>\u4f7f\u7528&nbsp;\u200b<code>$localize<\/code>\u200b&nbsp;\u6807\u8bb0\u7684\u6d88\u606f\u5b57\u7b26\u4e32\u5728\u4ee3\u7801\u4e2d\u6807\u8bb0\u51fa\u8981\u7ffb\u8bd1\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<pre><code>$localize `string_to_translate`;<\/code><\/pre>\n<p>i18n&nbsp;\u5143\u6570\u636e\u5305\u88f9\u5728\u5192\u53f7&nbsp;(\u200b<code>:<\/code>\u200b)&nbsp;\u5b57\u7b26\u4e2d\uff0c\u5e76\u653e\u5728\u7ffb\u8bd1\u6e90\u6587\u672c\u4e4b\u524d\u3002<\/p>\n<pre><code>$localize `:{i18n_metadata}:string_to_translate`<\/code><\/pre>\n<h3>\u5305\u542b\u63d2\u503c\u6587\u672c <\/h3>\n<p>\u5728&nbsp;\u200b<code>$localize<\/code>\u200b&nbsp;\u6807\u8bb0\u7684\u6d88\u606f\u5b57\u7b26\u4e32\u4e2d\u5305\u542b<b>\u63d2\u503c\u6587\u672c<\/b>\u3002<\/p>\n<pre><code>$localize `string_to_translate ${variable_name}`;<\/code><\/pre>\n<h3>\u547d\u540d\u63d2\u503c\u5360\u4f4d\u7b26<\/h3>\n<pre><code>$localize `string_to_translate ${variable_name}:placeholder_name:`;<\/code><\/pre>\n<h2>\u7528\u4e8e\u7ffb\u8bd1\u7684&nbsp;i18n&nbsp;\u5143\u6570\u636e<\/h2>\n<pre><code>{meaning}|{description}@@{custom_id}<\/code><\/pre>\n<p>\u4ee5\u4e0b\u53c2\u6570\u63d0\u4f9b\u4e0a\u4e0b\u6587\u548c\u9644\u52a0\u4fe1\u606f\uff0c\u4ee5\u907f\u514d\u7ffb\u8bd1\u4eba\u5458\u5f04\u6df7\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<p>\u5143\u6570\u636e\u53c2\u6570<\/p>\n<\/th>\n<th>\n<p>\u8be6\u60c5<\/p>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<p>\u81ea\u5b9a\u4e49 ID<\/p>\n<\/td>\n<td>\n<p>\u63d0\u4f9b\u81ea\u5b9a\u4e49\u6807\u8bc6\u7b26<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u8bf4\u660e<\/p>\n<\/td>\n<td>\n<p>\u63d0\u4f9b\u989d\u5916\u7684\u4fe1\u606f\u6216\u80cc\u666f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u542b\u4e49(Meaning)<\/p>\n<\/td>\n<td>\n<p>\u63d0\u4f9b\u6587\u672c\u5728\u7279\u5b9a\u4e0a\u4e0b\u6587\u4e2d\u7684\u542b\u4e49\u6216\u610f\u56fe<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u6dfb\u52a0\u6709\u7528\u7684\u63cf\u8ff0\u548c\u542b\u4e49 <\/h3>\n<p>\u8981\u51c6\u786e\u7ffb\u8bd1\u6587\u672c\u6d88\u606f\uff0c\u5c31\u8981\u4e3a\u7ffb\u8bd1\u4eba\u5458\u63d0\u4f9b\u989d\u5916\u4fe1\u606f\u6216\u4e0a\u4e0b\u6587\u3002<\/p>\n<p>\u4e3a&nbsp;\u200b<code>i18n&nbsp;<\/code>\u200b\u5c5e\u6027\u7684\u503c\u6216&nbsp;\u200b<code>$localize<\/code>\u200b&nbsp;\u6807\u8bb0\u7684\u6d88\u606f\u5b57\u7b26\u4e32\u6dfb\u52a0\u6587\u672c\u6d88\u606f\u7684<b>\u63cf\u8ff0<\/b>\u3002<\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u663e\u793a\u4e86&nbsp;\u200b<code>i18n&nbsp;<\/code>\u200b\u5c5e\u6027\u7684\u503c\u3002<\/p>\n<pre><code>&lt;h1 i18n=\"An introduction header for this sample\"&gt;Hello i18n!&lt;\/h1&gt;<\/code><\/pre>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u663e\u793a\u4e86\u5e26\u6709\u63cf\u8ff0\u7684&nbsp;\u200b<code>$localize<\/code>\u200b&nbsp;\u6807\u8bb0\u6d88\u606f\u5b57\u7b26\u4e32\u7684\u503c\u3002<\/p>\n<pre><code>$localize `:An introduction header for this sample:Hello i18n!`;<\/code><\/pre>\n<p>\u7ffb\u8bd1\u8005\u53ef\u80fd\u8fd8\u9700\u8981\u4e86\u89e3\u8be5\u7279\u5b9a\u5e94\u7528\u4e0a\u4e0b\u6587\u4e2d\u6b64\u6587\u672c\u6d88\u606f\u7684\u542b\u4e49\u6216\u610f\u56fe\uff0c\u4ee5\u4fbf\u4ee5\u4e0e\u5177\u6709\u76f8\u540c\u542b\u4e49\u7684\u5176\u4ed6\u6587\u672c\u76f8\u540c\u7684\u65b9\u5f0f\u5bf9\u5176\u8fdb\u884c\u7ffb\u8bd1\u3002\u628a<b>\u542b\u4e49<\/b>\u653e\u5728&nbsp;\u200b<code>i18n&nbsp;<\/code>\u200b\u5c5e\u6027\u503c\u7684\u6700\u524d\u9762\uff0c\u5e76\u7528&nbsp;\u200b<code>|<\/code>\u200b&nbsp;\u5b57\u7b26\u5c06\u5176\u4e0e<b>\u63cf\u8ff0<\/b>\u5206\u5f00\uff1a\u200b<code>{meaning}|{description}<\/code>\u200b\u3002<\/p>\n<h4>h1&nbsp;\u793a\u4f8b <\/h4>\n<p>\u6bd4\u5982\uff0c\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06&nbsp;\u200b<code>&lt;h1&gt;<\/code>\u200b&nbsp;\u6807\u8bb0\u6307\u5b9a\u4e3a\u9700\u8981\u4ee5\u76f8\u540c\u65b9\u5f0f\u7ffb\u8bd1\u7684\u7ad9\u70b9\u6807\u9898\uff0c\u65e0\u8bba\u662f\u628a\u5b83\u7528\u4f5c\u6807\u9898\u8fd8\u662f\u5728\u5176\u4ed6\u6587\u672c\u90e8\u5206\u4e2d\u5f15\u7528\u3002<\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u663e\u793a\u5982\u4f55\u6307\u5b9a&nbsp;\u200b<code>&lt;h1&gt;<\/code>\u200b&nbsp;\u6807\u8bb0\u65e0\u8bba\u5728\u6807\u9898\u8fd8\u662f\u5728\u522b\u5904\u5f15\u7528\u90fd\u8981\u4ee5\u76f8\u540c\u65b9\u5f0f\u7ffb\u8bd1\u3002<\/p>\n<pre><code>&lt;h1 i18n=\"site header|An introduction header for this sample\"&gt;Hello i18n!&lt;\/h1&gt;<\/code><\/pre>\n<p>\u5176\u7ed3\u679c\u662f\uff1a\u4efb\u4f55\u6807\u6709&nbsp;\u200b<code>site&nbsp;header<\/code>\u200b&nbsp;\u7684\u6587\u672c\u90fd\u4f1a\u4ee5\u76f8\u540c\u65b9\u5f0f\u7ffb\u8bd1\uff0c\u56e0\u4e3a\u5176<b>\u542b\u4e49<\/b>\u5b8c\u5168\u76f8\u540c\u3002<\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u793a\u4f8b\u663e\u793a\u4e86\u5e26\u6709\u542b\u4e49\u548c\u63cf\u8ff0\u7684&nbsp;\u200b<code>$localize<\/code>\u200b&nbsp;\u6807\u8bb0\u6d88\u606f\u5b57\u7b26\u4e32\u7684\u503c\u3002<\/p>\n<pre><code>$localize `:site header|An introduction header for this sample:Hello i18n!`;<\/code><\/pre>\n<blockquote><p>\n  Angular&nbsp;\u63d0\u53d6\u5de5\u5177\u4f1a\u4e3a\u6a21\u677f\u4e2d\u7684\u6bcf\u4e2a&nbsp;\u200b<br \/>\n <code>i18n&nbsp;<\/code>\u200b\u5c5e\u6027\u751f\u6210\u4e00\u4e2a\u7ffb\u8bd1\u5355\u5143\u6761\u76ee\u3002Angular&nbsp;\u63d0\u53d6\u5de5\u5177\u4f1a\u6839\u636e\u542b\u4e49\u548c\u63cf\u8ff0\u4e3a\u6bcf\u4e2a\u7ffb\u8bd1\u5355\u5143\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684&nbsp;ID\u3002<br \/>\n <br \/>\u5177\u6709\u4e0d\u540c<br \/>\n <b>\u542b\u4e49<\/b>\u7684\u76f8\u540c\u6587\u672c\u5143\u7d20\u4ee5\u4e0d\u540c\u7684&nbsp;ID&nbsp;\u63d0\u53d6\u3002\u6bd4\u5982\uff0c\u5982\u679c\u5355\u8bcd\u201cright\u201d\u5728\u4e24\u4e2a\u4e0d\u540c\u7684\u4f4d\u7f6e\u4f7f\u7528\u4ee5\u4e0b\u4e24\u4e2a\u5b9a\u4e49\uff0c\u5219\u8be5\u5355\u8bcd\u5c06\u88ab\u4ee5\u4e0d\u540c\u5730\u65b9\u5f0f\u7ffb\u8bd1\u5e76\u4f5c\u4e3a\u4e0d\u540c\u7684\u7ffb\u8bd1\u6761\u76ee\u5408\u5e76\u56de\u5e94\u7528\u7a0b\u5e8f\u3002<br \/>\n  <\/p>\n<ul>\n<li>\u200b<code>correct&nbsp;<\/code>\u200b\u5982&nbsp;\"you&nbsp;are&nbsp;right\"<\/li>\n<li>\u200b<code>direction&nbsp;<\/code>\u200b\u5982&nbsp;\"turn&nbsp;right\"<\/li>\n<\/ul>\n<p>\u5982\u679c\u76f8\u540c\u7684\u6587\u672c\u5143\u7d20\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff0c\u5219\u53ea\u4f1a\u63d0\u53d6\u4e00\u6b21\u6587\u672c\u5143\u7d20\u5e76\u4f7f\u7528\u76f8\u540c\u7684&nbsp;ID\u3002<br \/>\n  <\/p>\n<ul>\n<li>\u76f8\u540c\u7684\u542b\u4e49\u6216\u5b9a\u4e49<\/li>\n<li>\u4e0d\u540c\u7684\u63cf\u8ff0<\/li>\n<\/ul>\n<p>\u53ea\u8981\u51fa\u73b0\u76f8\u540c\u7684\u6587\u672c\u5143\u7d20\uff0c\u8be5\u7ffb\u8bd1\u6761\u76ee\u5c31\u4f1a\u5408\u5e76\u56de\u5e94\u7528\u7a0b\u5e8f\u3002\n<\/p><\/blockquote>\n<h2>ICU&nbsp;\u8868\u8fbe\u5f0f <\/h2>\n<p>ICU&nbsp;\u8868\u8fbe\u5f0f\u53ef\u5e2e\u52a9\u4f60\u5728\u7ec4\u4ef6\u6a21\u677f\u4e2d\u6807\u8bb0\u51fa\u67d0\u4e9b\u6761\u4ef6\u4e0b\u7684\u66ff\u4ee3\u6587\u672c\u3002ICU&nbsp;\u8868\u8fbe\u5f0f\u5305\u62ec\u4e00\u4e2a\u7ec4\u4ef6\u5c5e\u6027\u3001\u4e00\u4e2a&nbsp;ICU&nbsp;\u5b50\u53e5\u4ee5\u53ca\u7531\u5de6\u82b1\u62ec\u53f7&nbsp;(&nbsp;\u200b<code>{<\/code>\u200b&nbsp;)&nbsp;\u548c\u53f3\u82b1\u62ec\u53f7&nbsp;(&nbsp;\u200b<code>}<\/code>\u200b&nbsp;)&nbsp;\u5b57\u7b26\u5305\u56f4\u7684&nbsp;case&nbsp;\u8bed\u53e5\u3002<\/p>\n<pre><code>{ component_property, icu_clause, case_statements }<\/code><\/pre>\n<p>\u7ec4\u4ef6\u5c5e\u6027\u5b9a\u4e49\u4e86\u53d8\u91cf\uff0c\u800c ICU \u5b50\u53e5\u5b9a\u4e49\u4e86\u6761\u4ef6\u6587\u672c\u7684\u7c7b\u578b\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<p>ICU \u5b50\u53e5<\/p>\n<\/th>\n<th>\n<p>\u8be6\u60c5<\/p>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u200b<code>plural<\/code>\u200b<\/td>\n<td>\n<p>\u6807\u8bb0\u590d\u6570\u7684\u4f7f\u7528<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\u200b<code>select<\/code>\u200b<\/td>\n<td>\n<p>\u6839\u636e\u4f60\u5b9a\u4e49\u7684\u5b57\u7b26\u4e32\u503c\u6807\u8bb0\u51fa\u66ff\u4ee3\u6587\u672c\u7684\u4e00\u4e9b\u9009\u62e9<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e3a\u4e86\u7b80\u5316\u7ffb\u8bd1\uff0c\u8bf7\u4f7f\u7528\u5e26\u6709\u6b63\u5219\u8868\u8fbe\u5f0f\u7684&nbsp;Unicode&nbsp;\u5b50\u53e5\uff08ICU&nbsp;\u5b50\u53e5\uff09\u7684\u56fd\u9645\u5316\u7ec4\u4ef6\u3002<\/p>\n<blockquote>\n<p>ICU&nbsp;\u5b50\u53e5\u9075\u5faa&nbsp;CLDR&nbsp;\u590d\u6570\u89c4\u5219&nbsp;\u4e2d\u6307\u5b9a\u7684&nbsp;ICU&nbsp;\u6d88\u606f\u683c\u5f0f\u3002<\/p>\n<\/blockquote>\n<h3>\u6807\u8bb0\u590d\u6570 <\/h3>\n<p>\u4e0d\u540c\u7684\u8bed\u8a00\u6709\u4e0d\u540c\u7684\u590d\u6570\u89c4\u5219\uff0c\u8fd9\u589e\u52a0\u4e86\u7ffb\u8bd1\u7684\u96be\u5ea6\u3002\u56e0\u4e3a\u5176\u4ed6\u8bed\u8a00\u73af\u5883\u8868\u8fbe\u57fa\u6570\u7684\u65b9\u5f0f\u4e0d\u540c\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u4e0e\u82f1\u8bed\u4e0d\u4e00\u81f4\u7684\u590d\u6570\u7c7b\u522b\u3002\u4f7f\u7528&nbsp;\u200b<code>plural&nbsp;<\/code>\u200b\u4ece\u53e5\u6765\u6807\u8bb0\u5f53\u9010\u5b57\u7ffb\u8bd1\u65f6\u53ef\u80fd\u6ca1\u6709\u610f\u4e49\u7684\u8868\u8fbe\u5f0f\u3002<\/p>\n<pre><code>{ component_property, plural, pluralization_categories }<\/code><\/pre>\n<p>\u5728\u590d\u6570\u7c7b\u522b\u4e4b\u540e\uff0c\u8f93\u5165\u7531\u5de6\u5927\u62ec\u53f7&nbsp;(\u200b<code>{<\/code>\u200b)&nbsp;\u548c\u53f3\u5927\u62ec\u53f7&nbsp;(\u200b<code>}<\/code>\u200b)&nbsp;\u5b57\u7b26\u5305\u56f4\u7684\u9ed8\u8ba4\u6587\u672c\uff08\u82f1\u6587\uff09\u3002<\/p>\n<pre><code>pluralization_category { }<\/code><\/pre>\n<p>\u4ee5\u4e0b\u590d\u6570\u7c7b\u522b\u9002\u7528\u4e8e\u82f1\u8bed\uff0c\u53ef\u80fd\u4f1a\u6839\u636e\u8bed\u8a00\u73af\u5883\u800c\u53d8\u5316\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<p>\u590d\u6570\u7c7b<\/p>\n<\/th>\n<th>\n<p>\u8be6\u60c5<\/p>\n<\/th>\n<th>\n<p>\u8303\u4f8b<\/p>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>zero<\/code> <\/td>\n<td>\n<p>\u6570\u91cf\u4e3a\u96f6<\/p>\n<\/td>\n<td><code>=0 { }<\/code> <br \/><code>zero { }<\/code> <\/td>\n<\/tr>\n<tr>\n<td><code>one<\/code> <\/td>\n<td>\n<p>\u6570\u91cf\u4e3a 1<\/p>\n<\/td>\n<td><code>=1 { }<\/code> <br \/><code>one { }<\/code> <\/td>\n<\/tr>\n<tr>\n<td><code>two<\/code> <\/td>\n<td>\n<p>\u6570\u91cf\u4e3a 2<\/p>\n<\/td>\n<td><code>=2 { }<\/code> <br \/><code>two { }<\/code> <\/td>\n<\/tr>\n<tr>\n<td><code>few<\/code> <\/td>\n<td>\n<p>\u6570\u91cf\u4e3a 2 \u6216\u66f4\u591a<\/p>\n<\/td>\n<td><code>few { }<\/code> <\/td>\n<\/tr>\n<tr>\n<td><code>many<\/code> <\/td>\n<td>\n<p>\u6570\u91cf\u5f88\u5927<\/p>\n<\/td>\n<td><code>many { }<\/code> <\/td>\n<\/tr>\n<tr>\n<td><code>other<\/code> <\/td>\n<td>\n<p>\u6570\u91cf\u7684\u9ed8\u8ba4\u503c<\/p>\n<\/td>\n<td><code>other { }<\/code> <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u4e0d\u80fd\u5339\u914d\u4efb\u4f55\u590d\u6570\u7c7b\u522b\uff0cAngular&nbsp;\u5c31\u4f1a\u4f7f\u7528&nbsp;\u200b<code>other&nbsp;<\/code>\u200b\u6765\u5339\u914d\u7f3a\u5931\u7c7b\u522b\u7684\u6807\u51c6\u540e\u5907\u503c\u3002<\/p>\n<pre><code>other { default_quantity }<\/code><\/pre>\n<blockquote>\n<p>\u6709\u5173\u590d\u6570\u7c7b\u522b\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605&nbsp;CLDR&nbsp;-&nbsp;Unicode&nbsp;Common&nbsp;Locale&nbsp;Data&nbsp;Repository&nbsp;\u4e2d\u7684\u9009\u62e9\u590d\u6570\u7c7b\u522b\u540d\u79f0\u3002<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u8bb8\u591a\u8bed\u8a00\u73af\u5883\u4e0d\u652f\u6301\u67d0\u4e9b\u590d\u6570\u7c7b\u522b\u3002\u9ed8\u8ba4\u8bed\u8a00\u73af\u5883&nbsp;(\u200b<code>en-US<\/code>\u200b)&nbsp;\u4f7f\u7528\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684&nbsp;\u200b<code>plural()<\/code>\u200b&nbsp;\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u4e0d\u652f\u6301&nbsp;\u200b<code>few&nbsp;<\/code>\u200b\u590d\u6570\u7c7b\u522b\u3002\u53e6\u4e00\u4e2a\u5177\u6709\u7b80\u5355&nbsp;\u200b<code>plural()<\/code>\u200b&nbsp;\u51fd\u6570\u7684\u8bed\u8a00\u73af\u5883\u662f&nbsp;\u200b<code>es<\/code>\u200b\u3002\u4ee5\u4e0b\u4ee3\u7801\u793a\u4f8b\u663e\u793a\u4e86&nbsp;en-US&nbsp;\u591a\u91cdplural()\u51fd\u6570\u3002<\/p>\n<pre><code>function plural(n: number): number {\n  let i = Math.floor(Math.abs(n)), v = n.toString().replace(\/^[^.]*\\.?\/, '').length;\n  if (i === 1 &amp;&amp; v === 0) return 1;\n  return 5;\n}<\/code><\/pre>\n<p>\u200b<code>plural()<\/code>\u200b&nbsp;\u51fd\u6570\u53ea\u8fd4\u56de&nbsp;1&nbsp;(&nbsp;\u200b<code>one&nbsp;<\/code>\u200b)&nbsp;\u6216&nbsp;5&nbsp;(&nbsp;\u200b<code>other&nbsp;<\/code>\u200b)\u3002\u800c&nbsp;\u200b<code>few&nbsp;<\/code>\u200b\u7c7b\u522b\u6c38\u8fdc\u4e0d\u4f1a\u5339\u914d\u5230\u3002<\/p>\n<\/blockquote>\n<h4>minutes&nbsp;\u793a\u4f8b <\/h4>\n<p>\u5982\u679c\u4f60\u60f3\u7528\u82f1\u6587\u663e\u793a\u4ee5\u4e0b\u77ed\u8bed\uff0c\u5176\u4e2d&nbsp;\u200b<code>x<\/code>\u200b&nbsp;\u662f\u4e00\u4e2a\u6570\u5b57\u3002<\/p>\n<pre><code>updated x minutes ago<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u8fd8\u60f3\u6839\u636e&nbsp;\u200b<code>x&nbsp;<\/code>\u200b\u7684\u57fa\u6570\u663e\u793a\u4ee5\u4e0b\u77ed\u8bed\u3002<\/p>\n<pre><code>updated just now<\/code><\/pre>\n<pre><code>updated one minute ago<\/code><\/pre>\n<p>\u4f7f\u7528&nbsp;HTML&nbsp;\u6807\u8bb0\u548c<b>\u63d2\u503c<\/b>\u3002\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u5728&nbsp;\u200b<code>&lt;span&gt;<\/code>\u200b&nbsp;\u5143\u7d20\u4e2d\u4f7f\u7528&nbsp;\u200b<code>plural&nbsp;<\/code>\u200b\u5b50\u53e5\u6765\u8868\u8fbe\u524d\u4e09\u79cd\u60c5\u51b5\u3002<\/p>\n<pre><code>&lt;span i18n&gt;Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}&lt;\/span&gt;<\/code><\/pre>\n<p>\u67e5\u770b\u524d\u9762\u4ee3\u7801\u793a\u4f8b\u4e2d\u7684\u4ee5\u4e0b\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<p>\u53c2\u6570<\/p>\n<\/th>\n<th>\n<p>\u8be6\u60c5<\/p>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>minutes<\/code> <\/td>\n<td>\n<p>\u7b2c\u4e00\u4e2a\u53c2\u6570\u6307\u5b9a\u8fd9\u4e2a\u7ec4\u4ef6\u5c5e\u6027\u662f&nbsp;<code>minutes<\/code>&nbsp;\u5e76\u786e\u5b9a\u5176\u5206\u949f\u6570\u3002<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><code>plural<\/code> <\/td>\n<td>\n<p>\u7b2c\u4e8c\u4e2a\u53c2\u6570\u6307\u5b9a ICU \u5b50\u53e5\u662f&nbsp;<code>plural<\/code>\u3002<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><code>=0 {just now}<\/code> <\/td>\n<td>\n<p>\u5bf9\u4e8e\u96f6\u5206\u949f\uff0c\u590d\u6570\u7c7b\u522b\u662f&nbsp;<code>=0<\/code>\u3002\u5176\u503c\u662f&nbsp;<code>just now<\/code>\u3002<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><code>=1 {one minute}<\/code> <\/td>\n<td>\n<p>\u5bf9\u4e8e\u4e00\u5206\u949f\uff0c\u590d\u6570\u7c7b\u522b\u662f&nbsp;<code>=1<\/code>\u3002\u8be5\u503c\u4e3a&nbsp;<code>one minute<\/code>\u3002<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><code>other {{{minutes}} minutes ago}<\/code> <\/td>\n<td>\n<p>\u5bf9\u4e8e\u4efb\u4f55\u4e0d\u5339\u914d\u7684\u57fa\u6570\uff0c\u9ed8\u8ba4\u7684\u590d\u6570\u7c7b\u522b\u662f&nbsp;<code>other<\/code>\u3002\u8be5\u503c\u4e3a&nbsp;<code>{{minutes}} minutes ago<\/code>\u3002<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u200b<code>{{minutes}}<\/code>\u200b&nbsp;\u662f\u4e00\u4e2a<b>\u63d2\u503c<\/b>\u3002<\/p>\n<h3>\u6807\u8bb0\u66ff\u4ee3\u548c\u5d4c\u5957\u8868\u8fbe\u5f0f <\/h3>\n<p>\u200b<code>select&nbsp;<\/code>\u200b\u5b50\u53e5\u6839\u636e\u4f60\u5b9a\u4e49\u7684\u5b57\u7b26\u4e32\u503c\u6807\u8bb0\u66ff\u4ee3\u6587\u672c\u7684\u9009\u62e9\u3002<\/p>\n<pre><code>{ component_property, select, selection_categories }<\/code><\/pre>\n<p>\u7ffb\u8bd1\u6240\u6709\u66ff\u4ee3\u9879\u4ee5\u6839\u636e\u53d8\u91cf\u7684\u503c\u663e\u793a\u66ff\u4ee3\u6587\u672c\u3002<\/p>\n<p>\u5728\u9009\u62e9\u7c7b\u522b\u540e\uff0c\u8f93\u5165\u7531\u5de6\u5927\u62ec\u53f7&nbsp;(&nbsp;\u200b<code>{<\/code>\u200b&nbsp;)&nbsp;\u548c\u53f3\u5927\u62ec\u53f7&nbsp;(&nbsp;\u200b<code>}<\/code>\u200b&nbsp;)&nbsp;\u5b57\u7b26\u5305\u56f4\u7684\u6587\u672c\uff08\u82f1\u6587\uff09\u3002<\/p>\n<pre><code>selection_category { text }<\/code><\/pre>\n<p>\u4e0d\u540c\u7684\u8bed\u8a00\u73af\u5883\u5177\u6709\u4e0d\u540c\u7684\u8bed\u6cd5\u7ed3\u6784\uff0c\u8fd9\u589e\u52a0\u4e86\u7ffb\u8bd1\u7684\u96be\u5ea6\u3002\u4f7f\u7528&nbsp;HTML&nbsp;\u6807\u8bb0\u3002\u5982\u679c\u65e0\u6cd5\u5339\u914d\u4efb\u4f55\u9009\u62e9\u7c7b\u522b\uff0cAngular&nbsp;\u5c31\u4f1a\u4f7f\u7528&nbsp;\u200b<code>other&nbsp;<\/code>\u200b\u6765\u5339\u914d\u7f3a\u5931\u7c7b\u522b\u7684\u6807\u51c6\u540e\u5907\u503c\u3002<\/p>\n<pre><code>other { default_value }<\/code><\/pre>\n<h4>gender&nbsp;\u4f8b\u5b50 <\/h4>\n<p>\u5982\u679c\u4f60\u60f3\u7528\u82f1\u6587\u663e\u793a\u4e0b\u9762\u7684\u77ed\u8bed\u3002<\/p>\n<pre><code>The author is other<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u8fd8\u60f3\u6839\u636e\u7ec4\u4ef6\u7684&nbsp;\u200b<code>gender&nbsp;<\/code>\u200b\u5c5e\u6027\u663e\u793a\u4ee5\u4e0b\u77ed\u8bed\u3002<\/p>\n<pre><code>The author is female<\/code><\/pre>\n<pre><code>The author is male<\/code><\/pre>\n<p>\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u7ed1\u5b9a\u7ec4\u4ef6\u7684&nbsp;\u200b<code>gender&nbsp;<\/code>\u200b\u5c5e\u6027\uff0c\u5e76\u4f7f\u7528&nbsp;\u200b<code>select&nbsp;<\/code>\u200b\u5b50\u53e5\u5728&nbsp;\u200b<code>&lt;span&gt;<\/code>\u200b&nbsp;\u5143\u7d20\u4e2d\u8868\u8fbe\u524d\u4e09\u79cd\u60c5\u51b5\u3002<\/p>\n<p>\u200b<code>gender&nbsp;<\/code>\u200b\u5c5e\u6027\u5c06\u8f93\u51fa\u7ed1\u5b9a\u5230\u4ee5\u4e0b\u6bcf\u4e2a\u5b57\u7b26\u4e32\u503c\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<p>\u503c<\/p>\n<\/th>\n<th>\n<p>\u82f1\u8bed\u503c<\/p>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<p>\u5973\u6027<\/p>\n<\/td>\n<td><code>female<\/code> <\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u7537\u6027<\/p>\n<\/td>\n<td><code>male<\/code> <\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5176\u5b83<\/p>\n<\/td>\n<td><code>other<\/code> <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u200b<code>select&nbsp;<\/code>\u200b\u5b50\u53e5\u4f1a\u5c06\u503c\u6620\u5c04\u6210\u9002\u5f53\u7684\u7ffb\u8bd1\u3002\u4ee5\u4e0b\u4ee3\u7801\u793a\u4f8b\u663e\u793a\u4e86\u4e0e&nbsp;select&nbsp;\u5b50\u53e5\u4e00\u8d77\u4f7f\u7528\u7684&nbsp;\u200b<code>gender&nbsp;<\/code>\u200b\u5c5e\u6027\u3002<\/p>\n<pre><code>&lt;span i18n&gt;The author is {gender, select, male {male} female {female} other {other}}&lt;\/span&gt;<\/code><\/pre>\n<h4>gender&nbsp;\u548c&nbsp;minutes&nbsp;\u793a\u4f8b <\/h4>\n<p>\u5c06\u4e0d\u540c\u7684\u5b50\u53e5\u7ec4\u5408\u5728\u4e00\u8d77\uff0c\u6bd4\u5982&nbsp;\u200b<code>plural&nbsp;<\/code>\u200b\u548c&nbsp;\u200b<code>select&nbsp;<\/code>\u200b\u5b50\u53e5\u3002\u4ee5\u4e0b\u4ee3\u7801\u793a\u4f8b\u663e\u793a\u4e86\u57fa\u4e8e&nbsp;\u200b<code>gender&nbsp;<\/code>\u200b\u548c&nbsp;\u200b<code>minutes&nbsp;<\/code>\u200b\u793a\u4f8b\u7684\u5d4c\u5957\u5b50\u53e5\u3002<\/p>\n<pre><code>&lt;span i18n&gt;Updated: {minutes, plural,\n  =0 {just now}\n  =1 {one minute ago}\n  other {{{minutes}} minutes ago by {gender, select, male {male} female {female} other {other}}}}\n&lt;\/span&gt;<\/code><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u51c6\u5907\u7ffb\u8bd1\u7ec4\u4ef6 \u8981\u51c6\u5907\u7ffb\u8bd1\u9879\u76ee\uff0c\u8bf7\u5b8c\u6210\u4ee5\u4e0b\u64cd\u4f5c\u3002 \u4f7f\u7528&nbsp;\u200bi18n\u200b&nbsp;\u5c5e\u6027\u6807\u8bb0\u7ec4\u4ef6\u6a21\u677f\u4e2d\u7684\u6587 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-189018","post","type-post","status-publish","format-standard","hentry","category-website"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/189018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=189018"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/189018\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=189018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=189018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=189018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}