Debian Codegraph @

README

raw
1 NAME
2
3 Catmandu::I18N - tools for text localisation
4
5 SYNOPSIS
6
7 use Catmandu::Sane;
8
9 use Catmandu::I18N;
10
11 my $i = Catmandu::I18N->new(
12 config => {
13 en => [
14 "Gettext",
15 "/path/to/en.po"
16 ],
17 nl => [
18 "Gettext",
19 "/path/to/nl.po"
20 ]
21 }
22 );
23
24 $i->t( "my-lang", "my-key" );
25 $i->t( "my-lang", "my-key2", "arg-1", "arg-2" );
26
27 CONSTRUCTOR ARGUMENTS
28
29 config
30
31 Configuration for Locale::Maketext.
32
33 Must be either:
34
35 * hash reference
36
37 * string (e.g. "i18n")
38
39 When the config is a string, it is interpreted as the path to the
40 I18N configuration in Catmandu config.
41
42 Required
43
44 on_failure
45
46 What to do when a lookup does not give a result.
47
48 Possible values:
49
50 * "undef" : return undef
51
52 * "auto" : return key itself. Always a result.
53
54 * "die" : die
55
56 Default: "undef"
57
58 Note: "undef" should be a string, as opposed to undef.
59
60 fallback_languages
61
62 array of fallback language codes
63
64 * must be array reference
65
66 * default is [ "i-default","en","en-US" ] as determined by
67 Locale::Maketext
68
69 When Locale::Maketext does not find the specified language in your
70 config, it will fallback to one of these, and then load the handle
71 for that.
72
73 Only if that fallback language does not exist in the config, will it
74 fail.
75
76 Example 1:
77
78 fallback_languages is [ "en" ]
79
80 you have only language "en" in your config, but you request language
81 "nl", then you'll get the message in English.
82
83 Example 2:
84
85 fallback_languages is [ "en" ]
86
87 you have only language "nl" in your config, but you request language
88 "fr", then the creation of the message will fail
89
90 You can set this to an empty array for consistent behaviour.
91
92 NOTES
93
94 * the lexicon implementation determines the format of the message.
95
96 e.g. only Locale::Maketext::Lexicon::Gettext supports placeholders like
97 %1.
98
99 For other implementations you need to use placeholders like [_1]
100
101 AUTHORS
102
103 Nicolas Franck <nicolas.franck at ugent.be>
104
105 SEE ALSO
106
107 Catmandu::Fix::i18n, Locale::Maketext::Lexicon::CatmanduConfig,
108 Catmandu, Locale::Maketext
109
110 LICENSE AND COPYRIGHT
111
112 This program is free software; you can redistribute it and/or modify it
113 under the terms of either: the GNU General Public License as published
114 by the Free Software Foundation; or the Artistic License.
115
116 See http://dev.perl.org/licenses/ for more information.
117