You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

418 lines
194 KiB
HTML

12 months ago
<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-local-language" data-has-hydrated="false">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v3.0.0">
<title data-rh="true">21. 全球化和本地化 | Furion</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="http://furion.baiqian.ltd/docs/local-language"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="21. 全球化和本地化 | Furion"><meta data-rh="true" name="description" content="📝 模块更新日志"><meta data-rh="true" property="og:description" content="📝 模块更新日志"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="http://furion.baiqian.ltd/docs/local-language"><link data-rh="true" rel="alternate" href="http://furion.baiqian.ltd/docs/local-language" hreflang="en"><link data-rh="true" rel="alternate" href="http://furion.baiqian.ltd/docs/local-language" hreflang="x-default"><link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="Furion RSS Feed">
<link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="Furion Atom Feed"><link rel="stylesheet" href="/assets/css/styles.3f87a095.css">
<script src="/assets/js/runtime~main.89709a83.js" defer="defer"></script>
<script src="/assets/js/main.10e5dc01.js" defer="defer"></script>
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return localStorage.getItem("theme")}catch(t){}}();t(null!==e?e:"light")}(),function(){try{const a=new URLSearchParams(window.location.search).entries();for(var[t,e]of a)if(t.startsWith("docusaurus-data-")){var n=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(n,e)}}catch(t){}}(),document.documentElement.setAttribute("data-announcement-bar-initially-dismissed",function(){try{return"true"===localStorage.getItem("docusaurus.announcement.dismiss")}catch(t){}return!1}())</script><div id="__docusaurus"><div class="floatbar_hUWl"><div class="qrcode_sWwE"><img title="微信扫码关注 Furion 官方公众号" src="/img/weixin_qrcode.jpg" style="display:block"><div>❤️ 关注 Furion 微信公众号有惊喜哦!</div></div><div style="display:flex;flex-direction:row-reverse;align-items:flex-start"><div class="title_SD0k">🫠 遇到问题了</div><div class="extend__5i1"><a class="item_Y35a" href="/docs/subscribe"><div style="flex:1"><div class="itemTitle_If_T">⭐️ VIP 服务 ⭐️</div><div class="itemDesc_dp7r">仅需 499 元/年,尊享 365 天项目无忧</div></div><div class="jiantou_mV_o"></div></a><div class="item_Y35a"><div style="flex:1"><div class="itemTitle_If_T">问题反馈</div><div class="itemDesc_dp7r">到 Furion 开源仓库反馈</div></div><div class="jiantou_mV_o"></div></div></div></div></div><div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><div class="announcementBar_mb4j" style="background-color:#4623d9;color:yellow" role="banner"><div class="content_knG7 announcementBarContent_xLdY">⭐️ 开通 VIP 服务仅需 499 元/年,尊享 365 天项目无忧 <a href="/docs/subscribe" style="background-color:rgb(199, 29, 36);color:#ffffff;padding:1px 10px;border-radius:3px;text-decoration:none;display:inline-block;margin:0 5px;font-size:12px;cursor:pointer;">立即开通</a>⭐️</div></div><nav aria-label="Main" class="navbar navbar--fixed-top navbarHideable_m1mJ"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/furionlogo.png" alt="Furion Logo" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/furionlogo.png" alt="Furion Logo" class="themedComponent_mlkZ themedComponent--dark_xIcU"></div><b class="navbar__title text--truncate">Furion</b></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/docs/category/appendix">文档</a><a class="navbar__item navbar__link" href="/docs/global/app">静态类</a><a class="navbar__item navbar__link" href="/docs/settings/appsettings">配置</a><a class="navbar__item navbar__link" href="/blog">博客</a><div class="navbar__item dropdown dropdown--hoverable"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">更新日志</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/docs/upgrade">📝 查看日志v4.9.1.7</a></li><li><a class="dropdown__link" href="/docs/target">🚀 路线图</a></li></ul></div><a href="http://furion.baiqian.ltd/api/api" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">API<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></div><div class="navbar__items navbar__it
<li>
<p><strong>新特性</strong></p>
<ul>
<li> <label class="label_p8vM" title="新增" style="background-color:#39b54a"><svg viewBox="0 0 1024 1024" width="14px" height="14px" style="display:block" class="icon_knQK"><path d="M512 71.68c-242.688 0-440.32 197.632-440.32 440.32s197.632 440.32 440.32 440.32 440.32-197.632 440.32-440.32-197.632-440.32-440.32-440.32z m0 819.2c-208.896 0-378.88-169.984-378.88-378.88s169.984-378.88 378.88-378.88 378.88 169.984 378.88 378.88-169.984 378.88-378.88 378.88z" fill="white"></path><path d="M542.72 261.12H481.28v220.16H261.12v61.44h220.16v220.16h61.44v-220.16h220.16V481.28h-220.16z" fill="white"></path></svg> <!-- -->新增</label> 多语言支持 <code>L.GetDefaultCulture()</code> 获取本地配置默认语言 <sup>4.8.8.49</sup> <sup>2023.10.25</sup> <a href="https://gitee.com/dotnetchina/Furion/pulls/858" target="_blank" rel="noopener noreferrer">!858</a></li>
<li> <label class="label_p8vM" title="新增" style="background-color:#39b54a"><svg viewBox="0 0 1024 1024" width="14px" height="14px" style="display:block" class="icon_knQK"><path d="M512 71.68c-242.688 0-440.32 197.632-440.32 440.32s197.632 440.32 440.32 440.32 440.32-197.632 440.32-440.32-197.632-440.32-440.32-440.32z m0 819.2c-208.896 0-378.88-169.984-378.88-378.88s169.984-378.88 378.88-378.88 378.88 169.984 378.88 378.88-169.984 378.88-378.88 378.88z" fill="white"></path><path d="M542.72 261.12H481.28v220.16H261.12v61.44h220.16v220.16h61.44v-220.16h220.16V481.28h-220.16z" fill="white"></path></svg> <!-- -->新增</label> 多语言支持 <code>L.GetString(name, culture)</code> 获取指定区域翻译 <sup>4.8.8.41</sup> <sup>2023.08.04</sup> <a href="https://gitee.com/dotnetchina/Furion/commit/044b0edfbd622c7c69d685267aafa9f5855a9167" target="_blank" rel="noopener noreferrer">044b0ed</a></li>
<li> <label class="label_p8vM" title="新增" style="background-color:#39b54a"><svg viewBox="0 0 1024 1024" width="14px" height="14px" style="display:block" class="icon_knQK"><path d="M512 71.68c-242.688 0-440.32 197.632-440.32 440.32s197.632 440.32 440.32 440.32 440.32-197.632 440.32-440.32-197.632-440.32-440.32-440.32z m0 819.2c-208.896 0-378.88-169.984-378.88-378.88s169.984-378.88 378.88-378.88 378.88 169.984 378.88 378.88-169.984 378.88-378.88 378.88z" fill="white"></path><path d="M542.72 261.12H481.28v220.16H261.12v61.44h220.16v220.16h61.44v-220.16h220.16V481.28h-220.16z" fill="white"></path></svg> <!-- -->新增</label> 多语言支持 <code>DateTime</code> 时间格式化配置节点 <code>DateTimeFormatCulture</code> <sup>4.8.7.31</sup> <sup>2023.03.31</sup> <a href="https://gitee.com/dotnetchina/Furion/issues/I6RUOU" target="_blank" rel="noopener noreferrer">#I6RUOU</a></li>
<li> <label class="label_p8vM" title="新增" style="background-color:#39b54a"><svg viewBox="0 0 1024 1024" width="14px" height="14px" style="display:block" class="icon_knQK"><path d="M512 71.68c-242.688 0-440.32 197.632-440.32 440.32s197.632 440.32 440.32 440.32 440.32-197.632 440.32-440.32-197.632-440.32-440.32-440.32z m0 819.2c-208.896 0-378.88-169.984-378.88-378.88s169.984-378.88 378.88-378.88 378.88 169.984 378.88 378.88-169.984 378.88-378.88 378.88z" fill="white"></path><path d="M542.72 261.12H481.28v220.16H261.12v61.44h220.16v220.16h61.44v-220.16h220.16V481.28h-220.16z" fill="white"></path></svg> <!-- -->新增</label> <strong>多语言支持 <code>.json</code> 文件配置方式(推荐)</strong> <sup>4.8.6</sup> <sup>2023.02.08</sup> <a href="https://gitee.com/dotnetchina/Furion/issues/I6DL71" target="_blank" rel="noopener noreferrer">#I6DL71</a> <a href="https://gitee.com/dotnetchina/Furion/issues/I5DXKP" target="_blank" rel="noopener noreferrer">#I5DXKP</a></li>
<li> <label class="label_p8vM" title="新增" style="background-color:#39b54a"><svg viewBox="0 0 1024 1024" width="14px" height="14px" style="display:block" class="icon_knQK"><path d="M512 71.68c-242.688 0-440.32 197.632-440.32 440.32s197.632 440.32 440.32 440.32 440.32-197.632 440.32-440.32-197.632-440.32-440.32-440.32z m0 819.2c-208.896 0-378.88-169.984-378.88-378.88s169.984-378.88 378.88-378.88 378.88 169.984 378.88 378.88-169.984 378.88-378.88 378.88z" fill="white"></path><path d="M542.72 261.12H481.28v220.16H261.12v61.44h220.16v220.16h61.44v-220.16h220.16V481.28h-220.16z" fill="white"></path></svg> <!-- -->新增</label> <code>L.SetCurrentUICulture(culture)</code><code>L.GetCurrentUICulture()</code> 静态方法,可在运行时动态修改当前线程区域性 <sup>4.8.3.10</sup> <sup>2022.12.23</sup> <a href="https://gitee.com/dotnetchina/Furion/issues/I66JWA" target="_blank" rel="noopener noreferrer">#I66JWA</a></li>
<li> <label class="label_p8vM" title="新增" style="background-color:#39b54a"><svg viewBox="0 0 1024 1024" width="14px" height="14px" style="display:block" class="icon_knQK"><path d="M512 71.68c-242.688 0-440.32 197.632-440.32 440.32s197.632 440.32 440.32 440.32 440.32-197.632 440.32-440.32-197.632-440.32-440.32-440.32z m0 819.2c-208.896 0-378.88-169.984-378.88-378.88s169.984-378.88 378.88-378.88 378.88 169.984 378.88 378.88-169.984 378.88-378.88 378.88z" fill="white"></path><path d="M542.72 261.12H481.28v220.16H261.12v61.44h220.16v220.16h61.44v-220.16h220.16V481.28h-220.16z" fill="white"></path></svg> <!-- -->新增</label> <code>L.SetCulture(culture, immediately)</code> 方法重载,可配置运行时修改多语言立即有效 <sup>4.8.3.10</sup> <sup>2022.12.23</sup> <a href="https://gitee.com/dotnetchina/Furion/issues/I66JWA" target="_blank" rel="noopener noreferrer">#I66JWA</a></li>
</ul>
</li>
<li>
<p><strong>其他更改</strong></p>
<ul>
<li> <label class="label_p8vM" title="调整" style="background-color:#333"><svg viewBox="0 0 1024 1024" width="14px" height="14px" style="display:block" class="icon_knQK"><path d="M380.15463648 874.54223633c0 18.12744166-14.83154297 32.95898463-32.95898463 32.95898463s-32.95898463-14.83154297-32.95898462-32.95898463V228.9152832L172.71078883 370.86962865a33.04467773 33.04467773 0 0 1-46.60400416 0 33.04467773 33.04467773 0 0 1 0-46.6040034l197.55615234-198.14941406A32.76782227 32.76782227 0 0 1 347.0967749 116.52514674c0.03295924 0 0.06591772-0.03295924 0.09887695-0.03295924 1.54907201 0 2.90039088 0.69213867 4.41650366 0.88989258 2.66967773 0.39550781 5.40527318 0.59326172 7.94311548 1.61499049 12.03002904 4.94384766 20.59936549 16.71020508 20.59936549 30.45410156v725.0910642z m320.15698192 23.34155248a32.85351537 32.85351537 0 0 1-23.43383789 9.59106445c-0.03295924 0-0.06591772 0.03295924-0.09887696 0.03295924-1.54907201 0-2.90039088-0.69213867-4.41650365-0.92285182-2.70263697-0.36254857-5.40527318-0.56030248-7.94311549-1.61498972-12.03002904-4.91088842-20.59936549-16.67724584-20.59936473-30.42114309V149.45776367c0-18.12744166 14.83154297-32.95898463 32.95898387-32.95898463s32.95898463 14.83154297 32.95898463 32.95898463v645.60058619l141.52587916-141.92138697c12.81445313-12.82104467 33.81591797-12.82104467 46.63037109 0 12.78808619 12.81445313 12.78808619 33.77636719 0 46.60400416L700.3116184 897.88378881z" fill="white"></path></svg> <!-- -->调整</label> 多语言中间件 <code>app.UseAppLocalization()</code> 添加 <code>Action&lt;options&gt;</code> 委托参数 <sup>4.8.7.30</sup> <sup>2023.03.31</sup> <a href="https://gitee.com/dotnetchina/Furion/issues/I6RUOU" target="_blank" rel="noopener noreferrer">#I6RUOU</a></li>
</ul>
</li>
<li>
<p><strong>文档</strong></p>
<ul>
<li> <label class="label_p8vM" title="新增" style="background-color:#39b54a"><svg viewBox="0 0 1024 1024" width="14px" height="14px" style="display:block" class="icon_knQK"><path d="M512 71.68c-242.688 0-440.32 197.632-440.32 440.32s197.632 440.32 440.32 440.32 440.32-197.632 440.32-440.32-197.632-440.32-440.32-440.32z m0 819.2c-208.896 0-378.88-169.984-378.88-378.88s169.984-378.88 378.88-378.88 378.88 169.984 378.88 378.88-169.984 378.88-378.88 378.88z" fill="white"></path><path d="M542.72 261.12H481.28v220.16H261.12v61.44h220.16v220.16h61.44v-220.16h220.16V481.28h-220.16z" fill="white"></path></svg> <!-- -->新增</label> <strong>多语言 <code>.json</code> 配置方式文档</strong></li>
</ul>
</li>
</ul></div></div></div></div></details>
<!-- -->
<!-- -->
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="211-全球化和本地化">21.1 全球化和本地化<a href="#211-全球化和本地化" class="hash-link" aria-label="Direct link to 21.1 全球化和本地化" title="Direct link to 21.1 全球化和本地化"></a></h2>
<p><strong>全球化</strong> 是设计支持不同区域性的应用程序的过程。 全球化添加了对一组有关特定地理区域的已定义语言脚本的输入、显示和输出支持。</p>
<p><strong>本地化</strong> 是将已经针对可本地化性进行处理的全球化应用调整为特定的区域性/区域设置的过程。</p>
<p>通俗来说,就是使应用或系统支持多语言切换。<code>Furion</code> 框架提供了完整支持多语言处理的服务。</p>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="212-注册服务">21.2 注册服务<a href="#212-注册服务" class="hash-link" aria-label="Direct link to 21.2 注册服务" title="Direct link to 21.2 注册服务"></a></h2>
<p>在使用多语言服务之前,必须先注册服务,如:</p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">ConfigureServices</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 107)">IServiceCollection</span><span class="token plain"> services</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> services</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">AddControllersWithViews</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">AddAppLocalization</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 注册多语言</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">Configure</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 107)">IApplicationBuilder</span><span class="token plain"> app</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><s
<div class="theme-admonition theme-admonition-important admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>特别注意</div><div class="admonitionContent_BuS1"><p><code>app.UseAppLocalization();</code> 必须在 <code>app.UseRouting();</code> 之前注册。</p></div></div>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="213-如何使用">21.3 如何使用<a href="#213-如何使用" class="hash-link" aria-label="Direct link to 21.3 如何使用" title="Direct link to 21.3 如何使用"></a></h2>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2131-配置-localizationsettings">21.3.1 配置 <code>LocalizationSettings</code><a href="#2131-配置-localizationsettings" class="hash-link" aria-label="Direct link to 2131-配置-localizationsettings" title="Direct link to 2131-配置-localizationsettings"></a></h3>
<p>添加 <code>LocalizationSettings</code> 配置选项:</p>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">{</span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;LocalizationSettings&quot;: {</span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;SupportedCultures&quot;: [&quot;zh-CN&quot;, &quot;en-US&quot;], // 配置支持的语言列表</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;DefaultCulture&quot;: &quot;zh-CN&quot; // 配置默认语言,如果不配置,取 SupportedCultures 的第一项</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> }</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">}</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2132-创建-resources-文件夹">21.3.2 创建 <code>Resources</code> 文件夹<a href="#2132-创建-resources-文件夹" class="hash-link" aria-label="Direct link to 2132-创建-resources-文件夹" title="Direct link to 2132-创建-resources-文件夹"></a></h3>
<p>接下来在 <code>Web启动项目层</code> 添加 <code>Resources</code> 文件夹,如图:(<strong>可配置放置任意层,见配置 <code>AssemblyName</code></strong></p>
<img src="/img/lang1.png">
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="214-l-静态类">21.4 <code>L</code> 静态类<a href="#214-l-静态类" class="hash-link" aria-label="Direct link to 214-l-静态类" title="Direct link to 214-l-静态类"></a></h2>
<p><code>Furion</code> 框架主要通过 <code>L</code> 静态类完成多语言转换,该静态类有以下属性和方法:</p>
<ul>
<li><strong><code>L.Text[文本]</code></strong>:转换文本多语言</li>
<li><strong><code>L.Html[HTML代码, 格式化]</code></strong>:转换 <code>Html</code> 多语言</li>
<li><code>L.TextOf&lt;T&gt;()[文本]</code>转换文本多语言使用该方式那么资源文件需使用完整类型限定名Furion 4.8.6+ 支持</li>
<li><code>L.HtmlOf&lt;T&gt;()[HTML代码, 格式化]</code>:转换 <code>Html</code> 多语言使用该方式那么资源文件需使用完整类型限定名Furion 4.8.6+ 支持</li>
<li><code>L.SetCulture(区域码)</code>:设置当前语言区域,默认在下一次请求有效,第二个参数设置 <code>true</code> 立即有效</li>
<li><code>L.GetSelectCulture()</code>:获取当前的语言区域</li>
<li><code>L.GetCultures()</code>:获取系统支持的多语言列表</li>
<li><code>L.SetCurrentUICulture(区域码)</code>:运行时设置当前线程语言区域,立即有效,<code>Furion 4.8.3.10+</code> 版本有效</li>
<li><code>L.GetCurrentUICulture()</code> 获取当前线程 UI 区域性,<code>Furion 4.8.3.10+</code> 版本有效</li>
<li><code>L.GetString&lt;T&gt;(u =&gt; u.属性)</code> 根据表达式获取翻译,<code>Furion 4.8.3.10+</code> 版本有效</li>
<li><code>L.GetString(name, culture)</code> 获取指定的区域翻译,<code>Furion 4.8.8.41+</code> 版本有效</li>
<li><code>L.GetDefaultCulture()</code> 获取本地配置默认语言,<code>Furion 4.8.8.49+</code> 版本有效</li>
</ul>
<div class="theme-admonition theme-admonition-tip admonition_xJq3 alert alert--success"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>小提示</div><div class="admonitionContent_BuS1"><p>通过 <code>L.SetCulture</code> 实际上是往客户端写入区域 <code>Cookie</code> 数据,也就是只对下一次请求有效,如果希望运行时立即有效,可通过 <code>L.SetCurrentUICulture</code> 设置或一起设置即可。</p><p>也可以直接通过设置 <code>L.SetCulture(区域码, true)</code> 立即生效(包含当前请求(线程)和下一次请求)。</p></div></div>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="215-使用例子">21.5 使用例子<a href="#215-使用例子" class="hash-link" aria-label="Direct link to 21.5 使用例子" title="Direct link to 21.5 使用例子"></a></h2>
<p>通过上面的配置步骤之后,我们就可以通过 <code>L</code> 静态类在代码任何位置使用了,如:</p>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2151-在类中使用">21.5.1 在类中使用<a href="#2151-在类中使用" class="hash-link" aria-label="Direct link to 21.5.1 在类中使用" title="Direct link to 21.5.1 在类中使用"></a></h3>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 文本多语言</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">var</span><span class="token plain"> apiInterface </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;API 接口&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">var</span><span class="token plain"> sourceCode </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;源码地址&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">var</span><span class="token plain"> other </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;其他{0}&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// HTML 标记多语言</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style=
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2152-在视图中使用">21.5.2 在视图中使用<a href="#2152-在视图中使用" class="hash-link" aria-label="Direct link to 21.5.2 在视图中使用" title="Direct link to 21.5.2 在视图中使用"></a></h3>
<div class="language-html codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-html codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">@using Furion.Localization</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token tag" style="color:rgb(255, 85, 114)">div</span><span class="token tag" style="color:rgb(255, 85, 114)"> </span><span class="token tag special-attr attr-name" style="color:rgb(255, 203, 107)">style</span><span class="token tag special-attr attr-value punctuation attr-equals" style="color:rgb(199, 146, 234)">=</span><span class="token tag special-attr attr-value punctuation" style="color:rgb(199, 146, 234)">&quot;</span><span class="token tag special-attr attr-value value css language-css property" style="color:rgb(255, 85, 114)">text-align</span><span class="token tag special-attr attr-value value css language-css punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token tag special-attr attr-value value css language-css" style="color:rgb(255, 85, 114)">center</span><span class="token tag special-attr attr-value value css language-css punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token tag special-attr attr-value value css language-css property" style="color:rgb(255, 85, 114)">margin-top</span><span class="token tag special-attr attr-value value css language-css punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token tag special-attr attr-value value css language-css number" style="color:rgb(247, 140, 108)">50</span><span class="token tag special-attr attr-value value css language-css unit" style="color:rgb(255, 85, 114)">px</span><span class="token tag special-attr attr-value value css language-css punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token tag special-attr attr-value punctuation" style="color:rgb(199, 146, 234)">&quot;</span><span class="token tag punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token tag" style="color:rgb(255, 85, 114)">p</span><span class="token tag punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token plain">让 .NET 开发更简单,更通用,更流行。</span><span class="token tag punctuation" style="color:rgb(199, 146, 234)">&lt;/</span><span class="token tag" style="color:rgb(255, 85, 114)">p</span><span class="token tag punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token tag" style="color:rgb(255, 85, 114)">p</span><span class="token tag punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token plain"></span></span><br></span><span class="token-line theme-c
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2153-在验证特性中使用">21.5.3 在验证特性中使用<a href="#2153-在验证特性中使用" class="hash-link" aria-label="Direct link to 21.5.3 在验证特性中使用" title="Direct link to 21.5.3 在验证特性中使用"></a></h3>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token attribute class-name" style="color:rgb(255, 203, 107)">Required</span><span class="token attribute attribute-arguments punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token attribute attribute-arguments">ErrorMessage </span><span class="token attribute attribute-arguments operator" style="color:rgb(137, 221, 255)">=</span><span class="token attribute attribute-arguments"> </span><span class="token attribute attribute-arguments string" style="color:rgb(195, 232, 141)">&quot;必填消息&quot;</span><span class="token attribute attribute-arguments punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p><strong>所有验证特性已经自动支持多语言配置了,无需通过 <code>L.Text[]</code> 调用。</strong></p>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2154-在异常消息中使用">21.5.4 在异常消息中使用<a href="#2154-在异常消息中使用" class="hash-link" aria-label="Direct link to 21.5.4 在异常消息中使用" title="Direct link to 21.5.4 在异常消息中使用"></a></h3>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token keyword" style="font-style:italic">using</span><span class="token plain"> </span><span class="token namespace" style="color:rgb(178, 204, 214)">Furion</span><span class="token namespace punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token namespace" style="color:rgb(178, 204, 214)">FriendlyException</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token keyword" style="font-style:italic">namespace</span><span class="token plain"> </span><span class="token namespace" style="color:rgb(178, 204, 214)">Furion</span><span class="token namespace punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token namespace" style="color:rgb(178, 204, 214)">Application</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token attribute class-name" style="color:rgb(255, 203, 107)">ErrorCodeType</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">enum</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">ErrorCodes</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token attribute class-name" style="color:rgb(255, 203, 107)">ErrorCodeItemMetadata</span><span class="token attribute attribute-arguments punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token attribute attribute-arguments string" style="color:rgb(195, 232, 141)">&quot;用户名不能为空&quot;</span><span class="token attribute attribute-arguments punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)
<p><strong>所有异常消息特性已经自动支持多语言配置了,无需通过 <code>L.Text[]</code> 调用。</strong></p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token keyword" style="font-style:italic">throw</span><span class="token plain"> Oops</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">Oh</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">ErrorCodes</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">z1000</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 自动应用多语言</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2155-sharedresource-模式">21.5.5 <code>SharedResource</code> 模式<a href="#2155-sharedresource-模式" class="hash-link" aria-label="Direct link to 2155-sharedresource-模式" title="Direct link to 2155-sharedresource-模式"></a></h3>
<div class="theme-admonition theme-admonition-important admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>版本说明</div><div class="admonitionContent_BuS1"><p>以下内容仅限 <code>Furion 4.3.7 +</code> 版本使用。</p></div></div>
<p>正常情况下,我们都是通过 <code>L.Text[&quot;Hello&quot;]</code> 方式输出 <code>Hello</code> 在不同的区域语言的翻译,但是会导致 <code>Hello</code> 硬编码字符串散落到处都是。</p>
<p>所以 <code>Furion</code> 提供了 <code>SharedResource</code> 模式,只需要创建一个 <code>SharedResource.cs</code> 类(可以任何名字)并添加对应的属性即可,如:</p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token keyword" style="font-style:italic">namespace</span><span class="token plain"> </span><span class="token namespace" style="color:rgb(178, 204, 214)">Furion</span><span class="token namespace punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token namespace" style="color:rgb(178, 204, 214)">Core</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">SharedResource</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">string</span><span class="token plain"> Hello </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">set</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">string</span><span class="token plain"> Name </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">set</span><span class="token punctuatio
<p>使用如下:</p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">var</span><span class="token plain"> hello </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token generic-method function" style="color:rgb(130, 170, 255)">GetString</span><span class="token generic-method generic class-name punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token generic-method generic class-name" style="color:rgb(255, 203, 107)">SharedResource</span><span class="token generic-method generic class-name punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">u </span><span class="token operator" style="color:rgb(137, 221, 255)">=&gt;</span><span class="token plain"> u</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Hello</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 比 L.Text[&quot;Hello&quot;]; 容易维护</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">var</span><span class="token plain"> name </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token generic-method function" style="color:rgb(130, 170, 255)">GetString</span><span class="token generic-method generic class-name punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token generic-method generic class-name" style="color:rgb(255, 203, 107)">SharedResource</span><span class="token generic-method generic class-name punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">u </span><span class="token operator" style="color:rgb(137, 221, 255)">=&gt;</span><span class="token plain"> u</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 比 L.Text[&quot;Name&quot;]; 容易维护</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>当然也有更简单的方式,就是使用 <code>nameof</code>,如:</p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">var</span><span class="token plain"> hello </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token keyword" style="font-style:italic">nameof</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">SharedResource</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Hello</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 比 L.Text[&quot;Hello&quot;]; 容易维护</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">var</span><span class="token plain"> name </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token keyword" style="font-style:italic">nameof</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">SharedResource</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 比 L.Text[&quot;Name&quot;]; 容易维护</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="216-创建语言翻译文件">21.6 创建语言翻译文件<a href="#216-创建语言翻译文件" class="hash-link" aria-label="Direct link to 21.6 创建语言翻译文件" title="Direct link to 21.6 创建语言翻译文件"></a></h2>
<p><code>Furion</code> 框架中,如果没找到对应的语言翻译文件,则自动显示字符串文本,如:</p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;没找到&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// =&gt; 如果设置为英文,但是没有文件,则直接输出 “没找到”</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2161-在-resources-文件夹中创建语言文件">21.6.1 在 <code>Resources</code> 文件夹中创建语言文件<a href="#2161-在-resources-文件夹中创建语言文件" class="hash-link" aria-label="Direct link to 2161-在-resources-文件夹中创建语言文件" title="Direct link to 2161-在-resources-文件夹中创建语言文件"></a></h3>
<p>接下来,我们只需要在刚刚的 <code>Resources</code> 文件夹中添加 <code>.resx</code> 资源文件即可,资源文件命名规则:<code>Lang.区域码.resx</code>,如:<code>Lang.en-US.resx</code></p>
<img src="/img/lang2.png">
<img src="/img/lang3.png">
<p></p>
<p>接下来,只需要把对应语言版本的键值对填写即可。</p>
<div class="theme-admonition theme-admonition-tip admonition_xJq3 alert alert--success"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>自定义资源文件名或存放程序集</div><div class="admonitionContent_BuS1"><p>默认情况下,资源文件名必须以 <code>Lang</code> 开头,且默认放在启动层,如果需要自定义,添加配置文件即可</p><div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">{</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;LocalizationSettings&quot;: {</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;LanguageFilePrefix&quot;: &quot;MyLang&quot;</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> // &quot;AssemblyName&quot;: &quot;你的其他层程序集名称&quot;</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> }</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">}</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>之后,就可以:<code>MyLang.区域码.resx</code></p></div></div>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="217-切换语言">21.7 切换语言<a href="#217-切换语言" class="hash-link" aria-label="Direct link to 21.7 切换语言" title="Direct link to 21.7 切换语言"></a></h2>
<p><code>Furion</code> 提供了三种语言切换方式进行切换语言:</p>
<ul>
<li><code>URL 参数</code> 方式: <code>?culture=en-US</code><strong>此方式优先级最高</strong>,格式为:<code>culture=区域码</code></li>
<li><code>Cookies</code> 方式:调用 <code>L.SetCulture(区域码)</code> 方式切换</li>
<li><code>客户端浏览器语言自动匹配</code>:如果前面两种方式都没有设置,<strong>支持自动根据客户端浏览器语言进行匹配。</strong></li>
</ul>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2171-url-参数-方式">21.7.1 <code>URL 参数</code> 方式<a href="#2171-url-参数-方式" class="hash-link" aria-label="Direct link to 2171-url-参数-方式" title="Direct link to 2171-url-参数-方式"></a></h3>
<img src="/img/lang4.gif">
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2172-cookies-方式">21.7.2 <code>Cookies</code> 方式<a href="#2172-cookies-方式" class="hash-link" aria-label="Direct link to 2172-cookies-方式" title="Direct link to 2172-cookies-方式"></a></h3>
<p>此方式只需要提供一个 <code>api</code> 或设置代码即可:</p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">SetCulture</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;en-US&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// en-US 也可以通过前端传递过来,这样就可以不用 `culture` 参数了,可以自定义参数。</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>这样就可以直接根据客户端存储的 <code>cookies</code> 自动切换了。</p>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2173-客户端浏览器语言自动切换">21.7.3 <code>客户端浏览器语言自动切换</code><a href="#2173-客户端浏览器语言自动切换" class="hash-link" aria-label="Direct link to 2173-客户端浏览器语言自动切换" title="Direct link to 2173-客户端浏览器语言自动切换"></a></h3>
<p>推荐此方式,可以自动根据浏览器的语言自动配置:</p>
<img src="/img/lang5.gif">
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2174-请求报文头-accept-language-方式">21.7.4 请求报文头 <code>Accept-Language</code> 方式<a href="#2174-请求报文头-accept-language-方式" class="hash-link" aria-label="Direct link to 2174-请求报文头-accept-language-方式" title="Direct link to 2174-请求报文头-accept-language-方式"></a></h3>
<p>如果使用第三方工具请求,也可以添加请求报文头方式,如:</p>
<div class="language-txt codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-txt codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">Accept-Language: en-US</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2175-请求报文头-cookie-方式">21.7.5 请求报文头 <code>Cookie</code> 方式<a href="#2175-请求报文头-cookie-方式" class="hash-link" aria-label="Direct link to 2175-请求报文头-cookie-方式" title="Direct link to 2175-请求报文头-cookie-方式"></a></h3>
<p>如果使用第三方工具请求,也可以添加请求报文头方式,如:</p>
<div class="language-txt codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-txt codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">Cookie: c%3Den-US%7Cuic%3Den-USen-US</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>它的明文格式为:<code>c=en-US|uic=en-US</code></p>
<div class="theme-admonition theme-admonition-caution admonition_xJq3 alert alert--warning"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>注意</div><div class="admonitionContent_BuS1"><p>这种方式不能使用 <code>明文</code>,否则无效。另外 <code>c</code><code>uic</code> 的值通常一致。</p></div></div>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="218-依赖注入方式使用">21.8 依赖注入方式使用<a href="#218-依赖注入方式使用" class="hash-link" aria-label="Direct link to 21.8 依赖注入方式使用" title="Direct link to 21.8 依赖注入方式使用"></a></h2>
<p><code>Furion</code> 框架也兼容 <code>.NET Core</code> 自带的依赖注入方式,如:</p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">TestController</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"> </span><span class="token type-list class-name" style="color:rgb(255, 203, 107)">Controller</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">private</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">readonly</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">IStringLocalizer</span><span class="token plain"> _localizer</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">TestController</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 107)">IStringLocalizerFactory</span><span class="token plain"> factory</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> _localizer </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> factory</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">Create</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" s
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="219-localizationsettings-配置">21.9 <code>LocalizationSettings</code> 配置<a href="#219-localizationsettings-配置" class="hash-link" aria-label="Direct link to 219-localizationsettings-配置" title="Direct link to 219-localizationsettings-配置"></a></h2>
<ul>
<li><code>LocalizationSettings</code> 多语言配置根节点<!-- -->
<ul>
<li><code>ResourcesPath</code>:资源目录,<code>string</code> 类型,默认 <code>Resources</code></li>
<li><code>SupportedCultures</code>:支持的语言区域码类别,<code>string[]</code> 类型</li>
<li><code>DefaultCulture</code>:默认语言区域码,如果为空,则取 <code>SupportedCultures</code> 第一项</li>
<li><code>LanguageFilePrefix</code>:配置资源文件前缀,<code>string</code>型,默认 <code>Lang</code></li>
<li><code>AssemblyName</code>:配置资源文件存放程序集名,<code>string</code> 类型,默认 <code>启动层</code> 名称</li>
</ul>
</li>
</ul>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2110-关于中文不能切换问题">21.10 关于中文不能切换问题<a href="#2110-关于中文不能切换问题" class="hash-link" aria-label="Direct link to 21.10 关于中文不能切换问题" title="Direct link to 21.10 关于中文不能切换问题"></a></h2>
<p>若通过 <code>dotnet build</code> 命令行编译后发布的代码(比如 <code>jenkins</code> 以及其他 <code>devops</code> 工具),无法生成 <code>zh-CN</code> 资源文件,会出现中文无法显示的问题,这时候只需要将 <code>Lang.zh-CN.resx</code> 修改为:<code>Lang.zh-Hans.resx</code><code>Lang.zh-Hant.resx</code><code>Lang.zh.resx</code> 即可。</p>
<p>相关文档说明 <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.globalization.cultureinfo?view=net-6.0" target="_blank" rel="noopener noreferrer">https://docs.microsoft.com/zh-cn/dotnet/api/system.globalization.cultureinfo?view=net-6.0</a></p>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2111-基于-json-文件多语言">21.11 基于 <code>JSON</code> 文件多语言<a href="#2111-基于-json-文件多语言" class="hash-link" aria-label="Direct link to 2111-基于-json-文件多语言" title="Direct link to 2111-基于-json-文件多语言"></a></h2>
<div class="theme-admonition theme-admonition-important admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>版本说明</div><div class="admonitionContent_BuS1"><p>以下内容仅限 <code>Furion 4.8.6 +</code> 版本使用。</p></div></div>
<p>在默认情况下,微软推荐使用 <code>.resx</code> 资源文件格式作为多语言配置文件格式,<strong>但此方式无法在运行时进行修改</strong>。所以社区更多使用的是 <code>.json</code> 文件格式作为多语言配置,可在运行时动态修改。</p>
<hr>
<p><strong><code>Furion</code> 框架默认不提供 <code>json</code> 多语言配置功能,但非常容易集成第三方多语言库</strong>,在这里推荐:<a href="https://github.com/hishamco/My.Extensions.Localization.Json" target="_blank" rel="noopener noreferrer">https://github.com/hishamco/My.Extensions.Localization.Json</a></p>
<p><strong>1. 安装 <code>My.Extensions.Localization.Json</code> 拓展,通常安装在 <code>XXX.Web.Core</code></strong></p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">dotnet add package My.Extensions.Localization.Json</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p><strong>2. 在 <code>Startup.cs</code> 中注册服务</strong></p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">ConfigureServices</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 107)">IServiceCollection</span><span class="token plain"> services</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> services</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">AddControllersWithViews</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">AddAppLocalization</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">settings </span><span class="token operator" style="color:rgb(137, 221, 255)">=&gt;</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 集成第三方 json 配置</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> services</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">AddJsonLocalization</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">options </span><span class="token operator" style="color:rgb(137, 221, 255)">=&gt;</span><span class="token plain"> options</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">ResourcesPath </span><span class="token o
<div class="theme-admonition theme-admonition-important admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>特别注意</div><div class="admonitionContent_BuS1"><p><code>app.UseAppLocalization();</code> 必须在 <code>app.UseRouting();</code> 之前注册。</p></div></div>
<p><strong>3. 在 <code>Resources</code> 文件夹中添加 <code>.json</code> 文件即可,资源文件命名规则:<code>Lang.区域码.json</code>,如:<code>Lang.en-US.json</code></strong></p>
<img src="/img/dyy1.png">
<img src="/img/dyy2.png">
<div class="theme-admonition theme-admonition-tip admonition_xJq3 alert alert--success"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>自定义资源文件名或存放程序集</div><div class="admonitionContent_BuS1"><p>默认情况下,资源文件名必须以 <code>Lang</code> 开头,且默认放在启动层,如果需要自定义,添加配置文件即可</p><div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">{</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;LocalizationSettings&quot;: {</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;LanguageFilePrefix&quot;: &quot;MyLang&quot;</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> // &quot;AssemblyName&quot;: &quot;你的其他层程序集名称&quot;</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> }</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">}</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>之后,就可以:<code>MyLang.区域码.json</code></p></div></div>
<p><strong>4. 在代码中使用</strong></p>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;Furion&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// =&gt; 如果设置为英文,但是没有文件,则直接输出 “Furion”</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<div class="theme-admonition theme-admonition-tip admonition_xJq3 alert alert--success"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>小知识</div><div class="admonitionContent_BuS1"><p><strong>集成第三方多语言库除了注册服务和文件后缀名有区别,其他用法一模一样(包括全局配置,用法等)</strong>,也就是任何时候替换成第三方都可以,业务使用代码无需更改。</p></div></div>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2112-多语言其他实现">21.12 多语言其他实现<a href="#2112-多语言其他实现" class="hash-link" aria-label="Direct link to 21.12 多语言其他实现" title="Direct link to 21.12 多语言其他实现"></a></h2>
<p><code>asp.net core 本地化</code> 文档中微软推荐了三个拓展开源项目:<a href="https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/localization-extensibility?view=aspnetcore-6.0#localization-resources" target="_blank" rel="noopener noreferrer">https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/localization-extensibility?view=aspnetcore-6.0#localization-resources</a></p>
<p>选择自己合适的即可。</p>
<img src="/img/lang6.png">
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2113-在-winformwpf-中使用">21.13 在 <code>WinForm/WPF</code> 中使用<a href="#2113-在-winformwpf-中使用" class="hash-link" aria-label="Direct link to 2113-在-winformwpf-中使用" title="Direct link to 2113-在-winformwpf-中使用"></a></h2>
<p>框架提供了完整的多语言在 <code>WinForm/WPF</code> 中使用。</p>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="21131-winform-中使用">21.13.1 <code>WinForm</code> 中使用<a href="#21131-winform-中使用" class="hash-link" aria-label="Direct link to 21131-winform-中使用" title="Direct link to 21131-winform-中使用"></a></h3>
<ul>
<li>注册 <code>services.AddAppLocalization()</code> 服务</li>
</ul>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token keyword" style="font-style:italic">using</span><span class="token plain"> </span><span class="token namespace" style="color:rgb(178, 204, 214)">Microsoft</span><span class="token namespace punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token namespace" style="color:rgb(178, 204, 214)">Extensions</span><span class="token namespace punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token namespace" style="color:rgb(178, 204, 214)">DependencyInjection</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token keyword" style="font-style:italic">namespace</span><span class="token plain"> </span><span class="token namespace" style="color:rgb(178, 204, 214)">WinFormsApp1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token keyword" style="font-style:italic">internal</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">static</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">Program</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token attribute class-name" style="color:rgb(255, 203, 107)">STAThread</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">static</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(255, 203, 107);font-style:italic">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">Main</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><br></span
<ul>
<li>添加 <code>appsettings.json</code> 配置文件,并设置属性为 <code>如果较新则复制</code></li>
</ul>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">{</span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;LocalizationSettings&quot;: {</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;SupportedCultures&quot;: [&quot;zh-CN&quot;, &quot;en-US&quot;], // 配置支持的语言列表</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;DefaultCulture&quot;: &quot;zh-CN&quot; // 配置默认语言,如果不配置,取 SupportedCultures 的第一项</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> }</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">}</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<ul>
<li>添加 <code>Resources</code> 文件夹并添加 <code>Lang.区域码.resx</code> 资源文件</li>
</ul>
<p>参考 <a href="/docs/local-language#2161-%E5%9C%A8-resources-%E6%96%87%E4%BB%B6%E5%A4%B9%E4%B8%AD%E5%88%9B%E5%BB%BA%E8%AF%AD%E8%A8%80%E6%96%87%E4%BB%B6">21.6.1 在 Resources 文件夹中创建语言文件</a></p>
<ul>
<li>在代码中使用</li>
</ul>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 设置当前线程 UI 区域性</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">SetCurrentUICulture</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;en-US&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 通过 L.Text[Key] 获取</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">label1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;API 接口&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="21132-在-wpf-中使用">21.13.2 在 <code>WPF</code> 中使用<a href="#21132-在-wpf-中使用" class="hash-link" aria-label="Direct link to 21132-在-wpf-中使用" title="Direct link to 21132-在-wpf-中使用"></a></h3>
<ul>
<li>注册 <code>services.AddAppLocalization()</code> 服务</li>
</ul>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token keyword" style="font-style:italic">namespace</span><span class="token plain"> </span><span class="token namespace" style="color:rgb(178, 204, 214)">WpfApp1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain" style="display:inline-block"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">partial</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">App</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"> </span><span class="token type-list class-name" style="color:rgb(255, 203, 107)">Application</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">public</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">App</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> Serve</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">RunNative</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">services </span><span class="token operator" style="color:rgb(137, 221, 255)">=&gt;</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_fea
<ul>
<li>添加 <code>appsettings.json</code> 配置文件,并设置属性为 <code>如果较新则复制</code></li>
</ul>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">{</span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;LocalizationSettings&quot;: {</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;SupportedCultures&quot;: [&quot;zh-CN&quot;, &quot;en-US&quot;], // 配置支持的语言列表</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;DefaultCulture&quot;: &quot;zh-CN&quot; // 配置默认语言,如果不配置,取 SupportedCultures 的第一项</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> }</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">}</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<ul>
<li>添加 <code>Resources</code> 文件夹并添加 <code>Lang.区域码.resx</code> 资源文件</li>
</ul>
<p>参考 <a href="/docs/local-language#2161-%E5%9C%A8-resources-%E6%96%87%E4%BB%B6%E5%A4%B9%E4%B8%AD%E5%88%9B%E5%BB%BA%E8%AF%AD%E8%A8%80%E6%96%87%E4%BB%B6">21.6.1 在 Resources 文件夹中创建语言文件</a></p>
<ul>
<li>在代码中使用</li>
</ul>
<div class="language-cs codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cs codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 设置当前线程 UI 区域性</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">SetCurrentUICulture</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;en-US&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"></span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// 通过 L.Text[Key] 获取</span><span class="token plain"></span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">label1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Name </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> L</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;API 接口&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2114-关于-datetimenow-问题">21.14 关于 <code>DateTime.Now</code> 问题<a href="#2114-关于-datetimenow-问题" class="hash-link" aria-label="Direct link to 2114-关于-datetimenow-问题" title="Direct link to 2114-关于-datetimenow-问题"></a></h2>
<div class="theme-admonition theme-admonition-important admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>版本说明</div><div class="admonitionContent_BuS1"><p>以下内容仅限 <code>Furion 4.8.7.31 +</code> 版本使用。</p></div></div>
<p>启用了多语言功能之后很有可能会影响 <code>DateTime.Now</code> 获取的时间所在的时区,比如设置多语言区域设置为 <code>en-US</code>,那么获取的就是国外的时间。所以,<strong>尽可能的使用 <code>DateTime.UtcNow</code> 或者 <code>DateTimeOffset.UtNow</code> 记录时间</strong></p>
<p>当然也可以添加配置,固定时间区域为特定时区,比如北京时间。</p>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv codeBlockLinesWithNumbering_o6Pm"><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">{</span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;LocalizationSettings&quot;: {</span></span><br></span><span class="token-line theme-code-block-highlighted-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> &quot;DateTimeFormatCulture&quot;: &quot;zh-CN&quot;</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain"> }</span></span><br></span><span class="token-line codeLine_lJS_" style="color:#bfc7d5"><span class="codeLineNumber_Tfdd"></span><span class="codeLineContent_feaV"><span class="token plain">}</span></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2115-关于-blazor-项目问题">21.15 关于 <code>Blazor</code> 项目问题<a href="#2115-关于-blazor-项目问题" class="hash-link" aria-label="Direct link to 2115-关于-blazor-项目问题" title="Direct link to 2115-关于-blazor-项目问题"></a></h2>
<p>如果使用的是 <code>.razor</code> 组件,那么只支持请求头中携带 <code>Accept-Language</code><code>cookies</code> 方式,有关配置可查阅相关 <code>Issue</code><a href="https://gitee.com/dotnetchina/Furion/issues/I7ERGO" target="_blank" rel="noopener noreferrer">https://gitee.com/dotnetchina/Furion/issues/I7ERGO</a></p>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2116-区域码列表">21.16 区域码列表<a href="#2116-区域码列表" class="hash-link" aria-label="Direct link to 21.16 区域码列表" title="Direct link to 21.16 区域码列表"></a></h2>
<ul>
<li>af 公用荷兰语</li>
<li>af-ZA 公用荷兰语 - 南非</li>
<li>sq 阿尔巴尼亚</li>
<li>sq-AL 阿尔巴尼亚 -阿尔巴尼亚</li>
<li>ar 阿拉伯语</li>
<li>ar-DZ 阿拉伯语 -阿尔及利亚</li>
<li>ar-BH 阿拉伯语 -巴林</li>
<li>ar-EG 阿拉伯语 -埃及</li>
<li>ar-IQ 阿拉伯语 -伊拉克</li>
<li>ar-JO 阿拉伯语 -约旦</li>
<li>ar-KW 阿拉伯语 -科威特</li>
<li>ar-LB 阿拉伯语 -黎巴嫩</li>
<li>ar-LY 阿拉伯语 -利比亚</li>
<li>ar-MA 阿拉伯语 -摩洛哥</li>
<li>ar-OM 阿拉伯语 -阿曼</li>
<li>ar-QA 阿拉伯语 -卡塔尔</li>
<li>ar-SA 阿拉伯语 - 沙特阿拉伯</li>
<li>ar-SY 阿拉伯语 -叙利亚共和国</li>
<li>ar-TN 阿拉伯语 -北非的共和国</li>
<li>ar-AE 阿拉伯语 - 阿拉伯联合酋长国</li>
<li>ar-YE 阿拉伯语 -也门</li>
<li>hy 亚美尼亚</li>
<li>hy-AM 亚美尼亚的 -亚美尼亚</li>
<li>az Azeri</li>
<li>az-AZ-Cyrl Azeri-(西里尔字母的) 阿塞拜疆</li>
<li>az-AZ-Latn Azeri(拉丁文)- 阿塞拜疆</li>
<li>eu 巴斯克</li>
<li>eu-ES 巴斯克 -巴斯克</li>
<li>be Belarusian</li>
<li>be-BY Belarusian-白俄罗斯</li>
<li>bg 保加利亚</li>
<li>bg-BG 保加利亚 -保加利亚</li>
<li>ca 嘉泰罗尼亚</li>
<li>ca-ES 嘉泰罗尼亚 -嘉泰罗尼亚</li>
<li>zh-HK 华 - 香港的 SAR</li>
<li>zh-MO 华 - 澳门的 SAR</li>
<li>zh-CN 华 -中国</li>
<li>zh-CHS 华 (单一化)</li>
<li>zh-SG 华 -新加坡</li>
<li>zh-TW 华 -台湾</li>
<li>zh-CHT 华 (传统的)</li>
<li>hr 克罗埃西亚</li>
<li>hr-HR 克罗埃西亚 -克罗埃西亚</li>
<li>cs 捷克</li>
<li>cs-CZ 捷克 - 捷克</li>
<li>da 丹麦文</li>
<li>da-DK 丹麦文 -丹麦</li>
<li>div Dhivehi</li>
<li>div-MV Dhivehi-马尔代夫</li>
<li>nl 荷兰</li>
<li>nl-BE 荷兰 -比利时</li>
<li>nl-NL 荷兰 - 荷兰</li>
<li>en 英国</li>
<li>en-AU 英国 -澳洲</li>
<li>en-BZ 英国 -伯利兹</li>
<li>en-CA 英国 -加拿大</li>
<li>en-CB 英国 -加勒比海</li>
<li>en-IE 英国 -爱尔兰</li>
<li>en-JM 英国 -牙买加</li>
<li>en-NZ 英国 - 新西兰</li>
<li>en-PH 英国 -菲律宾共和国</li>
<li>en-ZA 英国 - 南非</li>
<li>en-TT 英国 - 千里达托贝哥共和国</li>
<li>en-GB 英国 - 英国</li>
<li>en-US 英国 - 美国</li>
<li>en-ZW 英国 -津巴布韦</li>
<li>et 爱沙尼亚</li>
<li>et-EE 爱沙尼亚的 -爱沙尼亚</li>
<li>fo Faroese</li>
<li>fo-FO Faroese- 法罗群岛</li>
<li>fa 波斯语</li>
<li>fa-IR 波斯语 -伊朗王国</li>
<li>fi 芬兰语</li>
<li>fi-FI 芬兰语 -芬兰</li>
<li>fr 法国</li>
<li>fr-BE 法国 -比利时</li>
<li>fr-CA 法国 -加拿大</li>
<li>fr-FR 法国 -法国</li>
<li>fr-LU 法国 -卢森堡</li>
<li>fr-MC 法国 -摩纳哥</li>
<li>fr-CH 法国 -瑞士</li>
<li>gl 加利西亚</li>
<li>gl-ES 加利西亚 -加利西亚</li>
<li>ka 格鲁吉亚州</li>
<li>ka-GE 格鲁吉亚州 -格鲁吉亚州</li>
<li>de 德国</li>
<li>de-AT 德国 -奥地利</li>
<li>de-DE 德国 -德国</li>
<li>de-LI 德国 -列支敦士登</li>
<li>de-LU 德国 -卢森堡</li>
<li>de-CH 德国 -瑞士</li>
<li>el 希腊</li>
<li>el-GR 希腊 -希腊</li>
<li>gu Gujarati</li>
<li>gu-IN Gujarati-印度</li>
<li>he 希伯来</li>
<li>he-IL 希伯来 -以色列</li>
<li>hi 北印度语</li>
<li>hi-IN 北印度的 -印度</li>
<li>hu 匈牙利</li>
<li>hu-HU 匈牙利的 -匈牙利</li>
<li>is 冰岛语</li>
<li>is-IS 冰岛的 -冰岛</li>
<li>id 印尼</li>
<li>id-ID 印尼 -印尼</li>
<li>it 意大利</li>
<li>it-IT 意大利 -意大利</li>
<li>it-CH 意大利 -瑞士</li>
<li>ja 日本</li>
<li>ja-JP 日本 -日本</li>
<li>kn 卡纳达语</li>
<li>kn-IN 卡纳达语 -印度</li>
<li>kk Kazakh</li>
<li>kk-KZ Kazakh-哈萨克</li>
<li>kok Konkani</li>
<li>kok-IN Konkani-印度</li>
<li>ko 韩国</li>
<li>ko-KR 韩国 -韩国</li>
<li>ky Kyrgyz</li>
<li>ky-KZ Kyrgyz-哈萨克</li>
<li>lv 拉脱维亚</li>
<li>lv-LV 拉脱维亚的 -拉脱维亚</li>
<li>lt 立陶宛</li>
<li>lt-LT 立陶宛 -立陶宛</li>
<li>mk 马其顿</li>
<li>mk-MK 马其顿 -FYROM</li>
<li>ms 马来</li>
<li>ms-BN 马来 -汶莱</li>
<li>ms-MY 马来 -马来西亚</li>
<li>mr 马拉地语</li>
<li>mr-IN 马拉地语 -印度</li>
<li>mn 蒙古</li>
<li>mn-MN 蒙古 -蒙古</li>
<li>no 挪威</li>
<li>nb-NO 挪威 (Bokm?l) - 挪威</li>
<li>nn-NO 挪威 (Nynorsk)- 挪威</li>
<li>pl 波兰</li>
<li>pl-PL 波兰 -波兰</li>
<li>pt 葡萄牙</li>
<li>pt-BR 葡萄牙 -巴西</li>
<li>pt-PT 葡萄牙 -葡萄牙</li>
<li>pa Punjab 语</li>
<li>pa-IN Punjab 语 -印度</li>
<li>ro 罗马尼亚语</li>
<li>ro-RO 罗马尼亚语 -罗马尼亚</li>
<li>ru 俄国</li>
<li>ru-RU 俄国 -俄国</li>
<li>sa 梵文</li>
<li>sa-IN 梵文 -印度</li>
<li>sr-SP-Cyrl 塞尔维亚 -(西里尔字母的) 塞尔维亚共和国</li>
<li>sr-SP-Latn 塞尔维亚 (拉丁文)- 塞尔维亚共和国</li>
<li>sk 斯洛伐克</li>
<li>sk-SK 斯洛伐克 -斯洛伐克</li>
<li>sl 斯洛文尼亚</li>
<li>sl-SI 斯洛文尼亚 -斯洛文尼亚</li>
<li>es 西班牙</li>
<li>es-AR 西班牙 -阿根廷</li>
<li>es-BO 西班牙 -玻利维亚</li>
<li>es-CL 西班牙 -智利</li>
<li>es-CO 西班牙 -哥伦比亚</li>
<li>es-CR 西班牙 - 哥斯达黎加</li>
<li>es-DO 西班牙 - 多米尼加共和国</li>
<li>es-EC 西班牙 -厄瓜多尔</li>
<li>es-SV 西班牙 - 萨尔瓦多</li>
<li>es-GT 西班牙 -危地马拉</li>
<li>es-HN 西班牙 -洪都拉斯</li>
<li>es-MX 西班牙 -墨西哥</li>
<li>es-NI 西班牙 -尼加拉瓜</li>
<li>es-PA 西班牙 -巴拿</li>
<li>es-PY 西班牙 -巴拉圭</li>
<li>es-PE 西班牙 -秘鲁</li>
<li>es-PR 西班牙 - 波多黎各</li>
<li>es-ES 西班牙 -西班牙</li>
<li>es-UY 西班牙 -乌拉圭</li>
<li>es-VE 西班牙 -委内瑞拉</li>
<li>sw Swahili</li>
<li>sw-KE Swahili-肯尼亚</li>
<li>sv 瑞典</li>
<li>sv-FI 瑞典 -芬兰</li>
<li>sv-SE 瑞典 -瑞典</li>
<li>syr Syriac</li>
<li>syr-SY Syriac-叙利亚共和国</li>
<li>ta 坦米尔</li>
<li>ta-IN 坦米尔 -印度</li>
<li>tt Tatar</li>
<li>tt-RU Tatar-俄国</li>
<li>te Telugu</li>
<li>te-IN Telugu-印度</li>
<li>th 泰国</li>
<li>th-TH 泰国 -泰国</li>
<li>tr 土耳其语</li>
<li>tr-TR 土耳其语 -土耳其</li>
<li>uk 乌克兰</li>
<li>uk-UA 乌克兰 -乌克兰</li>
<li>ur Urdu</li>
<li>ur-PK Urdu-巴基斯坦</li>
<li>uz Uzbek</li>
<li>uz-UZ-Cyrl Uzbek-(西里尔字母的) 乌兹别克斯坦</li>
<li>uz-UZ-Latn Uzbek(拉丁文)- 乌兹别克斯坦</li>
<li>vi 越南</li>
<li>vi-VN 越南 -越南</li>
</ul>
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2117-反馈与建议">21.17 反馈与建议<a href="#2117-反馈与建议" class="hash-link" aria-label="Direct link to 21.17 反馈与建议" title="Direct link to 21.17 反馈与建议"></a></h2>
<div class="theme-admonition theme-admonition-note admonition_xJq3 alert alert--secondary"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>与我们交流</div><div class="admonitionContent_BuS1"><p>给 Furion 提 <a href="https://gitee.com/dotnetchina/Furion/issues/new?issue" target="_blank" rel="noopener noreferrer">Issue</a></p></div></div>
<hr>
<div class="theme-admonition theme-admonition-note admonition_xJq3 alert alert--secondary"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>了解更多</div><div class="admonitionContent_BuS1"><p>想了解更多 <code>多语言</code> 知识可查阅 <a href="https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/localization?view=aspnetcore-5.0" target="_blank" rel="noopener noreferrer">ASP.NET Core - 全局化和本地化</a> 章节。</p></div></div></div><footer class="theme-doc-footer docusaurus-mt-lg"><a href="http://github.crmeb.net/u/furion" target="_blank" style="display:block;margin-bottom:20px;text-decoration:none;position:relative;border-radius:5px;overflow:hidden;color:#25c2a0" title="CRMEB 专注开源电商系统研发"><img src="/img/crmeb-spec.jpg" style="display:block;pointer-events:none;max-width:100%"><span style="position:absolute;display:block;right:0;bottom:0;z-index:5;font-size:12px;background-color:rgba(0,0,0,0.8);padding:0 5px">特别赞助</span></a><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a class="ass_kwc6" style="margin:0;margin-bottom:10px;height:80px;z-index:999" href="/docs/subscribe"><div class="title_MSGy">开通 VIP 服务尊享一对一技术指导</div><div class="progress_esN_"><div class="number_F0eG">344</div><div class="percent_Dln9"><div class="current_QYTp" style="width:34.4%"></div></div><div class="number_F0eG">1000</div></div></a><a href="https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/local-language.mdx" target="_blank" rel="noopener noreferrer" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_Z9Sw" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_VsjB"><div class="donate_FEDP" style="margin:0;margin-bottom:10px;border:2px solid #ffb02e;margin-top:-4px" title="您的支持是我们坚持完善下去的动力!"><div style="position:relative;margin-right:9px"><img src="/img/donateme.png" style="height:100%;max-height:100%;display:block;min-width:70px" alt="赞助 Furion"><span style="position:absolute;top:25px;left:0;right:0;font-size:12px;z-index:1;text-align:center;color:white;font-weight:bold;background-color:rgba(0, 0, 0, 0.4)">查看大图</span></div><div style="display:flex;flex:1;flex-direction:column;justify-content:space-between;padding:5px 0 5px 0"><h3 style="font-weight:500;font-size:17px;margin:4px 0 0 0;text-align:left;background:linear-gradient(to right, red, blue);background-clip:text;-webkit-background-clip:text;color:transparent;white-space:nowrap;cursor:pointer">谢谢您对 Furion 的认可!</h3><div style="display:flex;justify-content:space-between;white-space:nowrap;margin-top:10px"><span style="font-size:12px;color:#ccc">微信ibaiqian</span><a href="https://gitee.com/dotnetchina/Furion" style="margin-right:6px" target="_blank"><img src="https://gitee.com/dotnetchina/Furion/badge/star.svg?theme=white" alt="star"></a></div></div></div><span class="theme-last-updated">Last updated<!-- --> on <b><time datetime="2023-10-25T11:35:12.000Z">Oct 25, 2023</time></b> by <b>百小僧</b></span></div></div><a style="display:flex;width:100%;box-sizing:border-box;align-items:center;justify-content:space-between;padding-left:5px" title="⭐️ VIP 499 <EFBFBD><EFBFBD>
</body>
</html>