The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Lang::SQL - A backend for Lang 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 an SQL backend for the Lang internationalization module.

DESCRIPTION

new(dsn,user,pass) --> Lang::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.

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.

clear_cache() --> void

This function will clear the cache of translations.

BUGS

This module has only been tested with PostgreSQL.

SEE ALSO

Lang.

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.