Polish localization issues.

Help me understand how localization works in FreeBSD.
I'm trying to change it to Polish, but I can't.
Let's leave Xorg for now, just the console.

What do I want to achieve?
- ee editor in Polish, Polish messages and Polish characters in messages
- pl keyboard layout (programmers)
- the ability to write in Polish in the ee editor, Polish characters in the UTF-8 standard I don't need anything else to be happy.

Unfortunately, the manual did not help.
There is no reference where to find a list of languages and descriptions of how to do it.
# locale -a
it shows pl_PL.UTF-8 but what does it mean? FreeBSD supports something, but what (fonts on screen, fonts on printer, char coding UTF-8 when typing ) ?

People write all sorts of things on forums.
Some say that it is enough to make entries in /etc/profile
export LANG=pl_PL.UTF-8
export LANGUAGE=pl_PL.UTF-8
export LC_ALL=pl_PL.UTF-8
well not enough I tested on Vbox FBSD13.1_bootonly.ISO

Others say just type into /etc/login.conf
:charset=pl_PL.UTF-8:\
:lang=pl_PL.UTF-8:
# cap_mkdb /etc/login.conf
That's not enough either

The ISO8859-2 description is more accurate and I was able to display the ee editor in Polish
Formerly, the manual said that for ISO8859-2 you need to change w /etc/ttys to consl2 and now it says nothing about it.

Similarly with /etc/rc.conf fonts
font8x16=font_name
font8x14=font_name
font8x8=font_name
https://people.freebsd.org/~blackend/en_US.ISO8859-1/books/handbook/using-localization.html

I'm frustrated, most of all, that I can't figure out what I don't know and where to get the information.
For comparison, I checked how it is in GhostBSD.
There I can write Polish characters in the console in Xorg, but the ee editor is in English. The created TXT file in the editor in Xorg is displayed correctly in the console.

/etc/login.conf
:charset=UTF-8:\
:lang=en_PL.UTF-8:

After disabling lightxdm and restarting the computer there are no Polish characters in the console.
Displaying ????ó?? So something is missing, but what?
 
- the ability to write in Polish in the ee editor, Polish characters in the UTF-8 standard
UTF-8 support is very limited in ee. In my case it can display existing accented characters in a file, but fails at displaying the ones I type. For a better localisation support, consider using editors/nano instead, which is translated in various languages and works fine with UTF-8. I personally enjoy editors/micro, but it doesn't have localised messages.

- pl keyboard layout (programmers)
Available keyboard layouts on the console are those located in /usr/share/vt/keymaps/ and you can set it in /etc/rc.conf (for example keymap="pl.kbd"). There are two Polish layouts available (pl.kbd and pl.dvorak.kbd) but I don't think that's the one (programmer's) you want. I also notice centraleuropean.kbd and centraleuropean.qwerty.kbd, maybe one of them is what you're looking for? If none of the available layouts is to your liking, you may prefer using a terminal inside a Xorg session, where you'll have access to more layouts.
 
bsduck - Thank's for your quick answer. I assumed the ee editor is best related to FreeBSD. So I was wrong.
- polish programers keyboard layout is most common used, propably called diffrent in FreeBSD
I'm assuming it's pl.kbd
SirDice - please don't hold a grudge against me. I posted in the thread about FreBSD localization issues. The problem seemed similar to the one I had. I didn't want to start my adventure with the Freebsd forum by starting a new thread. You might consider that I didn't search for a solution before starting the discussion.
 
ee editor in Polish
Looks like it's only translated from the pl_PL.ISO8859-2 locale, no ee.cat in /usr/share/nls/pl_PL.UTF-8.
export LANG=pl_PL.UTF-8
export LANGUAGE=pl_PL.UTF-8
export LC_ALL=pl_PL.UTF-8
Don't do this, especially the LC_ALL variable, it's designed to be an override for system-wide settings; I don't know anything that looks at the LANGUAGE variable; LANG is ok, but you already have it set via /etc/login.conf.
 
Thank's for advise.
In that catalogs /usr/share/nls/<name_of_localization> are some files. Often is tcsh.cat it means a name of program ?
ee.cat means ee editor ?
So that would mean that a separate translation is written for each program. What if the program version changes? Need to rewrite everything?
 
tcsh(1) is one of the two shells included in the base system, along with sh(1).

So that would mean that a separate translation is written for each program.
Of course, that's how it's usually done with computer programs. That's why you often have programs displaying messages in English although your environment is properly configured to use another language (it means these programs don't have localised messages, or do but not for the requested language), and why you can encounter quite different translations for the same text in English from a program to another (different people translate the same words differently).

