File: Manual.pod

package info (click to toggle)
libcatalyst-plugin-i18n-perl 0.10-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 232 kB
  • sloc: perl: 2,137; makefile: 2
file content (590 lines) | stat: -rw-r--r-- 15,152 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
=encoding UTF-8

=head1 NAME

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

=head1 OUTLINE

    Prerequisites:
     - perl >= 5.8.0
     - Catalyst >= 5.33
     - Catalyst::Plugin::I18N >= 0.04
     - Catalyst::Plugin::Unicode >= 0.2
     - Catlayst::View::TT && Template-Toolkit >= 2.14
     - GNU gettext utilities
     - An editor that understands UTF-8 and Byte Order Mark (BOM)

    $ catalyst.pl MyApp
    created "MyApp"
    created "MyApp/script"
    created "MyApp/lib"
    created "MyApp/root"
    created "MyApp/root/static"
    created "MyApp/root/static/images"
    created "MyApp/t"
    created "MyApp/lib/MyApp"
    created "MyApp/lib/MyApp/Model"
    created "MyApp/lib/MyApp/View"
    created "MyApp/lib/MyApp/Controller"
    created "MyApp/lib/MyApp.pm"
    created "MyApp/Makefile.PL"
    created "MyApp/README"
    created "MyApp/Changes"
    created "MyApp/t/01app.t"
    created "MyApp/t/02pod.t"
    created "MyApp/t/03podcoverage.t"
    created "MyApp/root/static/images/catalyst_logo.png"
    created "MyApp/root/static/images/btn_120x50_built.png"
    created "MyApp/root/static/images/btn_120x50_built_shadow.png"
    created "MyApp/root/static/images/btn_120x50_powered.png"
    created "MyApp/root/static/images/btn_120x50_powered_shadow.png"
    created "MyApp/root/static/images/btn_88x31_built.png"
    created "MyApp/root/static/images/btn_88x31_built_shadow.png"
    created "MyApp/root/static/images/btn_88x31_powered.png"
    created "MyApp/root/static/images/btn_88x31_powered_shadow.png"
    created "MyApp/root/favicon.ico"
    created "MyApp/script/myapp_cgi.pl"
    created "MyApp/script/myapp_fastcgi.pl"
    created "MyApp/script/myapp_server.pl"
    created "MyApp/script/myapp_test.pl"
    created "MyApp/script/myapp_create.pl"

    $ cd MyApp
    $ vim lib/MyApp.pm

    use Catalyst qw/-Debug I18N Unicode/;
    
    sub begin : Private {
        my ( $self, $c ) = @_;
        
        my $locale = $c->request->param('locale');
        
        $c->response->headers->push_header( 'Vary' => 'Accept-Language' );  # hmm vary and param?
        $c->languages( $locale ? [ $locale ] : undef );
    }

    sub default : Private {
        my ( $self, $c ) = @_;

        my $name = $c->request->param('name') || $c->loc('Guest');

        $c->response->content_type('text/plain; charset=utf-8');
        $c->response->body( $c->loc( 'Welcome [_1]!', $name ) );
    }

    $ mkdir lib/MyApp/I18N
    $ xgettext.pl --output=lib/MyApp/I18N/messages.pot --directory=lib/
    $ ls lib/MyApp/I18N/
    messages.pot

    $ msginit --input=lib/MyApp/I18N/messages.pot --output=lib/MyApp/I18N/sv.po --locale=sv
    Created lib/MyApp/I18N/sv.po.

    $ vim lib/MyApp/I18N/sv.po

    "Content-Type: text/plain; charset=utf-8\n"

    #: lib/MyApp.pm:50
    msgid "Guest"
    msgstr "Gäst"

    #. ($name)
    #: lib/MyApp.pm:54
    msgid "Welcome %1!"
    msgstr "Välkommen %1!"

    $ perl script/myapp_server.pl
    [Fri Dec  2 03:52:45 2005] [catalyst] [debug] Debug messages enabled
    [Fri Dec  2 03:52:47 2005] [catalyst] [debug] Loaded plugins:
    .------------------------------------------------------------------------------.
    | Catalyst::Plugin::I18N                                                       |
    | Catalyst::Plugin::Unicode                                                    |
    '------------------------------------------------------------------------------'

    [Fri Dec  2 03:52:47 2005] [catalyst] [debug] Loaded dispatcher "Catalyst::Dispatcher"
    [Fri Dec  2 03:52:47 2005] [catalyst] [debug] Loaded engine "Catalyst::Engine::HTTP"
    [Fri Dec  2 03:52:47 2005] [catalyst] [debug] Found home "/Users/chansen/MyApp"
    [Fri Dec  2 03:52:48 2005] [catalyst] [debug] Initialized i18n "MyApp::I18N"
    [Fri Dec  2 03:52:48 2005] [catalyst] [debug] Loaded Private actions:
    .----------------------+----------------------------------------+--------------.
    | Private              | Class                                  | Method       |
    +----------------------+----------------------------------------+--------------+
    | /default             | MyApp                                  | default      |
    '----------------------+----------------------------------------+--------------'

    [Fri Dec  2 03:52:48 2005] [catalyst] [info] MyApp powered by Catalyst 5.57
    You can connect to your server at http://localhost:3000

    # point your browser to http://localhost:3000/?name=Joe
    # output should render:

    Välkommen Joe!

    $ vim lib/MyApp.pm

    sub default : Private {

        # ...

        $c->response->body( $c->loc( 'Welcome to my homepage [_1]!', $name ) );
    }
    
    $ xgettext.pl --output=lib/MyApp/I18N/messages.pot --directory=lib/
    $ msgmerge --update lib/MyApp/I18N/sv.po lib/MyApp/I18N/messages.pot
    . done.

    $ vim lib/MyApp/I18N/sv.po

    #. ($name)
    #: lib/MyApp.pm:54
    msgid "Welcome to my homepage %1!"
    msgstr "Välkommen till min hemsida %1!"

    $ perl script/myapp_server.pl

    # point your browser to http://localhost:3000/?name=Joe
    # output should render:

    Välkommen till min hemsida Joe!

    $ perl script/myapp_create.pl view TT TT
     exists "/Users/chansen/MyApp/script/../lib/MyApp/View"
     exists "/Users/chansen/MyApp/script/../t"
    created "/Users/chansen/MyApp/script/../lib/MyApp/View/TT.pm"
    created "/Users/chansen/MyApp/script/../t/view_TT.t"
    
    $ vim lib/MyApp.pm

    sub default : Private {
        my ( $self, $c ) = @_;

        my $name = $c->request->param('name') || $c->loc('Guest');

        $c->response->content_type('text/plain; charset=utf-8');
        $c->stash(
            name     => $name,
            template => 'test.tt' 
        );
        
        $c->forward('MyApp::View::TT');
    }

    $ vim root/test.tt # Save file in UTF-8 with BOM
    
    [% c.loc( 'Welcome to my place [_1]!', c.stash.name ) %]
    
    $ xgettext.pl --output=lib/MyApp/I18N/messages.pot --directory=lib/ --directory=root/
    $ msgmerge --update lib/MyApp/I18N/sv.po lib/MyApp/I18N/messages.pot
    . done.    
    
    $ vim lib/MyApp/I18N/sv.po

    #. (c.stash.name)
    #: root/test.tt:1
    msgid "Welcome to my place %1!"
    msgstr "Välkommen till mitt ställe %1!"
    
    $ perl script/myapp_server.pl 
    [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Debug messages enabled
    [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Loaded plugins:
    .------------------------------------------------------------------------------.
    | Catalyst::Plugin::I18N                                                       |
    | Catalyst::Plugin::Unicode                                                    |
    '------------------------------------------------------------------------------'

    [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Loaded dispatcher "Catalyst::Dispatcher"
    [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Loaded engine "Catalyst::Engine::HTTP"
    [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Found home "/Users/chansen/MyApp"
    [Fri Dec  2 05:12:58 2005] [catalyst] [debug] Initialized i18n "MyApp::I18N"
    [Fri Dec  2 05:12:59 2005] [catalyst] [debug] Loaded components:
    .-------------------------------------------------------------------+----------.
    | Class                                                             | Type     |
    +-------------------------------------------------------------------+----------+
    | MyApp::View::TT                                                   | instance |
    '-------------------------------------------------------------------+----------'

    [Fri Dec  2 05:12:59 2005] [catalyst] [debug] Loaded Private actions:
    .----------------------+----------------------------------------+--------------.
    | Private              | Class                                  | Method       |
    +----------------------+----------------------------------------+--------------+
    | /default             | MyApp                                  | default      |
    '----------------------+----------------------------------------+--------------'

    [Fri Dec  2 05:12:59 2005] [catalyst] [info] MyApp powered by Catalyst 5.57
    You can connect to your server at http://localhost:3000
    
    # point your browser to http://localhost:3000/?name=Joe
    # output should render:

    Välkommen till mitt ställe Joe!   
    

=head1 INTRODUCTION

=head1 INTERNATIONALIZATION

=head1 CONTENT NEGOTIATION

=head2 Server-driven

=head2 Agent-driven

=head1 LOCALIZATION

=head1 STAYING IN SYNC

=head1 TEMPLATE TOOLKIT

=head1 RESOURCES

=head2 Documentation

=head3 Definitions

=over 4

=item Internationalization and localization

L<http://en.wikipedia.org/wiki/Internationalization_and_localization>

=item Locale

L<http://en.wikipedia.org/wiki/Locale>

=item Byte Order Mark (BOM)

L<http://en.wikipedia.org/wiki/Byte_Order_Mark>

=item Character encoding

L<http://en.wikipedia.org/wiki/Character_encoding>

=item Collation

L<http://en.wikipedia.org/wiki/Collation>

=item Content Negotiation

L<http://en.wikipedia.org/wiki/Content_Negotiation>

=item Unicode

L<http://en.wikipedia.org/wiki/Unicode>

=back

=head3 Guides

=over 4

=item Guidelines, Checklists, and Resources

L<http://www.i18nguy.com/guidelines.html>

=item Localisation Guide

L<http://translate.sourceforge.net/wiki/guide/start>

=back

=head3 Perl

=over 4

=item Perl Locale handling

L<http://search.cpan.org/dist/perl/pod/perllocale.pod>

=item Perl Unicode introduction

L<http://search.cpan.org/dist/perl/pod/perluniintro.pod>

=item Perl Unicode support

L<http://search.cpan.org/dist/perl/pod/perlunicode.pod>

=item Unicode-processing issues in Perl and how to cope with it

L<http://www.ahinea.com/en/tech/perl-unicode-struggle.html>

=item Web Localization in Perl

L<http://search.cpan.org/dist/Locale-Maketext-Lexicon/docs/webl10n.html>

=item Localization and Perl: gettext breaks, Maketext fixes

L<http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod>

=item Lessons Learned with Perl and UTF-8

L<http://www.justatheory.com/computers/programming/perl/utf8_trials.html>

=item UTF-8 and Perl (In Five Minutes)

Slides from a talk given by Mark Fowler.

L<http://www.twoshortplanks.com/talks/utf8/perlandutf8.pdf>

=item Perl Loves UTF-8

Slides from a talk given by Tom Insam.

L<http://jerakeen.org/slush/talk-perl-loves-utf8>

=item Perl I18N Mailing List

L<http://lists.cpan.org/showlist.cgi?name=perl-i18n>

=item Perl Unicode Mailing List

L<http://lists.cpan.org/showlist.cgi?name=perl-unicode>

=back

=head3 Portals

=over 4

=item Google Directory - Computers > Software > Globalization

L<http://www.google.com/Top/Computers/Software/Globalization/>

=item Internationalization (I18N), Localization (L10N), Standards, and Amusements

L<http://www.i18nguy.com/>

=back

=head3 Standards

=over 4

=item RFC 2616 Hypertext Transfer Protocol -- HTTP/1.1

L<http://www.w3.org/Protocols/rfc2616/rfc2616.html>

=over 8

=item Section 12: Content Negotiation

L<http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html#sec12>

=item Section 13: Caching in HTTP

L<http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13>

=item Section 13.6: Caching Negotiated Responses

L<http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.6>

=back

=item RFC 3066 Tags for the Identification of Languages

L<http://www.faqs.org/rfcs/rfc3066.html>

=back

=head3 Web

=over 4

=item W3C Internationalization (I18N) Activity

L<http://www.w3.org/International/>

=item Authoring Techniques for XHTML & HTML Internationalization: Characters and Encodings 1.0

L<http://www.w3.org/TR/i18n-html-tech-char/>

=item Authoring Techniques for XHTML & HTML Internationalization: Specifying the language of content 1.0

L<http://www.w3.org/TR/i18n-html-tech-lang/>

=back

=head2 Locale Repositories

=over 4

=item Common Locale Data Repository (CLDR)

L<http://www.unicode.org/cldr/>

=item International Components for Unicode (ICU)

L<http://www-306.ibm.com/software/globalization/icu/index.jsp>

=back

=head2 Modules

=head3 Character Encoding, Collation and Normalization

=over 4

=item Encode

L<http://search.cpan.org/dist/Encode/>

=item Unicode::Collate

L<http://search.cpan.org/dist/Unicode-Collate/>

=item Unicode::Normalize

L<http://search.cpan.org/dist/Unicode-Normalize/>

=back

=head3 Currency

=over 4

=item Locale::Currency::Format

L<http://search.cpan.org/dist/Locale-Currency-Format/>

=item Math::Currency

L<http://search.cpan.org/dist/Math-Currency/>

=back

=head3 Dates

=over 4

=item DateTime

L<http://search.cpan.org/dist/DateTime/>

=item DateTime::Locale

L<http://search.cpan.org/dist/DateTime-Locale/>

=item DateTime::TimeZone

L<http://search.cpan.org/dist/DateTime-TimeZone/>

=back

=head3 Language Tags, Identification and Negotiation

=over 4

=item HTTP::Negotiate

L<http://search.cpan.org/dist/libwww-perl/lib/HTTP/Negotiate.pm>

=item I18N::AcceptLanguage

L<http://search.cpan.org/dist/I18N-AcceptLanguage/>

=item I18N::LangTags

L<http://search.cpan.org/dist/I18N-LangTags/>

L<http://search.cpan.org/dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm>

=back

=head3 Message Catalogs

=over 4

=item Locale::Maketext

L<http://search.cpan.org/dist/Locale-Maketext/>

L<http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod>

=item Locale::Maketext::Lexicon

L<http://search.cpan.org/dist/Locale-Maketext-Lexicon/>

L<http://search.cpan.org/dist/Locale-Maketext-Lexicon/docs/webl10n.html>

L<http://search.cpan.org/dist/Locale-Maketext-Lexicon/script/xgettext.pl>

=item Locale::Maketext::Simple

Provides a simple interface to Locale::Maketext::Lexicon.

L<http://search.cpan.org/dist/Locale-Maketext-Simple/>

=item libintl-perl

L<http://search.cpan.org/dist/libintl-perl/lib/Locale/Messages.pm>

L<http://search.cpan.org/dist/libintl-perl/lib/Locale/TextDomain.pm>

=back

=head3 Numbers

=over 4

=item Number::Format

L<http://search.cpan.org/dist/Number-Format/>

=back

=head2 Tools

=over 4 

=item GNU gettext utilities

L<http://www.gnu.org/software/gettext/>

L<http://www.gnu.org/software/gettext/manual/html_chapter/gettext.html>

L<http://gnuwin32.sourceforge.net/packages/gettext.htm>

=item gtranslator

Translation tool for Gnome. Supports gettext catalogs.

L<http://gtranslator.sourceforge.net/>

=item Ini Translator

Translation tool for Windows 98/Me/XP/2000. Supports several formats, 
including gettext catalogs.

L<http://initranslator.sourceforge.net/>

=item KBabel

Translation tool for KDE. Supports gettext catalogs.

L<http://i18n.kde.org/tools/kbabel/>

=item LocFactory Editor

Translation tool for Mac OS X. Supports sevral formats, including gettext
catalogs.

L<http://www.triplespin.com/en/products/locfactoryeditor.html>

=item poEdit

A cross-platform gettext catalogs editor.

L<http://www.poedit.org/>

=back

=head1 AUTHOR

Christian Hansen C<ch@ngmedia.com>

=head1 COPYRIGHT

This program is free software, you can redistribute it and/or modify 
it under the same terms as Perl itself.

=cut