Add a locale in Mac OSX

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):

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.

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:

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. Here is 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.

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.


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 :)

Tags:

Macos

Locale