man Locale::Maketext::Simple () - Simple interface to Locale::Maketext::Lexicon
NAME
Locale::Maketext::Simple - Simple interface to Locale::Maketext::Lexicon
VERSION
This document describes version 0.12 of Locale::Maketext::Simple, released March 17, 2004.
SYNOPSIS
Minimal setup (looks for auto/Foo/*.po and auto/Foo/*.mo):
package Foo; use Locale::Maketext::Simple; # exports 'loc' loc_lang('fr'); # set language to French sub hello { print loc("Hello, [_1]!", "World"); }
More sophisticated example:
package Foo::Bar; use Locale::Maketext::Simple ( Class => 'Foo', # search in auto/Foo/ Style => 'gettext', # %1 instead of [_1] Export => 'maketext', # maketext() instead of loc() Subclass => 'L10N', # Foo::L10N instead of Foo::I18N Decode => 1, # decode entries to unicode-strings Encoding => 'locale', # but encode lexicons in current locale # (needs Locale::Maketext::Lexicon 0.36) ); sub japh { print maketext("Just another %1 hacker", "Perl"); }
DESCRIPTION
This module is a simple wrapper around Locale::Maketext::Lexicon, designed to alleviate the need of creating Language Classes for module authors.
If Locale::Maketext::Lexicon is not present, it implements a minimal localization function by simply interpolating CW[_1] with the first argument, CW[_2] with the second, etc. Interpolated function like CW[quant,_1] are treated as CW[_1], with the sole exception of CW[tense,_1,X], which will append CWing to CW_1 when X is CWpresent, or appending CWed to <_1> otherwise.
OPTIONS
All options are passed either via the CWuse statement, or via an explicit CWimport.
Class
By default, Locale::Maketext::Simple draws its source from the calling package's auto/ directory; you can override this behaviour by explicitly specifying another package as CWClass.
Path
If your PO and MO files are under a path elsewhere than CWauto/, you may specify it using the CWPath option.
Style
By default, this module uses the CWmaketext style of CW[_1] and CW[quant,_1] for interpolation. Alternatively, you can specify the CWgettext style, which uses CW%1 and CW%quant(%1) for interpolation.
This option is case-insensitive.
Export
By default, this module exports a single function, CWloc, into its caller's namespace. You can set it to another name, or set it to an empty string to disable exporting.
Subclass
By default, this module creates an CW::I18N subclass under the caller's package (or the package specified by CWClass), and stores lexicon data in its subclasses. You can assign a name other than CWI18N via this option.
Decode
If set to a true value, source entries will be converted into utf8-strings (available in Perl 5.6.1 or later). This feature needs the Encode or Encode::compat module.
Encoding
Specifies an encoding to store lexicon entries, instead of utf8-strings. If set to CWlocale, the encoding from the current locale setting is used. Implies a true value for CWDecode.
ACKNOWLEDGMENTS
Thanks to Jos I. Boumans for suggesting this module to be written.
Thanks to Chia-Liang Kao for suggesting CWPath and CWloc_lang.
SEE ALSO
Locale::Maketext, Locale::Maketext::Lexicon
AUTHORS
Autrijus Tang <autrijus@autrijus.org>
COPYRIGHT
Copyright 2003, 2004 by Autrijus Tang <autrijus@autrijus.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>