Instructions for creating language template files

From WeBWorK_wiki
Revision as of 16:22, 23 January 2012 by Ghe3 (talk | contribs) (Adding instructions for creating POT file using POedit)
Jump to navigation Jump to search

Creating POT files using POedit

1. First, make sure you have POedit installed. You can download the application from http://www.poedit.net/download.php. There are versions for Windows, Mac OS, and Linux.

2. Make sure you have the correct settings: we want POedit to be able to read the .pm files that WeBWorK's content generator files uses.

  • To do this, open up POedit, then go to File --> Preferences. This will open up a new window.
  • Click on the Parsers tab in this window, and then select 'Perl' from the list the tab displays, and click 'Edit'. This will open up yet another window.
  • In the text area titled, "List of extensions separated by semicolons (e.g. *.cpp;*.h)", add, if it's not already there, the extension '*.pm' by typing it into the text area. As the title says, make sure you separate it from other extensions with a semicolon.
  • Click OK on both windows.

3. Now we are ready to create a POT file.

  • Before we begin, go to File --> Preferences again. This time, click on the Editors tab, and in the 'Behavior' section, uncheck the checkbox titled "Automatically compile .mo file on save". This will prevent POedit from creating useless .mo files when we create the POT file. Click OK once you are done.
  • Go to File --> New catalog. Do not use File --> New catalog from POT file -- this is something different. This will open up a new window.
  • On the 'Project Info' tab, you can fill out information about the POT file you are creating. The only thing really important here is to give it a name in the 'Project name and version' section, and that you make sure that both the 'Charset' and the 'Source code charset' sections are set to 'UTF-8' (this will be lower case for the 'Source code charset' section).
  • Click on the 'Paths' tab. Click on the second button from the left in the box, which should have a tooltip reading 'New item'. This will allow you to edit a line in the box below. Type '.' and hit the Enter key. This will tell POedit to look for translatable strings in the same directory as POT file when it is filled in.
  • Click on the 'Keywords' tab. Click on the 'New item' button in the box (again, second one from left). This will allow you to edit a line in the box below. Type 'maketext' and hit the Enter key. WeBWorK uses the 'maketext' function for most of its translations -- this will tell POedit to look for strings that are used by this function when it is filled in.
  • Once you are done with the steps above, click OK. This will open up your document viewer window, allowing to choose a location to save your POT file in. Make sure that it is in a directory which contains all of the files you want to translate (either directly in the directory or inside a directory contained in the directory) and nothing else except the files you want to translate. Name your POT file, change the file extension to '.pot', and save.

4. If all goes well and everything is in the right place, POedit should generate a POT file containing all of the translatable strings in the .pm files from the directory the POT file is in and all of its sub-directories. You will be able to view the translatable strings in POedit in the main box.

Other useful development files: