3

I have only two locales installed $ locale -a C POSIX

I want to use utf-8 character encoding and hence want to install en_US.UTF-8 For ubuntu I found locale_gen which does the job. Is this utility, or any similar utility present for FreeBSD? If yes, could you please tell me its location? Thanks

Apoorv
  • 2,525
  • 2
  • 14
  • 18

1 Answers1

5

I followed this guide to install UTF-8 locale. This is how it looks like in my terminal once that's set up:

g@crayon2:~ % locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_ALL=

Copying from there this is what I changed:

/etc/login.conf

--- login.conf.default  2012-01-02 17:08:05.804291477 -0500
+++ login.conf  2012-01-02 17:08:16.996213774 -0500
@@ -44,7 +44,9 @@
    \:pseudoterminals=unlimited:\
    \:priority=0:\
    \:ignoretime@:\
-   \:umask=022:
+   \:umask=022:\
+   \:charset=UTF-8:\
+   \:lang=en_US.UTF-8:

Rebuild the login database with cap_mkdb /etc/login.conf after making changes.

/etc/profile

LANG=en_US.UTF-8;   export LANG
CHARSET=UTF-8;  export CHARSET
GDM_LANG=en_US.UTF-8;   export GDM_LANG

Of course I used en_GB rather than en_US as you can tell.

Edit:

The locale files are located in /usr/share/locale:

g@crayon2:/usr/share/locale % ls -l
total 1423
drwxr-xr-x  2 root  wheel  3 11 Nov  2014 UTF-8
drwxr-xr-x  2 root  wheel  8 11 Nov  2014 af_ZA.ISO8859-1
drwxr-xr-x  2 root  wheel  8 11 Nov  2014 af_ZA.ISO8859-15
drwxr-xr-x  2 root  wheel  8 11 Nov  2014 af_ZA.UTF-8
drwxr-xr-x  2 root  wheel  8 11 Nov  2014 am_ET.UTF-8
drwxr-xr-x  2 root  wheel  8 11 Nov  2014 be_BY.CP1131
drwxr-xr-x  2 root  wheel  8 11 Nov  2014 be_BY.CP1251
drwxr-xr-x  2 root  wheel  8 11 Nov  2014 be_BY.ISO8859-5
(..)

These files are not part of any port, they are part of the base.txz archive available from the FreeBSD ftp server:

g@crayon2:~/Downloads % tar -tzf base.txz | grep "usr/share/locale"
./usr/share/locale/
./usr/share/locale/lt_LT.ISO8859-4/
./usr/share/locale/en_GB.ISO8859-15/
./usr/share/locale/kk_KZ.PT154/
./usr/share/locale/it_IT.ISO8859-15/
./usr/share/locale/hy_AM.UTF-8/
./usr/share/locale/en_IE.UTF-8/
./usr/share/locale/zh_HK.UTF-8/
./usr/share/locale/en_AU.ISO8859-1/
./usr/share/locale/zh_CN.eucCN/
./usr/share/locale/fr_BE.ISO8859-15/
./usr/share/locale/en_AU.UTF-8/
(...)
Greg
  • 8,230
  • 5
  • 38
  • 53
  • Thanks Amirax, but this is only going to work if you have "en_US.UTF-8" installed on your machine. You can find that out using `locale -a`. On my freeBSD machine, I just have 2 of them installed, and hence exporting any env variable with anything other than those 2 (C & POSIX) isn't working. – Apoorv Mar 03 '16 at 18:18
  • Oh sorry, I misunderstood your question then. I don't think they are part of any port. They are included in the base system. See my edit in the response. – Greg Mar 03 '16 at 18:59
  • Thanks, I solved it by copying the locale related files from a different installation to the /usr/share/locale directory, exported the LC_ALL env variable and it worked. – Apoorv Mar 11 '16 at 19:29
  • You could also copy it directly from the `base.txz` archive, but of course copying from another system ought to be quicker. I am glad it worked. – Greg Mar 11 '16 at 20:56