久久久久久久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?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 怡红院成人在线视频 | 天天影视色综合 | 天天天天操| 国产欧美日韩精品一区 | 欧洲尺码日本国产精品 | 中文字幕国产视频 | 免费午夜电影 | 亚洲综合一区二区三区 | 国产精品性做久久久久久 | 国内精品久久久久久久影视简单 | 亚州毛片 | 国产精品高清在线 | 国产精品久久久久久久白浊 | 国产69精品久久久久777 | 又黄又爽的网站 | 国产精品久久久久久久久久免费看 | 91久久网站| 欧美日韩成人网 | 九九综合 | 天天拍天天操 | 一级高清视频 | 成人日韩 | 激情五月婷婷 | 亚洲欧美久久 | 超级乱淫av片免费播放 | 国产精品美女一区二区三区 | 午夜ww| 神马影院一区二区三区 | 在线免费观看日本 | 91视频进入| 一级免费毛片 | 久99久视频 | 天堂视频中文在线 | 亚洲欧美在线免费观看 | 亚洲精品亚洲人成人网 | 91麻豆精品国产91久久久久久久久 | 国产精品一卡二卡三卡 | 欧美日韩国产一区二区三区 | 日韩成人精品 | 日韩电影一区二区三区 | 欧美色偷拍 |