1Locale::Maketext::SimpleP(e3rplm)Programmers ReferenceLGouciadlee::Maketext::Simple(3pm)
2
3
4
6 Locale::Maketext::Simple - Simple interface to
7 Locale::Maketext::Lexicon
8
10 This document describes version 0.18 of Locale::Maketext::Simple,
11 released Septermber 8, 2006.
12
14 Minimal setup (looks for auto/Foo/*.po and auto/Foo/*.mo):
15
16 package Foo;
17 use Locale::Maketext::Simple; # exports 'loc'
18 loc_lang('fr'); # set language to French
19 sub hello {
20 print loc("Hello, [_1]!", "World");
21 }
22
23 More sophisticated example:
24
25 package Foo::Bar;
26 use Locale::Maketext::Simple (
27 Class => 'Foo', # search in auto/Foo/
28 Style => 'gettext', # %1 instead of [_1]
29 Export => 'maketext', # maketext() instead of loc()
30 Subclass => 'L10N', # Foo::L10N instead of Foo::I18N
31 Decode => 1, # decode entries to unicode-strings
32 Encoding => 'locale', # but encode lexicons in current locale
33 # (needs Locale::Maketext::Lexicon 0.36)
34 );
35 sub japh {
36 print maketext("Just another %1 hacker", "Perl");
37 }
38
40 This module is a simple wrapper around Locale::Maketext::Lexicon,
41 designed to alleviate the need of creating Language Classes for module
42 authors.
43
44 If Locale::Maketext::Lexicon is not present, it implements a minimal
45 localization function by simply interpolating "[_1]" with the first
46 argument, "[_2]" with the second, etc. Interpolated function like
47 "[quant,_1]" are treated as "[_1]", with the sole exception of
48 "[tense,_1,X]", which will append "ing" to "_1" when X is "present", or
49 appending "ed" to <_1> otherwise.
50
52 All options are passed either via the "use" statement, or via an
53 explicit "import".
54
55 Class
56 By default, Locale::Maketext::Simple draws its source from the calling
57 package's auto/ directory; you can override this behaviour by
58 explicitly specifying another package as "Class".
59
60 Path
61 If your PO and MO files are under a path elsewhere than "auto/", you
62 may specify it using the "Path" option.
63
64 Style
65 By default, this module uses the "maketext" style of "[_1]" and
66 "[quant,_1]" for interpolation. Alternatively, you can specify the
67 "gettext" style, which uses %1 and "%quant(%1)" for interpolation.
68
69 This option is case-insensitive.
70
71 Export
72 By default, this module exports a single function, "loc", into its
73 caller's namespace. You can set it to another name, or set it to an
74 empty string to disable exporting.
75
76 Subclass
77 By default, this module creates an "::I18N" subclass under the caller's
78 package (or the package specified by "Class"), and stores lexicon data
79 in its subclasses. You can assign a name other than "I18N" via this
80 option.
81
82 Decode
83 If set to a true value, source entries will be converted into
84 utf8-strings (available in Perl 5.6.1 or later). This feature needs
85 the Encode or Encode::compat module.
86
87 Encoding
88 Specifies an encoding to store lexicon entries, instead of
89 utf8-strings. If set to "locale", the encoding from the current locale
90 setting is used. Implies a true value for "Decode".
91
93 Thanks to Jos I. Boumans for suggesting this module to be written.
94
95 Thanks to Chia-Liang Kao for suggesting "Path" and "loc_lang".
96
98 Locale::Maketext, Locale::Maketext::Lexicon
99
101 Audrey Tang <cpan@audreyt.org>
102
104 Copyright 2003, 2004, 2005, 2006 by Audrey Tang <cpan@audreyt.org>.
105
106 This software is released under the MIT license cited below.
107 Additionally, when this software is distributed with Perl Kit, Version
108 5, you may also redistribute it and/or modify it under the same terms
109 as Perl itself.
110
111 The "MIT" License
112 Permission is hereby granted, free of charge, to any person obtaining a
113 copy of this software and associated documentation files (the
114 "Software"), to deal in the Software without restriction, including
115 without limitation the rights to use, copy, modify, merge, publish,
116 distribute, sublicense, and/or sell copies of the Software, and to
117 permit persons to whom the Software is furnished to do so, subject to
118 the following conditions:
119
120 The above copyright notice and this permission notice shall be included
121 in all copies or substantial portions of the Software.
122
123 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
124 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
125 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
126 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
127 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
128 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
129 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
130
131
132
133perl v5.10.1 2009-02-12 Locale::Maketext::Simple(3pm)