What if the program version changes?
Typically, you may notice from time to time a few words or sentences in English showing up in an otherwise fully localised application: that's what happens when changes were made to the original text, or new items were added, and the translation you're using has not been updated accordingly yet.
 
Now we are talking about the polonization of programs and messages contained in console programs.

There is another thing.
We want to display a text file with Polish characters, for example using cat or less.
What and where must be changed in the system. so that Polish characters appear on the screen. We set system to UTF-8 and we want to can write in any text editor in Polish, for example in vi or ee?
 
[...] We want to display a text file with Polish characters, for example using cat or less.
What and where must be changed in the system. so that Polish characters appear on the screen. We set system to UTF-8 and we want to can write in any text editor in Polish, for example in vi or ee?
I think you wouldn’t have to do much: UTF-8 is the universal way to go, even in virtual consoles.

When you haven't started Xorg you are using virtual consoles. I think a lot of the basic utils in the FreeBSD base install that run via the CLI are UTF-8 capable, at the very least capable of displaying UTF-8 characters and glyphs correctly. Since the introduction of vt(4), also known as "newcons" UTF-8 is enabled on FreeBSD; see Newcons; the table comparing syscons(4) with vt(4) makes that evident. (ee(1) seems to be an exception of not being able to handle input and display certain Polish characters directly from the keyboard.)

Full Unicode support (casually, read that as UTF-8) is no small feat; see for example: Universal Unix tool AWK gets Unicode support. Things like sorting in Unicode for all languages is not trivial. However, having said that, I think that with Polish you probably will not encounter much difficulties as its character set isn't all that much different from basic ASCII.

For displaying UTF-8 encoded (existing) texts (in Polish but not limited to Polish) you need to have a font that contains at least the typical glyphs for correct display of Polish characters (like ą LATIN SMALL LETTER A WITH OGONEK - 0x0105 and ł LATIN SMALL LETTER L WITH STROKE - 0x0142). Using fonts from x11-fonts/spleen or x11-fonts/terminus-font with Unicode support for the console works fine for me. (It could be that the font(s) you are using already can display the Polish characters correctly.) For example, after installing x11-fonts/spleen and copying /usr/local/share/fonts/spleen/spleen-8x16.fnt to /usr/share/vt/fonts/spleen-8x16.fnt will make that font selectable interactively through vidfont(1). You'll have to switch to a Polish keymap with kbdmap(1); try "Polska (programistry)" or "Polish (programmer's)" when you are in an English environment. Besides that you need to set the character set to UTF-8 of course.

You can check if you can display the characters containing special glyphs correctly by using the Czech keyboard mapping file cz.kbd:
cat /usr/share/vt/keymaps/cz.kbd
In the section titled "Accent characters" you should see the correct characters and glyphs for the output, that is after the arrow "=>"; note that the way to enter those Czech characters is specific to the Czech keyboard mapping of the file. The display of those glyphs should be the same in your browser (Firefox for example) for the file: cz.kbd. I chose the Czech keymap because is has a section "Accent characters" (pl.kbd does not have that) where Czech special characters are embedded in that file as UTF-8 encoded characters and the browser displays these characters as the appropriate glyphs by means of a (pre-selected) Unicode font.

For my Polish testing I used the mentioned fonts with Unicode support, the keymap pl.kbd and I'm using vga graphics mode (if you have a graphics mode available from a dedicated iGPU or discrete GPU you should load the appropriate driver). My output of locale:
Code:
LANG=pl_PL.UTF-8
LC_CTYPE="pl_PL.UTF-8"
LC_COLLATE="pl_PL.UTF-8"
LC_TIME="pl_PL.UTF-8"
LC_NUMERIC="pl_PL.UTF-8"
LC_MONETARY="pl_PL.UTF-8"
LC_MESSAGES="pl_PL.UTF-8"
LC_ALL=
All the settings worked so that I was able to work in a fully localized vi (not being able to read all the Polish messages ... ). All characters worked as specified for a Polish programmers keyboard layout (as mentioned in QWERTY - Polish):
Code:
% cat polish.txt 
1234567890-=!@#$%^&*()_+
zą
ążźćvaaął
łą

