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 "Gaest"
92
93           #. ($name)
94           #: lib/MyApp.pm:54
95           msgid "Welcome %1!"
96           msgstr "Vaelkommen %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           Vaelkommen 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 "Vaelkommen 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           Vaelkommen 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 "Vaelkommen till mitt staelle %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           Vaelkommen till mitt staelle 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           <http://www.ahinea.com/en/tech/perl-unicode-struggle.html>
278
279       Web Localization in Perl
280           http://search.cpan.org/dist/Locale-Maketext-Lexicon/docs/webl10n.html
281           <http://search.cpan.org/dist/Locale-Maketext-
282           Lexicon/docs/webl10n.html>
283
284       Localization and Perl: gettext breaks, Maketext fixes
285           http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod
286           <http://search.cpan.org/dist/Locale-
287           Maketext/lib/Locale/Maketext/TPJ13.pod>
288
289       Lessons Learned with Perl and UTF-8
290           <http://www.justatheory.com/computers/programming/perl/utf8_trials.html>
291
292       UTF-8 and Perl (In Five Minutes)
293           Slides from a talk given by Mark Fowler.
294
295           <http://www.twoshortplanks.com/talks/utf8/perlandutf8.pdf>
296
297       Perl Loves UTF-8
298           Slides from a talk given by Tom Insam.
299
300           http://jerakeen.org/slush/talk-perl-loves-utf8
301           <http://jerakeen.org/slush/talk-perl-loves-utf8>
302
303       Perl I18N Mailing List
304           http://lists.cpan.org/showlist.cgi?name=perl-i18n
305           <http://lists.cpan.org/showlist.cgi?name=perl-i18n>
306
307       Perl Unicode Mailing List
308           http://lists.cpan.org/showlist.cgi?name=perl-unicode
309           <http://lists.cpan.org/showlist.cgi?name=perl-unicode>
310
311       Portals
312
313       Google Directory - Computers > Software > Globalization
314           <http://www.google.com/Top/Computers/Software/Globalization/>
315
316       Internationalization (I18N), Localization (L10N), Standards, and
317       Amusements
318           <http://www.i18nguy.com/>
319
320       Standards
321
322       RFC 2616 Hypertext Transfer Protocol -- HTTP/1.1
323           <http://www.w3.org/Protocols/rfc2616/rfc2616.html>
324
325           Section 12: Content Negotiation
326                   http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html#sec12
327                   <http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html#sec12>
328
329           Section 13: Caching in HTTP
330                   http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13
331                   <http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13>
332
333           Section 13.6: Caching Negotiated Responses
334                   http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.6
335                   <http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.6>
336
337       RFC 3066 Tags for the Identification of Languages
338           <http://www.faqs.org/rfcs/rfc3066.html>
339
340       Web
341
342       W3C Internationalization (I18N) Activity
343           <http://www.w3.org/International/>
344
345       Authoring Techniques for XHTML & HTML Internationalization: Characters
346       and Encodings 1.0
347           http://www.w3.org/TR/i18n-html-tech-char/
348           <http://www.w3.org/TR/i18n-html-tech-char/>
349
350       Authoring Techniques for XHTML & HTML Internationalization: Specifying
351       the language of content 1.0
352           http://www.w3.org/TR/i18n-html-tech-lang/
353           <http://www.w3.org/TR/i18n-html-tech-lang/>
354
355   Locale Repositories
356       Common Locale Data Repository (CLDR)
357           <http://www.unicode.org/cldr/>
358
359       International Components for Unicode (ICU)
360           http://www-306.ibm.com/software/globalization/icu/index.jsp
361           <http://www-306.ibm.com/software/globalization/icu/index.jsp>
362
363   Modules
364       Character Encoding, Collation and Normalization
365
366       Encode
367           <http://search.cpan.org/dist/Encode/>
368
369       Unicode::Collate
370           http://search.cpan.org/dist/Unicode-Collate/
371           <http://search.cpan.org/dist/Unicode-Collate/>
372
373       Unicode::Normalize
374           http://search.cpan.org/dist/Unicode-Normalize/
375           <http://search.cpan.org/dist/Unicode-Normalize/>
376
377       Currency
378
379       Locale::Currency::Format
380           http://search.cpan.org/dist/Locale-Currency-Format/
381           <http://search.cpan.org/dist/Locale-Currency-Format/>
382
383       Math::Currency
384           http://search.cpan.org/dist/Math-Currency/
385           <http://search.cpan.org/dist/Math-Currency/>
386
387       Dates
388
389       DateTime
390           <http://search.cpan.org/dist/DateTime/>
391
392       DateTime::Locale
393           http://search.cpan.org/dist/DateTime-Locale/
394           <http://search.cpan.org/dist/DateTime-Locale/>
395
396       DateTime::TimeZone
397           http://search.cpan.org/dist/DateTime-TimeZone/
398           <http://search.cpan.org/dist/DateTime-TimeZone/>
399
400       Language Tags, Identification and Negotiation
401
402       HTTP::Negotiate
403           http://search.cpan.org/dist/libwww-perl/lib/HTTP/Negotiate.pm
404           <http://search.cpan.org/dist/libwww-perl/lib/HTTP/Negotiate.pm>
405
406       I18N::AcceptLanguage
407           http://search.cpan.org/dist/I18N-AcceptLanguage/
408           <http://search.cpan.org/dist/I18N-AcceptLanguage/>
409
410       I18N::LangTags
411           http://search.cpan.org/dist/I18N-LangTags/
412           <http://search.cpan.org/dist/I18N-LangTags/>
413
414           http://search.cpan.org/dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm
415           <http://search.cpan.org/dist/I18N-
416           LangTags/lib/I18N/LangTags/Detect.pm>
417
418       Message Catalogs
419
420       Locale::Maketext
421           http://search.cpan.org/dist/Locale-Maketext/
422           <http://search.cpan.org/dist/Locale-Maketext/>
423
424           http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod
425           <http://search.cpan.org/dist/Locale-
426           Maketext/lib/Locale/Maketext/TPJ13.pod>
427
428       Locale::Maketext::Lexicon
429           http://search.cpan.org/dist/Locale-Maketext-Lexicon/
430           <http://search.cpan.org/dist/Locale-Maketext-Lexicon/>
431
432           http://search.cpan.org/dist/Locale-Maketext-Lexicon/docs/webl10n.html
433           <http://search.cpan.org/dist/Locale-Maketext-
434           Lexicon/docs/webl10n.html>
435
436           http://search.cpan.org/dist/Locale-Maketext-Lexicon/script/xgettext.pl
437           <http://search.cpan.org/dist/Locale-Maketext-
438           Lexicon/script/xgettext.pl>
439
440       Locale::Maketext::Simple
441           Provides a simple interface to Locale::Maketext::Lexicon.
442
443           http://search.cpan.org/dist/Locale-Maketext-Simple/
444           <http://search.cpan.org/dist/Locale-Maketext-Simple/>
445
446       libintl-perl
447           http://search.cpan.org/dist/libintl-perl/lib/Locale/Messages.pm
448           <http://search.cpan.org/dist/libintl-perl/lib/Locale/Messages.pm>
449
450           http://search.cpan.org/dist/libintl-perl/lib/Locale/TextDomain.pm
451           <http://search.cpan.org/dist/libintl-perl/lib/Locale/TextDomain.pm>
452
453       Numbers
454
455       Number::Format
456           http://search.cpan.org/dist/Number-Format/
457           <http://search.cpan.org/dist/Number-Format/>
458
459   Tools
460       GNU gettext utilities
461           <http://www.gnu.org/software/gettext/>
462
463           <http://www.gnu.org/software/gettext/manual/html_chapter/gettext.html>
464
465           <http://gnuwin32.sourceforge.net/packages/gettext.htm>
466
467       gtranslator
468           Translation tool for Gnome. Supports gettext catalogs.
469
470           <http://gtranslator.sourceforge.net/>
471
472       Ini Translator
473           Translation tool for Windows 98/Me/XP/2000. Supports several
474           formats, including gettext catalogs.
475
476           <http://initranslator.sourceforge.net/>
477
478       KBabel
479           Translation tool for KDE. Supports gettext catalogs.
480
481           <http://i18n.kde.org/tools/kbabel/>
482
483       LocFactory Editor
484           Translation tool for Mac OS X. Supports sevral formats, including
485           gettext catalogs.
486
487           <http://www.triplespin.com/en/products/locfactoryeditor.html>
488
489       poEdit
490           A cross-platform gettext catalogs editor.
491
492           <http://www.poedit.org/>
493

AUTHOR

495       Christian Hansen "ch@ngmedia.com"
496
498       This program is free software, you can redistribute it and/or modify it
499       under the same terms as Perl itself.
500
501
502
503perl v5.12.1                      2009-07-30 Catalyst::Plugin::I18N::Manual(3)
Impressum