# 区域设置和 UI 语言

**URL:** https://meta.discourse.org/t/locale-and-ui-language/167444
**Category:** Translations
**Created:** [2020年十月17日 14:55 UTC](https://meta.discourse.org/t/locale-and-ui-language/167444 "2020-10-17T14:55:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![SafaAlfulaij](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/safaalfulaij/32/120867_2.png) [@SafaAlfulaij](https://meta.discourse.org/u/SafaAlfulaij)
#### Post date: [2020年十月17日 14:55 UTC](https://meta.discourse.org/t/locale-and-ui-language/167444/1 "2020-10-17T14:55:42Z")

</div>

继续讨论 [Business Week Day](https://meta.discourse.org/t/business-week-day/167337/7)：

正如我在链接的帖子中提到的，区域设置（Locale）并不完全等同于界面语言。

我以 KDE（Linux 和 Qt）为例：

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/7/37f12c584a71dabe38e2add37005cffd49e7a600.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/3/c3bc499a9599a2976ed48ba8ec8bb7760db4aee5.png)

如图所示，在第一张截图中，用户可以选择界面语言。这决定了界面以及屏幕上显示的所有内容的语言，除了第二张截图中的内容。  
第二张截图允许定义用户的区域设置，并覆盖数字、时间、货币、单位和排序方式。  
这很重要，因为许多人使用他们偏好的语言操作系统，但居住在另一个国家，那里的区域设置偏好可能不同。

我以我所在的阿拉伯地区为例：

- 所有国家的主要语言都是阿拉伯语。
- [马什里克](https://en.wikipedia.org/wiki/Mashriq) 国家偏好使用 [东阿拉伯数字](https://en.wikipedia.org/wiki/Eastern_Arabic_numerals)（٠١٢٣٤٥٦٧٨٩），而 [马格里布](https://en.wikipedia.org/wiki/Maghreb) 国家偏好使用 [阿拉伯数字](https://en.wikipedia.org/wiki/Arabic_numerals)（0123456789）。
- 埃及、苏丹和海湾国家偏好使用拉丁月份名称的阿拉伯语转写：[https://en.wikipedia.org/wiki/Arabic\_names\_of\_Gregorian\_months#Egypt,\_Sudan,\_Arab\_Countries\_in\_the\_Arabic\_Gulf，而黎凡特和美索不达米亚地区偏好使用亚述月份名称：https://en.wikipedia.org/wiki/Arabic\_names\_of\_Gregorian\_months#Levant\_and\_Mesopotamia，马格里布国家则偏好使用法语月份名称的转写：https://en.wikipedia.org/wiki/Arabic\_names\_of\_Gregorian\_months#Algeria\_and\_Tunisia。](https://en.wikipedia.org/wiki/Arabic_names_of_Gregorian_months#Egypt,_Sudan,_Arab_Countries_in_the_Arabic_Gulf%EF%BC%8C%E8%80%8C%E9%BB%8E%E5%87%A1%E7%89%B9%E5%92%8C%E7%BE%8E%E7%B4%A2%E4%B8%8D%E8%BE%BE%E7%B1%B3%E4%BA%9A%E5%9C%B0%E5%8C%BA%E5%81%8F%E5%A5%BD%E4%BD%BF%E7%94%A8%E4%BA%9A%E8%BF%B0%E6%9C%88%E4%BB%BD%E5%90%8D%E7%A7%B0%EF%BC%9Ahttps://en.wikipedia.org/wiki/Arabic_names_of_Gregorian_months#Levant_and_Mesopotamia%EF%BC%8C%E9%A9%AC%E6%A0%BC%E9%87%8C%E5%B8%83%E5%9B%BD%E5%AE%B6%E5%88%99%E5%81%8F%E5%A5%BD%E4%BD%BF%E7%94%A8%E6%B3%95%E8%AF%AD%E6%9C%88%E4%BB%BD%E5%90%8D%E7%A7%B0%E7%9A%84%E8%BD%AC%E5%86%99%EF%BC%9Ahttps://en.wikipedia.org/wiki/Arabic_names_of_Gregorian_months#Algeria_and_Tunisia%E3%80%82)

因此，日期会受到这些差异的影响：

- 所有国家都从右向左书写。
- 马什里克国家：⁨١٢ يناير ٢٠٢٠⁩ = 2020 年 1 月 12 日（从右向左阅读）
- 马格里布国家：⁨12 جانفي 2020⁩ = 2020 年 1 月 12 日（从右向左阅读）
- 简单来说：无论是东阿拉伯数字还是西/阿拉伯数字，书写方向都是从右向左，这使得决定数字格式变得更加困难。

甚至 [千位分隔符](https://commons.wikimedia.org/wiki/File:Thousands_separators.gif) 也不同：

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/5/45db023b72bd27d4d1c51a5f590e28bd23dbc358.png)  
（东阿拉伯数字还有另一种分隔符：١٠٬٠٠٠٫٠٠： ![image](https://global.discourse-cdn.com/meta/original/3X/f/a/fae90fc86dca5eca5dfe49d8236adb1d4fe8ddba.png)）

#### 这对 Discourse 的影响：

- 日期和时间格式、数字、工作周的起始日。

#### 不受影响的内容：

- 相对日期。

#### 理想的解决方案：

- 提取并内置 Unicode 格式，允许用户选择任何他们喜欢的区域设置。这需要仔细考虑，因为它可能会与 Moment.JS 发生冲突。
- 为翻译人员提供所有必要的手段和方法，以便在软件中指定何处显示何种格式。

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [2020年十二月4日 17:09 UTC](https://meta.discourse.org/t/locale-and-ui-language/167444/3 "2020-12-04T17:09:39Z")

</div>

目前暂无计划将现有的语言环境系统拆分为语言环境和用户界面语言，但我同意，这样做会是一个很好的改进。

不过，我认为现有系统已经可用于创建特定区域的语言环境。我们已有 [client.en\_US.yml](https://github.com/discourse/discourse/blob/master/config/locales/client.en_US.yml) 和 [server.en\_US.yml](https://github.com/discourse/discourse/blob/master/config/locales/server.en_US.yml)，它们用于覆盖日期/时间格式、数字格式等。

我相信对阿拉伯语也可以实现类似的做法，甚至可以通过插件来完成。

> [@Add a new locale from plugin](https://meta.discourse.org/t/add-a-new-locale-from-plugin/78962):
>
> Usually the best way to add a new language to Discourse is by creating a pull request as described in “[How to add a new language](https://meta.discourse.org/t/how-to-add-a-new-language/14970)”. The following guide is for you, if you want to use a language that can’t be added to core right now. Adding a locale that extends an existing locale Let’s say you want to add a Spanish locale for Mexico (es\_MX). Discourse already ships a Spanish locale (es), so this is quite easy. Your plugin’s directory structure should look like this: custom-locales ├── assets…
