-
setLocale(locale) - 自從:ArcGIS 適用於 JavaScript 4.16 的 API
設置 API 使用的語言環境。這是設置 API 語言環境的首選方法。
當區域設置更改時,將調用
onLocaleChange()的已注冊回調。JavaScript API 小部件會在運行時更改語言環境時做出反應。請注意,這被認為是實驗性的。
JavaScript API 提供相同級別的支持數字, 和日期格式化為 Web 瀏覽器的 Intl API。對於小部件的翻譯,可以使用以下一組語言環境:
ar,bg,bs,ca,cs,da,de,el,en,es,et,fi,fr,he,hr,hu,id,it,ja,ko,lt,lv,nb,nl,pl,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-CN,zh-HK, 和zh-TW.如果翻譯消息不適用於當前語言環境,則根據 getLocale() 中說明的順序確定語言;否則默認為英文消息。
然後可以將語言環境設置為
en-US或en-GB。小部件使用en消息進行翻譯,而日期和數字使用其相應的格式。參數:
類型 說明 locale String新的 Unicode 區域設置標識符字符串,類似於 Intl API。如果這是
undefined,則區域設置將重置為其getLocale()中說明的默認值。例子:
// Sets the locale to French intl.setLocale("fr"); // Sets the locale to UK English. // Dates are formatted in day/month/year order. intl.setLocale("en-GB"); // Sets the locale to US English. // Dates are formatted in month/day/year order. intl.setLocale("en-US");
基本信息
以下是所在類或對象的基本信息。
AMD:
require(["esri/intl"], (intl) => { /* code goes here */ });
ESM:
import * as intl from "@arcgis/core/intl";
對象:
esri/intl
自從:用於 JavaScript 4.12 的 ArcGIS API
用法說明
intl.setLocale函數(或屬性)的定義如下:
相關用法
- JavaScript ArcGIS intl.substitute用法及代碼示例
- JavaScript ArcGIS intl.convertDateFormatToIntlOptions用法及代碼示例
- JavaScript ArcGIS intl.normalizeMessageBundleLocale用法及代碼示例
- JavaScript ArcGIS intl.fetchMessageBundle用法及代碼示例
- JavaScript ArcGIS intl.SubstituteOptions用法及代碼示例
- JavaScript ArcGIS intl.SubstituteDateTimeFormatOptions用法及代碼示例
- JavaScript ArcGIS intl.SubstituteNumberFormatOptions用法及代碼示例
- JavaScript ArcGIS intl.formatNumber用法及代碼示例
- JavaScript ArcGIS intl.convertNumberFormatToIntlOptions用法及代碼示例
- JavaScript ArcGIS intl.createJSONLoader用法及代碼示例
- JavaScript ArcGIS intl.registerMessageBundleLoader用法及代碼示例
- JavaScript ArcGIS intl.MessageBundleLoader用法及代碼示例
- JavaScript ArcGIS intl.formatDate用法及代碼示例
- JavaScript ArcGIS intl.onLocaleChange用法及代碼示例
- JavaScript includes()用法及代碼示例
- JavaScript isFinite()用法及代碼示例
- JavaScript isNaN()用法及代碼示例
- JavaScript ArcGIS imageService.getSamples用法及代碼示例
- JavaScript ArcGIS SceneView double-click事件用法及代碼示例
- JavaScript ArcGIS geometryEngineAsync.overlaps用法及代碼示例
- JavaScript ArcGIS Expand.when用法及代碼示例
- JavaScript ArcGIS Sublayer.JoinTableDataSource用法及代碼示例
- JavaScript ArcGIS FillSymbol3DLayer.outline用法及代碼示例
- JavaScript ArcGIS Ground.loadAll用法及代碼示例
- JavaScript Object valueOf()用法及代碼示例
注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 intl.setLocale。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