ąśdfghjkłżźćvbńmmpóqwęrty``````~~[]\|}{
The used settings also resulted in a Polish localized date output:
Code:
% date
pt. 24 lut 2023 12:13:54 CET

___
* using vim it seemed that Polish localization wasn't present and/or installed; you'll have to look into that how to get Polish localization. As bsduck mentioned editors/nano works well; I can confirm that it is localized; Polish characters can be typed and display correctly, Polish messages are there as well. For other editors/programs you'll have to look into if and how localization works. Also, don't forget that when in Xorg things related to the chosen DE and typical programs adapted to Xorg are usually pretty easily localized for the DE as a whole.
 
1. I installed FreeBSD in VirtualBox. I noticed that the option "Enable EFI" is of great importance.
If we have entered in rc.conf keymap="pl.kbd" then Polish fonts will be in CLI.
Nothing else needs to be set. By the way, we have a nice picture of FreeBSD at system startup.
Graphics mode is enabled and FreeBSD is using some fonts.
What fonts ? from Windows host or truetype in system FBSD ?

2. Confusing me how to set the variables displayed by the command locale
Of course you can do it with /etc/login.conf but it matters which one shell we are using

/bin/sh - use /etc/profile and then /usr/home/user/.profile and .shrc
/usr/local/bin/bash - use /usr/home/user/.profile
/usr/local/bin/csh - ...
...


Does the file .profile have the same syntax for sh() and bash() ?
man sh
"A login shell first reads commands from the file /etc/profile and then .profile in the user's home directory (...) The user can set the ENV variable to some file by placing the following line in the file .profile in the home directory, substituting for .shrc the filename desired."

Well, Nobody promised it would be easy.
 
1. I installed FreeBSD in VirtualBox. I noticed that the option "Enable EFI" is of great importance.
Not really. FreeBSD can boot via UEFI and CSM. But it does matter which boot was actually set up. As it can be set up to only CSM boot, or only EFI, or both.
What fonts ? from Windows host or truetype in system FBSD ?

2. Confusing me how to set the variables displayed by the command locale
Of course you can do it with /etc/login.conf but it matters which one shell we are using
If you set it in /etc/login.conf then the shell doesn't matter. It's an environment variable, every shell has them.

Does the file .profile have the same syntax for sh() and bash() ?
Both are Bourne compatible shells. bash(1) understands sh(1) syntax but bash(1) has some additional features that are not in sh(1). As long as you stick to the POSIX shell syntax it should work fine on both.
 
[...] 2. Confusing me how to set the variables displayed by the command locale
When I tested this, I specified the locale in an added login class "polish" in /etc/login.conf:
Code:
# Polish Users Accounts. Setup proper environment variables.
#
polish|Polish Users Accounts:\
        :charset=UTF-8:\
        :lang=pl_PL.UTF-8:\
        :tc=default:
The charset line results in setting the environment variable MM_CHARSET to UTF-8. The lang line results in the locale output I gave earlier:
Code:
LANG=pl_PL.UTF-8
LC_CTYPE="pl_PL.UTF-8"
LC_COLLATE="pl_PL.UTF-8"
LC_TIME="pl_PL.UTF-8"
LC_NUMERIC="pl_PL.UTF-8"
LC_MONETARY="pl_PL.UTF-8"
LC_MESSAGES="pl_PL.UTF-8"
LC_ALL=
You can explicitly specify individual environment variables concerning the locale. For example, in the above locale output, messages (as indicated by LC_MESSAGES) will be in polish, when localisation is available for the polish language. After adding the new line :setenv=LC_MESSAGES=en_US.UTF-8:\ directly after the line :lang=pl_PL.UTF-8:\ in /etc/login.conf in the example above, your messages will be in english inside a localized program, like the editor vi.

To use a login class you have to add it to its intended user accounts, either when adding an account at creation time or afterwards with pw(8): pw usermod -n <account_name> -L polish for example. You don't have to name it "polish", it's just a class name. You could also use something like "programmer"; it must however match the name used in /etc/login.conf. (Don't forget using cap_mkdb(1) after changing /etc/login.cong or the local .login_conf)

You do not have to use a specific login class: just add the settings after the line default:\ for classless users in /etc/login.conf; see also login.conf(5)

[...] Graphics mode is enabled and FreeBSD is using some fonts.
As mentioned in my previous answer, place a desired font file in /usr/share/vt/fonts/. This makes it easy selectable; use vidcontrol(1), for example: vidcontrol -f 8x16 spleen-8x16* and put that in the login startup file of your choosen shell.

___
* I've tried specifying fonts in /etc/rc.conf but I could not get the desired options to work as I intended.
 
Last edited:
Back
Top