macos 在 Mac OSX 中添加语言环境
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9991603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add a locale in Mac OSX
提问by Natxet
I'm using gettext in a MAMP environment. I have locale files for es_ES
, ca_ES
, en_US
and gl_ES
. No problem with the first three, but for the forth, I get an error when trying to bind the locale translations files to the gl_ES
language (galician in Spain). This is not a problem with apache or PHP because the others work (and in my CentOS server I have the gl_ES package and works fine)
我在 MAMP 环境中使用 gettext。我有语言文件es_ES
,ca_ES
,en_US
和gl_ES
。前三个没问题,但对于第四个,我在尝试将语言环境翻译文件绑定到gl_ES
语言(西班牙的加利西亚语)时出错。这不是 apache 或 PHP 的问题,因为其他的都可以工作(在我的 CentOS 服务器中,我有 gl_ES 包并且工作正常)
So I realize my Mac OS X version 10.6.8 came without Galician support. That's strange because it has support to Spanish, Catalan and Euskera, the other three official languages in Spain. Some terminal to show you:
所以我意识到我的Mac OS X 版本 10.6.8 没有加利西亚语支持。这很奇怪,因为它支持西班牙语、加泰罗尼亚语和 Euskera,这是西班牙的其他三种官方语言。一些终端向您展示:
$ locale -a | grep _ES
ca_ES
ca_ES.ISO8859-1
ca_ES.ISO8859-15
ca_ES.UTF-8
es_ES
es_ES.ISO8859-1
es_ES.ISO8859-15
es_ES.UTF-8
eu_ES
eu_ES.ISO8859-1
eu_ES.ISO8859-15
eu_ES.UTF-8
$ ll /usr/share/locale/ | grep _ES
drwxr-xr-x 8 root wheel 272B 3 dic 2010 ca_ES/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 ca_ES.ISO8859-1/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 ca_ES.ISO8859-15/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 ca_ES.UTF-8/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 es_ES/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 es_ES.ISO8859-1/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 es_ES.ISO8859-15/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 es_ES.UTF-8/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 eu_ES/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 eu_ES.ISO8859-1/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 eu_ES.ISO8859-15/
drwxr-xr-x 8 root wheel 272B 3 dic 2010 eu_ES.UTF-8/
Regression
回归
- I tried the installation disks (adding language packs) but no success: they're just translations of the operating system.
- I found this similar question, but doesn't have as much information and no good answers.
- I came to localedefas an option, but it seems to be just for creating the
.UTF-8
or similar when you already have the base file.
- 我尝试了安装盘(添加语言包)但没有成功:它们只是操作系统的翻译。
- 我发现了这个类似的问题,但没有那么多信息,也没有好的答案。
- 我来到localedef作为一个选项,但它似乎只是为了
.UTF-8
在您已经拥有基本文件时创建或类似的。
I have no clue on how to add galician support (or any other) to Mac OS X.
我不知道如何向 Mac OS X 添加加利西亚语支持(或任何其他支持)。
How to add a new locale in Mac OS X?
如何在 Mac OS X 中添加新的语言环境?
采纳答案by alo
This should do the trick:
这应该可以解决问题:
cd /usr/share/locale
sudo cp -R es_ES gl_ES
Then open a new terminal session and list the locales again. Galician should be there :)
然后打开一个新的终端会话并再次列出语言环境。加利西亚人应该在那里:)
回答by AndyPerlitch
After literally hours of searching, pouring over perl code, and head-scratching, I have concluded at Apple is epically failing in the locale-creation-and-definition department. Here's the deal: OSX gives you a (*ehem* ...shoddy) utility script written in perl located at /usr/bin/localedef
, which is SUPPOSED to create a new locale. The manpage says that usage should be something like this (run inside of usr/share/locale
):
经过数小时的搜索、倾注 perl 代码和令人头疼的问题,我得出的结论是,Apple 在语言环境创建和定义部门严重失败。交易如下:OSX 为您提供了一个用 perl 编写的 (*ehem* ...shoddy) 实用程序脚本,位于/usr/bin/localedef
,它应该用于创建新的语言环境。手册页说用法应该是这样的(在 内运行usr/share/locale
):
localedef -i base_file -f UTF-8 new_locale_name
As stated by the OP, this command is just for copying a current locale. Well, I couldn't even get THAT to work! I don't know perl, but I found at least one careless code error in /usr/bin/localedef
(line 512 references a sub called set_escape_char
which should really be set_escape
) and on top of that I couldn't get localedef
to work at all so that's out. As stated by @alombarte you can just copy a current locale directory with cp -R src_locale trg_locale
but he forgot to mention that there are differences between the source and target locales you need to actually manually change the text files within the new locale dir.
正如 OP 所述,此命令仅用于复制当前语言环境。好吧,我什至无法让它发挥作用!我不知道perl的,但我发现至少有一个不小心的代码错误/usr/bin/localedef
(线512只引用了一个名为子set_escape_char
应该真的set_escape
),不仅如此,我不能让顶localedef
在所有所以这是出来工作。正如@alombarte 所述,您可以只复制当前的语言环境目录,cp -R src_locale trg_locale
但他忘记提及源语言环境和目标语言环境之间存在差异,您需要实际手动更改新语言环境目录中的文本文件。
For example, I wanted to create the locale es_NI.UTF-8
(Nicaragua), with the correct currency code and monetary info, so here's what i did:
例如,我想es_NI.UTF-8
使用正确的货币代码和货币信息创建语言环境(尼加拉瓜),所以我这样做了:
cd /usr/share/locale
sudo cp -R es_MX.UTF-8 es_NI.UTF-8
sudo vim es_NI.UTF-8/LC_MONETARY
# changed MXN to NIO, $ to C$, etc...
# saved LC_MONETARY
You may need to change other pertinent values depending on your use of the new locale. Hereis the best collection of locale info I have been able to find online. If I were a better programmer I'd make a script that takes that websites "glibc" exported format and reformats it to work with the localedef
command in Mac OSX.
根据您对新语言环境的使用,您可能需要更改其他相关值。这是我能够在网上找到的最好的语言环境信息集合。如果我是一个更好的程序员,我会制作一个脚本,该脚本采用该网站的“glibc”导出格式并将其重新格式化以localedef
在 Mac OSX 中使用该命令。
P.S. apologies to @alombarte for the initial downvote... even though his response does not answer the true question, I didn't realize that it would be so incredibly difficult to do it any other way.
PS 就最初的否决向@alombarte 道歉......即使他的回答没有回答真正的问题,我也没有意识到以其他方式做到这一点会非常困难。
回答by Adrian M.
Looking into this found that, as of Mac OS X 10.10.3, collation is still broken for Spanish and most European languages. Collation definitions for these locales are linked to an ASCII definition. This ends up breaking things such as ORDER BY
clauses on PostgreSQL.
对此进行调查后发现,从 Mac OS X 10.10.3 开始,西班牙语和大多数欧洲语言的排序规则仍然存在问题。这些语言环境的归类定义链接到 ASCII 定义。这最终会破坏诸如ORDER BY
PostgreSQL 上的子句之类的东西。