You get a bonus - 1 coin for daily activity. Now you have 1 coin

webalizer - how to change the language

Practice



There's a statistics system called webalizer, which can analyze Apache logs and generate html report files.

However, there's a small "but". Webalizer uses the current system language to generate reports, which isn't always "good" because by default it doesn't handle Russian properly. For example, it generates garbled text in chart images, and also doesn't set a default charset (i.e., it writes in, say, KOI8-R, but doesn't tell the browser which charset to interpret the statistics site pages in).

Of course, there's no problem when the OS uses English as its language package. But if you have to use Russian, for example KOI8-R, as the main language in the operating system, webalizer, without any questions or settings, will try to write reports in Russian (well, that's just how odd it is).

The simplest solution (we all know at least basic English — the lines there are all understandable) is to make webalizer output text not in Russian, but in English.


Changing the language to English

So, to make webalizer write in English, we need to change the system locale to English or C (i.e., no localization at all). We need to learn to do this automatically, since the webalizer script may be run from cron, generating reports from there.

Let's take the following approach. We'll create a shell script file that will change the language, run webalizer, and change the language back.

Here's the listing of this file:

#!/bin/sh

oldlang=`echo $LANG`
newlang="C"
export LANG=$newlang

webalizer

export LANG=$oldlang

Here we save the current language settings (oldlang), change the system language to "no localization" (C), run webalizer, which will generate a report for the current month in English, after which we change the language back to the saved one.

Please note! The report will be generated with the new language only for the CURRENT month... for other months the language will remain as before.

So, save this file, for example, as /etc/webalizer/webalizer_run.sh and make it executable:

# chmod +x /etc/webalizer/webalizer_run.sh

Now you'll need to run webalizer only through this file, and it's this file that should be specified in crontab (/etc/crontab) to be run instead of plain webalizer.


Charset

Well, for some reason we still need webalizer to pass charset information to the browser. Using KOI8-R as an example, I'll show you where to set this in the config.

So, open the webalizer.conf config file (for Debian, for example, it's located in /etc/webalizer). Find the option inside:

HTMLHead

And bring it to the following form (don't forget to uncomment it):

HTMLHead <META content="text/html; charset=koi8-r" http-equiv="content-type" />


After that, run webalizer so it regenerates the report for the current month.

Applies to: Webalizer on Linux
created: 2017-05-09
updated: 2026-03-10
2041



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)