1Catalyst::Plugin::I18N:U:sMearnuCaoln(t3r)ibuted Perl DoCcautmaelnytsatt:i:oPnlugin::I18N::Manual(3)
2
3
4

NAME

6       Catalyst::Plugin::I18N::Manual - (Draft) I18N and L10N with Catalyst
7       and Template Toolkit.
8

OUTLINE

10           Prerequisites:
11            - perl >= 5.8.0
12            - Catalyst >= 5.33
13            - Catalyst::Plugin::I18N >= 0.04
14            - Catalyst::Plugin::Unicode >= 0.2
15            - Catlayst::View::TT && Template-Toolkit >= 2.14
16            - GNU gettext utilities
17            - An editor that understands UTF-8 and Byte Order Mark (BOM)
18
19           $ catalyst.pl MyApp
20           created "MyApp"
21           created "MyApp/script"
22           created "MyApp/lib"
23           created "MyApp/root"
24           created "MyApp/root/static"
25           created "MyApp/root/static/images"
26           created "MyApp/t"
27           created "MyApp/lib/MyApp"
28           created "MyApp/lib/MyApp/Model"
29           created "MyApp/lib/MyApp/View"
30           created "MyApp/lib/MyApp/Controller"
31           created "MyApp/lib/MyApp.pm"
32           created "MyApp/Makefile.PL"
33           created "MyApp/README"
34           created "MyApp/Changes"
35           created "MyApp/t/01app.t"
36           created "MyApp/t/02pod.t"
37           created "MyApp/t/03podcoverage.t"
38           created "MyApp/root/static/images/catalyst_logo.png"
39           created "MyApp/root/static/images/btn_120x50_built.png"
40           created "MyApp/root/static/images/btn_120x50_built_shadow.png"
41           created "MyApp/root/static/images/btn_120x50_powered.png"
42           created "MyApp/root/static/images/btn_120x50_powered_shadow.png"
43           created "MyApp/root/static/images/btn_88x31_built.png"
44           created "MyApp/root/static/images/btn_88x31_built_shadow.png"
45           created "MyApp/root/static/images/btn_88x31_powered.png"
46           created "MyApp/root/static/images/btn_88x31_powered_shadow.png"
47           created "MyApp/root/favicon.ico"
48           created "MyApp/script/myapp_cgi.pl"
49           created "MyApp/script/myapp_fastcgi.pl"
50           created "MyApp/script/myapp_server.pl"
51           created "MyApp/script/myapp_test.pl"
52           created "MyApp/script/myapp_create.pl"
53
54           $ cd MyApp
55           $ vim lib/MyApp.pm
56
57           use Catalyst qw/-Debug I18N Unicode/;
58
59           sub begin : Private {
60               my ( $self, $c ) = @_;
61
62               my $locale = $c->request->param('locale');
63
64               $c->response->headers->push_header( 'Vary' => 'Accept-Language' );  # hmm vary and param?
65               $c->languages( $locale ? [ $locale ] : undef );
66           }
67
68           sub default : Private {
69               my ( $self, $c ) = @_;
70
71               my $name = $c->request->param('name') || $c->loc('Guest');
72
73               $c->response->content_type('text/plain; charset=utf-8');
74               $c->response->body( $c->loc( 'Welcome [_1]!', $name ) );
75           }
76
77           $ mkdir lib/MyApp/I18N
78           $ xgettext.pl --output=lib/MyApp/I18N/messages.pot --directory=lib/
79           $ ls lib/MyApp/I18N/
80           messages.pot
81
82           $ msginit --input=lib/MyApp/I18N/messages.pot --output=lib/MyApp/I18N/sv.po --locale=sv
83           Created lib/MyApp/I18N/sv.po.
84
85           $ vim lib/MyApp/I18N/sv.po
86
87           "Content-Type: text/plain; charset=utf-8\n"
88
89           #: lib/MyApp.pm:50
90           msgid "Guest"
91           msgstr "Gäst"
92
93           #. ($name)
94           #: lib/MyApp.pm:54
95           msgid "Welcome %1!"
96           msgstr "Välkommen %1!"
97
98           $ perl script/myapp_server.pl
99           [Fri Dec  2 03:52:45 2005] [catalyst] [debug] Debug messages enabled
100           [Fri Dec  2 03:52:47 2005] [catalyst] [debug] Loaded plugins:
101           .------------------------------------------------------------------------------.
102           | Catalyst::Plugin::I18N                                                       |
103           | Catalyst::Plugin::Unicode                                                    |
104           '------------------------------------------------------------------------------'
105
106           [Fri Dec  2 03:52:47 2005] [catalyst] [debug] Loaded dispatcher "Catalyst::Dispatcher"
107           [Fri Dec  2 03:52:47 2005] [catalyst] [debug] Loaded engine "Catalyst::Engine::HTTP"
108           [Fri Dec  2 03:52:47 2005] [catalyst] [debug] Found home "/Users/chansen/MyApp"
109           [Fri Dec  2 03:52:48 2005] [catalyst] [debug] Initialized i18n "MyApp::I18N"
110           [Fri Dec  2 03:52:48 2005] [catalyst] [debug] Loaded Private actions:
111           .----------------------+----------------------------------------+--------------.
112           | Private              | Class                                  | Method       |
113           +----------------------+----------------------------------------+--------------+
114           | /default             | MyApp                                  | default      |
115           '----------------------+----------------------------------------+--------------'
116
117           [Fri Dec  2 03:52:48 2005] [catalyst] [info] MyApp powered by Catalyst 5.57
118           You can connect to your server at http://localhost:3000
119
120           # point your browser to http://localhost:3000/?name=Joe
121           # output should render:
122
123           Välkommen Joe!
124
125           $ vim lib/MyApp.pm
126
127           sub default : Private {
128
129               # ...
130
131               $c->response->body( $c->loc( 'Welcome to my homepage [_1]!', $name ) );
132           }
133
134           $ xgettext.pl --output=lib/MyApp/I18N/messages.pot --directory=lib/
135           $ msgmerge --update lib/MyApp/I18N/sv.po lib/MyApp/I18N/messages.pot
136           . done.
137
138           $ vim lib/MyApp/I18N/sv.po
139
140           #. ($name)
141           #: lib/MyApp.pm:54
142           msgid "Welcome to my homepage %1!"
143           msgstr "Välkommen till min hemsida %1!"
144
145           $ perl script/myapp_server.pl
146
147           # point your browser to http://localhost:3000/?name=Joe
148           # output should render:
149
150           Välkommen till min hemsida Joe!
151
152           $ perl script/myapp_create.pl view TT TT
153            exists "/Users/chansen/MyApp/script/../lib/MyApp/View"
154            exists "/Users/chansen/MyApp/script/../t"
155           created "/Users/chansen/MyApp/script/../lib/MyApp/View/TT.pm"
156           created "/Users/chansen/MyApp/script/../t/view_TT.t"
157
158           $ vim lib/MyApp.pm
159
160           sub default : Private {
161               my ( $self, $c ) = @_;
162
163               my $name = $c->request->param('name') || $c->loc('Guest');
164
165               $c->response->content_type('text/plain; charset=utf-8');
166               $c->stash(
167                   name     => $name,
168                   template => 'test.tt'
169               );
170
171               $c->forward('MyApp::View::TT');
172           }
173
174           $ vim root/test.tt # Save file in UTF-8 with BOM
175
176           [% c.loc( 'Welcome to my place [_1]!', c.stash.name ) %]
177
178           $ xgettext.pl --output=lib/MyApp/I18N/messages.pot --directory=lib/ --directory=root/
179           $ msgmerge --update lib/MyApp/I18N/sv.po lib/MyApp/I18N/messages.pot
180           . done.
181
182           $ vim lib/MyApp/I18N/sv.po
183
184           #. (c.stash.name)
185           #: root/test.tt:1
186           msgid "Welcome to my place %1!"
187           msgstr "Välkommen till mitt ställe %1!"
188
189           $ perl script/myapp_server.pl
190           [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Debug messages enabled
191           [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Loaded plugins:
192           .------------------------------------------------------------------------------.
193           | Catalyst::Plugin::I18N                                                       |
194           | Catalyst::Plugin::Unicode                                                    |
195           '------------------------------------------------------------------------------'
196
197           [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Loaded dispatcher "Catalyst::Dispatcher"
198           [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Loaded engine "Catalyst::Engine::HTTP"
199           [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Found home "/Users/chansen/MyApp"
200           [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Initialized i18n "MyApp::I18N"
201           [Fri Dec  2 05:12:59 2005] [catalyst] [debug] Loaded components:
202           .-------------------------------------------------------------------+----------.
203           | Class                                                             | Type     |
204           +-------------------------------------------------------------------+----------+
205           | MyApp::View::TT                                                   | instance |
206           '-------------------------------------------------------------------+----------'
207
208           [Fri Dec  2 05:12:59 2005] [catalyst] [debug] Loaded Private actions:
209           .----------------------+----------------------------------------+--------------.
210           | Private              | Class                                  | Method       |
211           +----------------------+----------------------------------------+--------------+
212           | /default             | MyApp                                  | default      |
213           '----------------------+----------------------------------------+--------------'
214
215           [Fri Dec  2 05:12:59 2005] [catalyst] [info] MyApp powered by Catalyst 5.57
216           You can connect to your server at http://localhost:3000
217
218           # point your browser to http://localhost:3000/?name=Joe
219           # output should render:
220
221           Välkommen till mitt ställe Joe!
222

INTRODUCTION

INTERNATIONALIZATION

CONTENT NEGOTIATION

226   Server-driven
227   Agent-driven

LOCALIZATION

STAYING IN SYNC

TEMPLATE TOOLKIT

RESOURCES

232   Documentation
233       Definitions
234
235       Internationalization and localization
236           <http://en.wikipedia.org/wiki/Internationalization_and_localization>
237
238       Locale
239           <http://en.wikipedia.org/wiki/Locale>
240
241       Byte Order Mark (BOM)
242           <http://en.wikipedia.org/wiki/Byte_Order_Mark>
243
244       Character encoding
245           <http://en.wikipedia.org/wiki/Character_encoding>
246
247       Collation
248           <http://en.wikipedia.org/wiki/Collation>
249
250       Content Negotiation
251           <http://en.wikipedia.org/wiki/Content_Negotiation>
252
253       Unicode
254           <http://en.wikipedia.org/wiki/Unicode>
255
256       Guides
257
258       Guidelines, Checklists, and Resources
259           <http://www.i18nguy.com/guidelines.html>
260
261       Localisation Guide
262           <http://translate.sourceforge.net/wiki/guide/start>
263
264       Perl
265
266       Perl Locale handling
267           <http://search.cpan.org/dist/perl/pod/perllocale.pod>
268
269       Perl Unicode introduction
270           <http://search.cpan.org/dist/perl/pod/perluniintro.pod>
271
272       Perl Unicode support
273           <http://search.cpan.org/dist/perl/pod/perlunicode.pod>
274
275       Unicode-processing issues in Perl and how to cope with it
276           <http://www.ahinea.com/en/tech/perl-unicode-struggle.html>
277
278       Web Localization in Perl
279           <http://search.cpan.org/dist/Locale-Maketext-Lexicon/docs/webl10n.html>
280
281       Localization and Perl: gettext breaks, Maketext fixes
282           <http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod>
283
284       Lessons Learned with Perl and UTF-8
285           <http://www.justatheory.com/computers/programming/perl/utf8_trials.html>
286
287       UTF-8 and Perl (In Five Minutes)
288           Slides from a talk given by Mark Fowler.
289
290           <http://www.twoshortplanks.com/talks/utf8/perlandutf8.pdf>
291
292       Perl Loves UTF-8
293           Slides from a talk given by Tom Insam.
294
295           <http://jerakeen.org/slush/talk-perl-loves-utf8>
296
297       Perl I18N Mailing List
298           <http://lists.cpan.org/showlist.cgi?name=perl-i18n>
299
300       Perl Unicode Mailing List
301           <http://lists.cpan.org/showlist.cgi?name=perl-unicode>
302
303       Portals
304
305       Google Directory - Computers > Software > Globalization
306           <http://www.google.com/Top/Computers/Software/Globalization/>
307
308       Internationalization (I18N), Localization (L10N), Standards, and
309       Amusements
310           <http://www.i18nguy.com/>
311
312       Standards
313
314       RFC 2616 Hypertext Transfer Protocol -- HTTP/1.1
315           <http://www.w3.org/Protocols/rfc2616/rfc2616.html>
316
317           Section 12: Content Negotiation
318                   <http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html#sec12>
319
320           Section 13: Caching in HTTP
321                   <http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13>
322
323           Section 13.6: Caching Negotiated Responses
324                   <http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.6>
325
326       RFC 3066 Tags for the Identification of Languages
327           <http://www.faqs.org/rfcs/rfc3066.html>
328
329       Web
330
331       W3C Internationalization (I18N) Activity
332           <http://www.w3.org/International/>
333
334       Authoring Techniques for XHTML & HTML Internationalization: Characters
335       and Encodings 1.0
336           <http://www.w3.org/TR/i18n-html-tech-char/>
337
338       Authoring Techniques for XHTML & HTML Internationalization: Specifying
339       the language of content 1.0
340           <http://www.w3.org/TR/i18n-html-tech-lang/>
341
342   Locale Repositories
343       Common Locale Data Repository (CLDR)
344           <http://www.unicode.org/cldr/>
345
346       International Components for Unicode (ICU)
347           <http://www-306.ibm.com/software/globalization/icu/index.jsp>
348
349   Modules
350       Character Encoding, Collation and Normalization
351
352       Encode
353           <http://search.cpan.org/dist/Encode/>
354
355       Unicode::Collate
356           <http://search.cpan.org/dist/Unicode-Collate/>
357
358       Unicode::Normalize
359           <http://search.cpan.org/dist/Unicode-Normalize/>
360
361       Currency
362
363       Locale::Currency::Format
364           <http://search.cpan.org/dist/Locale-Currency-Format/>
365
366       Math::Currency
367           <http://search.cpan.org/dist/Math-Currency/>
368
369       Dates
370
371       DateTime
372           <http://search.cpan.org/dist/DateTime/>
373
374       DateTime::Locale
375           <http://search.cpan.org/dist/DateTime-Locale/>
376
377       DateTime::TimeZone
378           <http://search.cpan.org/dist/DateTime-TimeZone/>
379
380       Language Tags, Identification and Negotiation
381
382       HTTP::Negotiate
383           <http://search.cpan.org/dist/libwww-perl/lib/HTTP/Negotiate.pm>
384
385       I18N::AcceptLanguage
386           <http://search.cpan.org/dist/I18N-AcceptLanguage/>
387
388       I18N::LangTags
389           <http://search.cpan.org/dist/I18N-LangTags/>
390
391           <http://search.cpan.org/dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm>
392
393       Message Catalogs
394
395       Locale::Maketext
396           <http://search.cpan.org/dist/Locale-Maketext/>
397
398           <http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod>
399
400       Locale::Maketext::Lexicon
401           <http://search.cpan.org/dist/Locale-Maketext-Lexicon/>
402
403           <http://search.cpan.org/dist/Locale-Maketext-Lexicon/docs/webl10n.html>
404
405           <http://search.cpan.org/dist/Locale-Maketext-Lexicon/script/xgettext.pl>
406
407       Locale::Maketext::Simple
408           Provides a simple interface to Locale::Maketext::Lexicon.
409
410           <http://search.cpan.org/dist/Locale-Maketext-Simple/>
411
412       libintl-perl
413           <http://search.cpan.org/dist/libintl-perl/lib/Locale/Messages.pm>
414
415           <http://search.cpan.org/dist/libintl-perl/lib/Locale/TextDomain.pm>
416
417       Numbers
418
419       Number::Format
420           <http://search.cpan.org/dist/Number-Format/>
421
422   Tools
423       GNU gettext utilities
424           <http://www.gnu.org/software/gettext/>
425
426           <http://www.gnu.org/software/gettext/manual/html_chapter/gettext.html>
427
428           <http://gnuwin32.sourceforge.net/packages/gettext.htm>
429
430       gtranslator
431           Translation tool for Gnome. Supports gettext catalogs.
432
433           <http://gtranslator.sourceforge.net/>
434
435       Ini Translator
436           Translation tool for Windows 98/Me/XP/2000. Supports several
437           formats, including gettext catalogs.
438
439           <http://initranslator.sourceforge.net/>
440
441       KBabel
442           Translation tool for KDE. Supports gettext catalogs.
443
444           <http://i18n.kde.org/tools/kbabel/>
445
446       LocFactory Editor
447           Translation tool for Mac OS X. Supports sevral formats, including
448           gettext catalogs.
449
450           <http://www.triplespin.com/en/products/locfactoryeditor.html>
451
452       poEdit
453           A cross-platform gettext catalogs editor.
454
455           <http://www.poedit.org/>
456

AUTHOR

458       Christian Hansen "ch@ngmedia.com"
459
461       This program is free software, you can redistribute it and/or modify it
462       under the same terms as Perl itself.
463
464
465
466perl v5.34.0                      2021-07-22 Catalyst::Plugin::I18N::Manual(3)
Impressum