The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Locale::Framework - A module for internationalization

SYNOPSIS

  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"]));
    
  print _T("This is a test");

  Locale::Framework::language("nl_NL");
  
  print _T("This is a test");

Alternative interface (using wxLocale backend as an example), which does exactly the same. There is no local object scope, there's only a global class (or program that is) scope. OO interface is only for conveniance.

  use Locale::Framework;
  use Locale::Framework::wxLocale;

  my $LOC=new Locale::Framework;

  $LOC->init(new Locale::Framework::wxLocale("./locale","test"));

  print _T("This is a test");
  $LOC->language("nl_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 Locale::Framework::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 a backend see Locale::Framework::SQL.

If you don't use Locale::Framework::init() to initialize a backend, Locale::Framework defaults to the Locale::Framework::Dumb backend. The default language that is being used is 'en', without specifiers.

Locale::Framework::init(backend) --> void

This initializes the Locale::Framework module with a supported backend.

Locale::Framework::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.

Locale::Framework::clear_cache() --> void

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

Locale::Framework::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

Locale::Framework::wxLocale, Locale::Framework::SQL, Locale::Framework::Dumb, 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.