Difference between revisions of "Instructions for creating language template files"

From WeBWorK_wiki
Jump to navigation Jump to search
(Added instructions for updating the POT file)
(Added instructions for updating from other POT files)
Line 42: Line 42:
   
 
Updating the POT file when you update you .pm source files is easy: simply make sure the updated .pm files are in the same directory as the POT file or in a sub-directory (and make sure that they are the only kinds of files in the directory or sub-directories, aside from the POT file), open up the POT file in POedit, and hit the 'Update Catalog' button, which will the 3rd button from the left at the top of the application. This will make POedit go through all the files again in the directory and sub-directories and pull out the translatable strings. Any new strings will be added to the POT file, while any strings that no longer appear in the .pm files will be removed.
 
Updating the POT file when you update you .pm source files is easy: simply make sure the updated .pm files are in the same directory as the POT file or in a sub-directory (and make sure that they are the only kinds of files in the directory or sub-directories, aside from the POT file), open up the POT file in POedit, and hit the 'Update Catalog' button, which will the 3rd button from the left at the top of the application. This will make POedit go through all the files again in the directory and sub-directories and pull out the translatable strings. Any new strings will be added to the POT file, while any strings that no longer appear in the .pm files will be removed.
  +
  +
  +
----
  +
  +
  +
'''Updating from other POT files'''
  +
  +
Another option for updating POT files is to update them strings for other POT files. To do this, go to Catalog-->Update from POT file, which will open up your document explorer. Choose the POT file you wish to update from, and POedit will go through all of the strings in the chosen POT file, adding new ones to the POT file currently opened in POedit and deleting obsolete strings (strings which are not found in the new POT file). Note that you may use this method to update both POT and ordinary PO files, as they both use the same format.
   
   

Revision as of 16:33, 25 January 2012

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.




Updating the POT file

Updating the POT file when you update you .pm source files is easy: simply make sure the updated .pm files are in the same directory as the POT file or in a sub-directory (and make sure that they are the only kinds of files in the directory or sub-directories, aside from the POT file), open up the POT file in POedit, and hit the 'Update Catalog' button, which will the 3rd button from the left at the top of the application. This will make POedit go through all the files again in the directory and sub-directories and pull out the translatable strings. Any new strings will be added to the POT file, while any strings that no longer appear in the .pm files will be removed.




Updating from other POT files

Another option for updating POT files is to update them strings for other POT files. To do this, go to Catalog-->Update from POT file, which will open up your document explorer. Choose the POT file you wish to update from, and POedit will go through all of the strings in the chosen POT file, adding new ones to the POT file currently opened in POedit and deleting obsolete strings (strings which are not found in the new POT file). Note that you may use this method to update both POT and ordinary PO files, as they both use the same format.



Other useful development files: