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 The language used is chosen from the loc_lang call. If a lookup is not
45 possible, the i-default language will be used. If the lookup is not in
46 the i-default language, then the key will be returned.
47
48 If Locale::Maketext::Lexicon is not present, it implements a minimal
49 localization function by simply interpolating "[_1]" with the first
50 argument, "[_2]" with the second, etc. Interpolated function like
51 "[quant,_1]" are treated as "[_1]", with the sole exception of
52 "[tense,_1,X]", which will append "ing" to "_1" when X is "present", or
53 appending "ed" to <_1> otherwise.
54
56 All options are passed either via the "use" statement, or via an
57 explicit "import".
58
59 Class
60 By default, Locale::Maketext::Simple draws its source from the calling
61 package's auto/ directory; you can override this behaviour by
62 explicitly specifying another package as "Class".
63
64 Path
65 If your PO and MO files are under a path elsewhere than "auto/", you
66 may specify it using the "Path" option.
67
68 Style
69 By default, this module uses the "maketext" style of "[_1]" and
70 "[quant,_1]" for interpolation. Alternatively, you can specify the
71 "gettext" style, which uses %1 and "%quant(%1)" for interpolation.
72
73 This option is case-insensitive.
74
75 Export
76 By default, this module exports a single function, "loc", into its
77 caller's namespace. You can set it to another name, or set it to an
78 empty string to disable exporting.
79
80 Subclass
81 By default, this module creates an "::I18N" subclass under the caller's
82 package (or the package specified by "Class"), and stores lexicon data
83 in its subclasses. You can assign a name other than "I18N" via this
84 option.
85
86 Decode
87 If set to a true value, source entries will be converted into
88 utf8-strings (available in Perl 5.6.1 or later). This feature needs
89 the Encode or Encode::compat module.
90
91 Encoding
92 Specifies an encoding to store lexicon entries, instead of
93 utf8-strings. If set to "locale", the encoding from the current locale
94 setting is used. Implies a true value for "Decode".
95
97 Thanks to Jos I. Boumans for suggesting this module to be written.
98
99 Thanks to Chia-Liang Kao for suggesting "Path" and "loc_lang".
100
102 Locale::Maketext, Locale::Maketext::Lexicon
103
105 Audrey Tang <cpan@audreyt.org>
106
108 Copyright 2003, 2004, 2005, 2006 by Audrey Tang <cpan@audreyt.org>.
109
110 This software is released under the MIT license cited below.
111 Additionally, when this software is distributed with Perl Kit, Version
112 5, you may also redistribute it and/or modify it under the same terms
113 as Perl itself.
114
115 The "MIT" License
116 Permission is hereby granted, free of charge, to any person obtaining a
117 copy of this software and associated documentation files (the
118 "Software"), to deal in the Software without restriction, including
119 without limitation the rights to use, copy, modify, merge, publish,
120 distribute, sublicense, and/or sell copies of the Software, and to
121 permit persons to whom the Software is furnished to do so, subject to
122 the following conditions:
123
124 The above copyright notice and this permission notice shall be included
125 in all copies or substantial portions of the Software.
126
127 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
128 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
129 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
130 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
131 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
132 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
133 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
134
135
136
137perl v5.34.1 2022-03-15 Locale::Maketext::Simple(3pm)