NAME

Lang - A module for internationalization

SYNOPSIS

use Lang;
use Lang::SQL;

Lang::init(new Lang::SQL("dbi:Pg:dbname=zclass;host=localhost","test","testpass");

Lang::language("en");

print _T("This is a test");

Lang::language("nl");

print _T("This is a test");

ABSTRACT

This module provides simple string based internationalization support. It exports a '_T' function that can be used for all text that need displayed. It can work with different backends, e.g. SQL or file based backends. The backend defaults to Lang::Dumb, which doesn't translate at all.

DESCRIPTION

With this module simple string based internationalization can be made through uses of '_T' function calls. Strings will be looked up by a backend and can be subsequentially cached by the same backend. For an interface to the backend see Lang::SQL.

Lang::init(backend) --> void

This initializes the Lang module with a supported backend. This function must be called before any use of the _T() function.

Lang::language(language) --> void

This sets the current language to use. Languages are free to be named, but it is recommended to use common categories as provided in ISO639, e.g. 'en', 'nl', 'no', 'pl', etc. The language is default initialized to 'en' (for category english).

If language is set to "" (empty string), no translations must be done by function _T().

_T(text) --> string

This function looks up 'text' in the current backend and returns a translation for 'text' given the provided language.

This function actually only calls the backend function backend-translate($language,$text)>; nothing else. The backend must to solve the rest.

Lang::clear_cache() --> void

This function can be used to inform the backend to clear it's current cached translations.

Lang::set_translation(text,translation) --> boolean

This function can be used to set a translation for a given tuple (language,text). The current language setting is used. The backend is required to update the translation for this tuple in it's translations base.

If the backend does not support this functionality, it must return false. Otherwise, it must update or add (if it does not exist) the translation and return true, if this updating succeeds.

EXPORT

_T() is exported.

SEE ALSO

Lang::SQL, ISO639 (google works).

AUTHOR

Hans Oesterholt-Dijkema <oesterhol@cpan.org>

COPYRIGHT AND LICENSE

This library is free software; you can redistribute it and/or modify it under LGPL terms.