Hi Kang,

On 29 Aug 2009, at 15:00, Kang wrote:

Opsview 3.3.0 started to support i18n.
but it's all latin1 based languages even though all opsview web pages are utf8 encoded.

Recently I had digged into opsview source code to support korean characters(utf8 encoding).

In order to support real i18n.

1. Opsview should implicitly change its based DB encoding to UTF8.
CREATE DATABASE [DBNAME] DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Most default mysql installation are latin1-based.( i don't want to modify mysql server configuration and it works well without server dependency ) If you want to create utf8-encoded database, you should add implicit option when creating DB.


2. DB connect string should contain ";mysql_enable_utf8=1"

Most default mysql installation are latin1-based and some old mysql doesn't properly handle utf8 client connection. so I modified opsview.conf to override opsview.default file to ensure the client is utf8 connection like "set names utf8";

$dbhost = "localhost;mysql_enable_utf8=1";
..
..

After doing those things.

Some database columns ( alias column in hosts table ) can handle korean characters(utf8 encoding) well.
but I wanted more columns can handle utf8 encoding.
< For example description column in keywords table >

so I modified DBIx::Class code in /usr/local/nagios/lib/Opsview/ Schema/Keywords.pm file.
__PACKAGE__->load_components(qw/UTF8Columns Core/);
__PACKAGE__->utf8_columns(qw/description/);

but It didn't work as I expected. and I searched other codes.
Finally I found that opsview has both DBIx::Class and Class::DBI ORM codes.
( I don't know what and where codes are really used. )

so I modified Class::DBI code ( /usr/local/nagios/lib/Opsview/ Keyword.pm )
__PACKAGE__->utf8_columns( qw/description/ );

After that, It worked well.

3. All DB columns need not to be alphanumeric characters should be enabled to handle utf8-encoding characters.

< DBIx::Class code >

__PACKAGE__->load_components(qw/UTF8Columns Code/);
__PACKAGE__->utf8_columns(qw/utf8_enabled_column1 utf8_enabled_column2/);

or
__PACKAGE__->load_components(qw/ForceUTF8/);


< Class::DBI code >

__PACKAGE__->utf8_columns(qw/utf8_enabled_column1 utf8_enabled_column2/);


References:
http://dev.catalystframework.org/wiki/tutorialsandhowtos/using_unicode


Thanks! We'll look into adding these in a future release. I've raised a ticket for us to look into this, probably around 3.3.2 release. https://secure.opsera.com/jira/browse/OPS-595

Ton

_______________________________________________
Opsview-users mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-users

Reply via email to