Locale::Framework::SQL - An SQL Backend for Locale::Framework


Locale-Framework-SQL documentation  | view source Contained in the Locale-Framework-SQL distribution.

Index


NAME

Top

Locale::Framework::SQL - An SQL Backend for Locale::Framework

SYNOPSIS

Top

  use Locale::Framework;
  use Locale::Framework::SQL;

  Locale::Framework::init(new Locale::Framework::SQL(
                               DSN => "dbi:Pg:dbname=zclass;host=localhost", 
                               DBUSER => "test", 
                               DBPASS => "testpass", 
                               [TABLE => "testtrans"]));

  Locale::Framework::language("en");

  print _T("This is a test");

  Locale::Framework::language("nl");

  print _T("This is a test");

ABSTRACT

Top

This module provides an SQL backend for the Locale::Framework internationalization module.

DESCRIPTION

Top

new(DSN => ..., DBUSER => ..., DBPASS => ..., [TABLE => ...]) --> Locale::Framework::SQL

Instantiates a new backend object with given DSN, user and password. It creates, if not already existent, table 'lang_translations' and index 'lang_translations_idx' in the given database in DSN. TABLE defaults to 'lang_translations'.

translate(language,text) --> string

This function looks up a translation for the tuple (language, text) in the database. If it doesn't find one, it inserts the tuple in the database with translation 'text'.

This function will cache all lookups in the database. So after a running a program for a while, there won't be a lot of database access anymore for translations. This also means, that a updating translations in the database will probably not result in updated translations in the application.

set_translation(language,text,translation) --> boolean

This function looks up the tuple (language,text) in the database. If it does exist, it updates the translation for this field. Otherwise, it inserts the translation.

This function will cache the translation. Function always returns true (i.e. 1).

clear_cache() --> void

This function will clear the cache of translations.

BUGS

Top

This module has only been tested with PostgreSQL and MySQL.

SEE ALSO

Top

Locale::Framework.

AUTHOR

Top

Hans Oesterholt-Dijkema <oesterhol@cpan.org>

COPYRIGHT AND LICENSE

Top


Locale-Framework-SQL documentation  | view source Contained in the Locale-Framework-SQL distribution.