Load a locale from /usr/local/share/locale in OS X

Solution 1:

This worked for me (macos 10.14):

sudo localedef -i /usr/share/locale/en_US.UTF-8 /usr/local/share/locale/en_US.utf8
sudo cp /usr/share/locale/en_US.UTF-8/LC_COLLATE /usr/local/share/locale/en_US.utf8/

Solution 2:

My solution now is to simply replace the string "en_US.utf8" with "en_US.UTF-8" in the dump file. Since that file is compressed in my case (hence binary format), it was necessary to keep the same number of characters in the original line. So I remove a couple of white-spaces, transforming

(...) LC_COLLATE = 'en_US.utf8' LC_CTYPE = 'en_US.utf8' (...)

into

(...) LC_COLLATE= 'en_US.UTF-8' LC_CTYPE= 'en_US.UTF-8' (...)

A perl command to do that in my importing script was

perl -pi -e "s/LC_COLLATE = 'en_US.utf8'/LC_COLLATE= 'en_US.UTF-8'/g" myDumpFilePath
perl -pi -e "s/LC_CTYPE = 'en_US.utf8'/LC_CTYPE= 'en_US.UTF-8'/g" myDumpFilePath