Полезная информация

Chapter 13. Localization

Table of Contents
13.1. Russian Language (KOI8-R encoding)
13.2. German Language (ISO 8859-1)

13.1. Russian Language (KOI8-R encoding)

Contributed by Andrey A. Chernov 1 May 1997.

See more info about KOI8-R encoding at KOI8-R References (Russian Net Character Set).

13.1.1. Console Setup

  1. Add following line to your kernel configuration file:

        options         "SC_MOUSE_CHAR=0x03"
    
    to move character codes used for mouse cursor off KOI8-R pseudographics range.
  2. Russian console entry in /etc/rc.conf should looks like:

        keymap=ru.koi8-r
        keychange="61 ^[[K"
        scrnmap=koi8-r2cp866
        font8x16=cp866b-8x16
        font8x14=cp866-8x14
        font8x8=cp866-8x8
    

    Note: ^[ means that real ESC character must be entered into /etc/rc.conf, not just ^[ string.

    This tuning means KOI8-R keyboard with Alternative screen font mapped to KOI8-R encoding to preserve pseudographics, Gray Delete key remapped to match Russian termcap(5) entry for FreeBSD console.

    RUS/LAT switch will be CapsLock. Old CapsLock function still available via Shift+CapsLock. CapsLock LED will indicate RUS mode, not CapsLock mode.

  3. For each ttyv? entry in /etc/ttys change terminal type from cons25 to cons25r, i.e. each entry should looks like:

        ttyv0  "/usr/libexec/getty Pc"        cons25r  on  secure
    

13.1.2. Locale Setup

There is two environment variables for locale setup:

  • LANG for POSIX setlocale(3) family functions;

  • MM_CHARSET for applications MIME character set.

The best way is using /etc/login.conf russian user's login class in passwd(5) entry login class position. See login.conf(5) for details.

13.1.2.1. Login Class Method

First of all check your /etc/login.conf have russian login class, this entry may looks like:

    russian:Russian Users Accounts:\
            :charset=KOI8-R:\
            :lang=ru_RU.KOI8-R:\
            :tc=default:

13.1.2.1.1. How to do it with vipw(8)

If you use vipw(8) for adding new users, /etc/master.passwd entry should looks like:

    user:password:1111:11:russian:0:0:User Name:/home/user:/bin/csh

13.1.2.1.2. How to do it with adduser(8)

If you use adduser(8) for adding new users:

  • Set

        defaultclass = russian
    
    in /etc/adduser.conf (you must enter default class for all non-Russian users in this case);
  • Alternative variant will be answering russian each time when you see

        Enter login class: default []:
    
    prompt from adduser(8);
  • Another variant: call

        # adduser -class russian
    
    for each Russian user you want to add.

13.1.2.1.3. How to do it with pw(8)

If you use pw(8) for adding new users, call it in this form:

    # pw useradd user_name -L russian

13.1.2.2. Shell Startup Files Method

If you don't want to use login class method for some reasons, just set this two environment variables in the following shell startup files:

  • /etc/profile:

        LANG=ru_RU.KOI8-R; export LANG
        MM_CHARSET=KOI8-R; export MM_CHARSET
    
  • /etc/csh.login:

        setenv LANG ru_RU.KOI8-R
        setenv MM_CHARSET KOI8-R
    

Alternatively you can add this instructions to

  • /usr/share/skel/dot.profile:

    (similar to /etc/profile above);

  • /usr/share/skel/dot.login:

    (similar to /etc/csh.login above).

13.1.3. Printer Setup

Since most printers with Russian characters comes with hardware code page CP866, special output filter needed for KOI8-R -> CP866 conversion. Such filter installed by default as /usr/libexec/lpr/ru/koi2alt. So, Russian printer /etc/printcap entry should looks like:

    lp|Russian local line printer:\
            :sh:of=/usr/libexec/lpr/ru/koi2alt:\
            :lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:

See printcap(5) for detailed description.

13.1.4. MSDOS FS and Russian file names

Look at following example fstab(5) entry to enable support for Russian file names in MSDOS FS:

    /dev/sd0s1        /dos/c    msdos   rw,-W=koi2dos,-L=ru_RU.KOI8-R 0 0

See mount.msdos(8) for detailed description of -W and -L options.

13.1.5. X Window Setup

Step by step instructions:

  1. Do non-X locale setup first as described.

    Note: Russian KOI8-R locale may not work with old XFree86 releases (lower than 3.3). XFree86 port from /usr/ports/x11/XFree86 already have most recent XFree86 version, so it will work, if you install XFree86 from this port. XFree86 version shipped with the latest FreeBSD distribution should work too (check XFree86 version number not less than 3.3 first).

  2. Go to /usr/ports/russian/X.language directory and say

        # make all install
    
    there. This port install latest version of KOI8-R fonts. XFree86 3.3 already have some KOI8-R fonts, but this ones scaled better.

    Check find "Files" section in your /etc/XF86Config, following lines must be before any other FontPath entries:

        FontPath   "/usr/X11R6/lib/X11/fonts/cyrillic/misc"
        FontPath   "/usr/X11R6/lib/X11/fonts/cyrillic/75dpi"
        FontPath   "/usr/X11R6/lib/X11/fonts/cyrillic/100dpi"
    

    If you use high resolution video mode, swap 75 dpi and 100 dpi lines.

  3. To activate Russian keyboard add

        XkbKeymap   "xfree86(ru)"
    
    line into "Keyboard" section in your /etc/XF86Config, also make sure that XkbDisable is turned off (commented out) there.

    RUS/LAT switch will be CapsLock. Old CapsLock function still available via Shift+CapsLock (in LAT mode only).

    Note: Russian XKB keyboard may not work with old XFree86 versions, see locale note for more info. Russian XKB keyboard may not work with non-localized applications too, minimally localized application should call XtSetLanguageProc (NULL, NULL, NULL); function early in the program.