久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Web 應用程序中的數字本地化

Numbers localization in Web applications(Web 應用程序中的數字本地化)
本文介紹了Web 應用程序中的數字本地化的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何在不更改字符代碼的情況下設置阿拉伯數字的變體?

How can I set the variant of Arabic numeral without changing character codes?

Eastern Arabic      ?   ?   ?   ?   ?   ?   ?   ?   ?   ?
Persian variant     ?   ?   ?   ?   ?   ?   ?   ?   ?   ?
Western Arabic      0   1   2   3   4   5   6   7   8   9 
(And other numeral systems)

這是一個示例代碼:

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
</head>
<body>

<div lang="fa">0123456789</div>
<div lang="ar">0123456789</div>
<div lang="en">0123456789</div>

</body>
</html>

如何僅使用客戶端技術(HTMLCSSJS)來做到這一點?
該解決方案應該對頁面的 SEO 分數沒有負面影響.

How can I do this using only client-side technologies (HTML,CSS,JS)?
The solution should have no negative impact on page's SEO score.

請注意,在 Windows 文本框(例如 Run)中,數字會根據周圍文本的語言正確顯示.

Note that in Windows text boxes (e.g. Run) numbers are displayed correctly according to language of surrounding text.

另請參閱:桌面應用程序中的數字本地化

注意:使用這個 PHP 包 https://github.com/salarmehr/cosmopolitan

Note: Localisation of numbers are super easy on backend using this PHP package https://github.com/salarmehr/cosmopolitan

推薦答案

一個新的(迄今為止)簡單的 JS 解決方案是使用 Intl.NumberFormat.它支持數字本地化、格式變化以及本地貨幣(有關更多示例,請參閱文檔).

A new (to date) and simple JS solution would be to use Intl.NumberFormat. It supports numeral localization, formatting variations as well as local currencies (see documentation for more examples).

使用一個與 MDN 自己的非常相似的示例:

To use an example very similar to MDN's own:

const val = 1234567809;
console.log('Eastern Arabic (Arabic-Egyptian)', new Intl.NumberFormat('ar-EG').format(val));
console.log('Persian variant (Farsi)',new Intl.NumberFormat('fa').format(val));
console.log('English (US)',new Intl.NumberFormat('en-US').format(val));

Intl.NumberFormat 似乎也支持字符串數值,并在它不是本地語言中的數字時進行指示.

Intl.NumberFormat also seems to support string numeric values as well as indicates when it's not a number in the local language.

const val1 = '456';
const val2 = 'Numeric + string example, 123';
console.log('Eastern Arabic', new Intl.NumberFormat('ar-EG').format(val1));
console.log('Eastern Arabic', new Intl.NumberFormat('ar-EG').format(val2));
console.log('Persian variant',new Intl.NumberFormat('fa').format(val1));
console.log('Persian variant',new Intl.NumberFormat('fa').format(val2));
console.log('English',new Intl.NumberFormat('en-US').format(val1));
console.log('English', new Intl.NumberFormat('en-US').format(val2));

對于語言環境標識符(傳遞給 NumberFormat 構造函數的字符串,指示語言環境),我嘗試了上面的值,它們看起來很好.我嘗試查找所有可能值的列表,并通過 MDN 遇到 本文檔和此列表可能會有所幫助.

For the locale identifier (string passed to NumberFormat constructor indicating locale), I experimented with the values above and they seemed fine. I tried finding a list for all possible values, and through MDN came across this documentation and this list that could be helpful.

我不熟悉 SEO,因此不確定這如何回答這部分問題.

I'm not familiar with SEO, and am thus unsure how this answers that part of the question.

這篇關于Web 應用程序中的數字本地化的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 欧美久久国产 | 久久久网| 丝袜天堂 | 超碰综合 | 亚洲视频中文 | 亚洲成人精品在线观看 | 中文字幕1区2区3区 亚洲国产成人精品女人久久久 | 亚洲精品二区 | 影音先锋成人资源 | 中文字幕在线一区 | 亚洲综合字幕 | 成人h视频在线观看 | 久久久精 | 成av在线 | 男人天堂久久久 | 一二三四av| 精品一区二区不卡 | 91久久久久久久久久久久久 | 国产精品精品视频一区二区三区 | 日韩av在线免费 | 日韩激情一区 | 五月婷婷丁香 | 中文字幕免费在线观看 | 91社影院在线观看 | 色视频一区二区 | 综合久 | 国产高清精品网站 | 久久久片 | 亚洲一二三在线 | 精品一区二区三区中文字幕 | 97视频在线免费 | 国产女人与拘做受免费视频 | 欧美黄视频 | 一级黄色毛片免费 | 成人免费视频网站在线看 | 福利社午夜影院 | 午夜成人免费视频 | 日本大片在线播放 | 久久天天躁狠狠躁夜夜躁2014 | 精品一二区 | av色噜噜 |