=head1 NAME CGI::Application::Plugin::I18N::Guide - Understanding and using I18N and L10N =head1 BACKGROUND I'm writing this guide for people who find themselves in the position I did. You code Perl CGI scripts, you want to make your scripts more open to other countries, and thus other languages. How is this done? Well after much research this is best done properly, do B be tempted to have a big list or variables or a large hash that you replace based on the users language. This B quickly break and do nothing more than to annoy people including yourself. Have a read through this guide. If you are completely new to Internationalization then you'll find this guide and it's resources useful even if you aren't using CGI::Application. =head1 WHERE TO START? Internationalization of your application or I18N for short, means making your application language packable. So that Localization (L10N) can be done for the end user. Depending on the language your are localizing to, these language packs can become complicated. If you are unfamiliar with the structures of other languages you'll probably be surprised (as I was) as to just how much things can differ, not just in alphabet and sentence structure, but culture, what's exceptable, varying degrees of quantifiers, not to mention currency formats! I don't want to re-write all the stuff that's been covered before. So before you continue on this guide, catch up your reading on the following resources. B =head2 Things to read This is the order I recommend:- We'll start with what's pretty mcuh the current standard for localization: Gettext, I'd only read to section 1.5, but feel free to read more if you are so inclined. L This'll cover some of the issues and ideas with the differences between languages and some ways around them. L These two links will help you understand language tags. L L UTF-8, you need to understand what this is and why it's used. L You also need to understand the difference between UTF-8 and Perl's internal format. L It's well worth reading Audreys guide. L Basics bits like yes/no, etc, are provided by:- L Getting deeping into the nitty gritty. L L And finally:- L Now you should have all the background info you need to understand how the L module works. =head2 Other useful resources The I18N Catalyst plugin as a Manual page that is full of useful links:- L =head1 Creating .po and .mo files The .po files are the editable language packs. The .mo files are compiled versions that are a bit faster to use. I've found a good little app for creating .po and .mo files:- L It's cross platform and gives you a nice GUI to work from. Of course you can always edit the .po files direct and generate the .mo files yourself. =head2 Getting the sample files This module includes some sample files in the folder sample/poedit. It's a tiny CGI::Application script designed to get you used to using and editing .po files. You'll need to copy this folder to your webservers public folder. It's safe to do this by FTP is you are stuck on shared hosting. Or you can test locally, just copy the folder to your public_html, httpdocs, wwwroot, etc. Depending on your servers configuration you might have to put this in the cgi-bin. For the sake of simplicity the rest of this guide refers to this folder as /tmp/potest. =head2 Using Poedit Download and install Poedit. When you open for the first time it'll ask for your name and email, don't worry this is just for stamping the .po files with your details. Click the I menu, then I and select the I tab. You'll see that there is a Perl parser, select this and then click the I button. You'll see that the list of file extensions only has I<*.pl>, extend this so that is contains I<*.pl;*.pm;*.cgi> and any other extensions you use for your applications Perl files. Click I and I again. Now we are ready to create our first catalog. Click INew catalog>. The details I entered:- Project name: Demo Team: po testers Team email: not@now.com Language: English Country: United States Charset: UTF-8 Source code charset: UTF-8 Then select the I tab, click the little square graphic for I then input the path to your script files, I've done /tmp/potest Then select the I tab and add I the same way you added the path. Click I to finish, a dialog will ask you where to save your .po file. I selected /tmp/potest/I18N/en-us.po. You should get a window titled I appear with a list of 4 new strings. Click I. If we added another localtext field to the potest example then all we need do is click on the globe icon at the top and it'd parse the files again for new strings. For this example, click on the I string, in the box at the bottom type I. Now click the save icon. The .mo compiled version of this file is generated automatically on each save. =head2 Testing your demo .po file Ok, now we are ready to test out your .po file and see it in action. Use your browser to open the script potest.cgi. I'm testing locally on my Vista IIS7. So /tmp/potest for me is actually c:\inetpub\wwwroot\cgi-bin\potest, I'll be opening http://localhost/cgi-bin/potest/potest.cgi in my browser. You'll get a very basic HTML form asking for a locale, and showing small bits of localized text (I do plan on an advanced version at some point). Enter in I and hit submit. You'll see all that has changed is I. Finally I wont have Americans moaning about how they can't spell colour or cheque properly :P If you enter in de then you'll get a german example that I've created as an example of a more complete language pack (although my German is minimal, I used babelfish to translate parts so it probably isn't structured correctly). =head1 Quantifiers I haven't used these yet... Stay tuned :) =cut