| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "Locale::Maketext::Simple 3perl" |
| 58 |
.TH Locale::Maketext::Simple 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide" |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
Locale::Maketext::Simple \- Simple interface to Locale::Maketext::Lexicon |
| 65 |
.SH VERSION |
| 66 |
.IX Header "VERSION" |
| 67 |
This document describes version 0.18 of Locale::Maketext::Simple, |
| 68 |
released Septermber 8, 2006. |
| 69 |
.SH SYNOPSIS |
| 70 |
.IX Header "SYNOPSIS" |
| 71 |
Minimal setup (looks for \fIauto/Foo/*.po\fR and \fIauto/Foo/*.mo\fR): |
| 72 |
.PP |
| 73 |
.Vb 6 |
| 74 |
\& package Foo; |
| 75 |
\& use Locale::Maketext::Simple; # exports \*(Aqloc\*(Aq |
| 76 |
\& loc_lang(\*(Aqfr\*(Aq); # set language to French |
| 77 |
\& sub hello { |
| 78 |
\& print loc("Hello, [_1]!", "World"); |
| 79 |
\& } |
| 80 |
.Ve |
| 81 |
.PP |
| 82 |
More sophisticated example: |
| 83 |
.PP |
| 84 |
.Vb 10 |
| 85 |
\& package Foo::Bar; |
| 86 |
\& use Locale::Maketext::Simple ( |
| 87 |
\& Class => \*(AqFoo\*(Aq, # search in auto/Foo/ |
| 88 |
\& Style => \*(Aqgettext\*(Aq, # %1 instead of [_1] |
| 89 |
\& Export => \*(Aqmaketext\*(Aq, # maketext() instead of loc() |
| 90 |
\& Subclass => \*(AqL10N\*(Aq, # Foo::L10N instead of Foo::I18N |
| 91 |
\& Decode => 1, # decode entries to unicode\-strings |
| 92 |
\& Encoding => \*(Aqlocale\*(Aq, # but encode lexicons in current locale |
| 93 |
\& # (needs Locale::Maketext::Lexicon 0.36) |
| 94 |
\& ); |
| 95 |
\& sub japh { |
| 96 |
\& print maketext("Just another %1 hacker", "Perl"); |
| 97 |
\& } |
| 98 |
.Ve |
| 99 |
.SH DESCRIPTION |
| 100 |
.IX Header "DESCRIPTION" |
| 101 |
This module is a simple wrapper around \fBLocale::Maketext::Lexicon\fR, |
| 102 |
designed to alleviate the need of creating \fILanguage Classes\fR for |
| 103 |
module authors. |
| 104 |
.PP |
| 105 |
The language used is chosen from the loc_lang call. If a lookup is not |
| 106 |
possible, the i\-default language will be used. If the lookup is not in the |
| 107 |
i\-default language, then the key will be returned. |
| 108 |
.PP |
| 109 |
If \fBLocale::Maketext::Lexicon\fR is not present, it implements a |
| 110 |
minimal localization function by simply interpolating \f(CW\*(C`[_1]\*(C'\fR with |
| 111 |
the first argument, \f(CW\*(C`[_2]\*(C'\fR with the second, etc. Interpolated |
| 112 |
function like \f(CW\*(C`[quant,_1]\*(C'\fR are treated as \f(CW\*(C`[_1]\*(C'\fR, with the sole |
| 113 |
exception of \f(CW\*(C`[tense,_1,X]\*(C'\fR, which will append \f(CW\*(C`ing\*(C'\fR to \f(CW\*(C`_1\*(C'\fR when |
| 114 |
X is \f(CW\*(C`present\*(C'\fR, or appending \f(CW\*(C`ed\*(C'\fR to <_1> otherwise. |
| 115 |
.SH OPTIONS |
| 116 |
.IX Header "OPTIONS" |
| 117 |
All options are passed either via the \f(CW\*(C`use\*(C'\fR statement, or via an |
| 118 |
explicit \f(CW\*(C`import\*(C'\fR. |
| 119 |
.SS Class |
| 120 |
.IX Subsection "Class" |
| 121 |
By default, \fBLocale::Maketext::Simple\fR draws its source from the |
| 122 |
calling package's \fIauto/\fR directory; you can override this behaviour |
| 123 |
by explicitly specifying another package as \f(CW\*(C`Class\*(C'\fR. |
| 124 |
.SS Path |
| 125 |
.IX Subsection "Path" |
| 126 |
If your PO and MO files are under a path elsewhere than \f(CW\*(C`auto/\*(C'\fR, |
| 127 |
you may specify it using the \f(CW\*(C`Path\*(C'\fR option. |
| 128 |
.SS Style |
| 129 |
.IX Subsection "Style" |
| 130 |
By default, this module uses the \f(CW\*(C`maketext\*(C'\fR style of \f(CW\*(C`[_1]\*(C'\fR and |
| 131 |
\&\f(CW\*(C`[quant,_1]\*(C'\fR for interpolation. Alternatively, you can specify the |
| 132 |
\&\f(CW\*(C`gettext\*(C'\fR style, which uses \f(CW%1\fR and \f(CW%quant(%1)\fR for interpolation. |
| 133 |
.PP |
| 134 |
This option is case-insensitive. |
| 135 |
.SS Export |
| 136 |
.IX Subsection "Export" |
| 137 |
By default, this module exports a single function, \f(CW\*(C`loc\*(C'\fR, into its |
| 138 |
caller's namespace. You can set it to another name, or set it to |
| 139 |
an empty string to disable exporting. |
| 140 |
.SS Subclass |
| 141 |
.IX Subsection "Subclass" |
| 142 |
By default, this module creates an \f(CW\*(C`::I18N\*(C'\fR subclass under the |
| 143 |
caller's package (or the package specified by \f(CW\*(C`Class\*(C'\fR), and stores |
| 144 |
lexicon data in its subclasses. You can assign a name other than |
| 145 |
\&\f(CW\*(C`I18N\*(C'\fR via this option. |
| 146 |
.SS Decode |
| 147 |
.IX Subsection "Decode" |
| 148 |
If set to a true value, source entries will be converted into |
| 149 |
utf8\-strings (available in Perl 5.6.1 or later). This feature |
| 150 |
needs the \fBEncode\fR or \fBEncode::compat\fR module. |
| 151 |
.SS Encoding |
| 152 |
.IX Subsection "Encoding" |
| 153 |
Specifies an encoding to store lexicon entries, instead of |
| 154 |
utf8\-strings. If set to \f(CW\*(C`locale\*(C'\fR, the encoding from the current |
| 155 |
locale setting is used. Implies a true value for \f(CW\*(C`Decode\*(C'\fR. |
| 156 |
.SH ACKNOWLEDGMENTS |
| 157 |
.IX Header "ACKNOWLEDGMENTS" |
| 158 |
Thanks to Jos I. Boumans for suggesting this module to be written. |
| 159 |
.PP |
| 160 |
Thanks to Chia-Liang Kao for suggesting \f(CW\*(C`Path\*(C'\fR and \f(CW\*(C`loc_lang\*(C'\fR. |
| 161 |
.SH "SEE ALSO" |
| 162 |
.IX Header "SEE ALSO" |
| 163 |
Locale::Maketext, Locale::Maketext::Lexicon |
| 164 |
.SH AUTHORS |
| 165 |
.IX Header "AUTHORS" |
| 166 |
Audrey Tang <[email protected]> |
| 167 |
.SH COPYRIGHT |
| 168 |
.IX Header "COPYRIGHT" |
| 169 |
Copyright 2003, 2004, 2005, 2006 by Audrey Tang <[email protected]>. |
| 170 |
.PP |
| 171 |
This software is released under the MIT license cited below. Additionally, |
| 172 |
when this software is distributed with \fBPerl Kit, Version 5\fR, you may also |
| 173 |
redistribute it and/or modify it under the same terms as Perl itself. |
| 174 |
.SS "The ""MIT"" License" |
| 175 |
.IX Subsection "The ""MIT"" License" |
| 176 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 177 |
of this software and associated documentation files (the "Software"), to deal |
| 178 |
in the Software without restriction, including without limitation the rights |
| 179 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 180 |
copies of the Software, and to permit persons to whom the Software is |
| 181 |
furnished to do so, subject to the following conditions: |
| 182 |
.PP |
| 183 |
The above copyright notice and this permission notice shall be included in |
| 184 |
all copies or substantial portions of the Software. |
| 185 |
.PP |
| 186 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 187 |
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 188 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 189 |
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 190 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 191 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 192 |
DEALINGS IN THE SOFTWARE. |