Locale::Framework - A module for internationalization
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");
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.
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()
Locale::Framework::init(backend)
This initializes the Locale::Framework module with a supported backend.
Locale::Framework::language(language)
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)
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.
backend-
Locale::Framework::clear_cache()
This function can be used to inform the backend to clear it's current cached translations.
Locale::Framework::set_translation(text,translation)
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.
language
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.
false
true
_T() is exported.
Locale::Framework::wxLocale, Locale::Framework::SQL, Locale::Framework::Dumb, ISO639 (google works).
Hans Oesterholt-Dijkema <oesterhol@cpan.org>
This library is free software; you can redistribute it and/or modify it under LGPL terms.
To install Locale::Framework, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::Framework
CPAN shell
perl -MCPAN -e shell install Locale::Framework
For more information on module installation, please visit the detailed CPAN module installation guide.