Translations for the Windows MFC version of PasswordSafe

The MFC Version of PasswordSafe has all its embedded resources in (US) English.  Some resources must remain in English (e.g. keywords for XML export/import, column headings for Text export/import and preferences in the configuration file, some HTML statements) but all others (e.g. menus and dialogs) can be changed to any other language – as long as someone is willing to do the translation!

As part of the build process, we create what is called a resource-only “Base DLL” that contains all the strings that should be translated.  This will change for every release as we add new features or change existing ones.  The TortoiseSVN project produced a program called “ResText” that enables these strings to be extracted from this Base DLL to a text file (a PO file), which can then be edited for a specific language and then applied back to this Base DLL to create a language specific set of strings.  We have both contributed to this Open Source program and slightly modified it for our use.

In addition, we have written our own program called “ResPWSL”, which updates the resulting new language specific resource-only DLL, so that it has information within it describing the particular language it supports.

For a language to be supported by PasswordSafe’s on-the-fly change of language new feature, both of these programs must be used and, in particular, V2.0 or later of the ResPWSL program.

Both ResText and ResPWSL can be downloaded from the “Translation” file area at http://sourceforge.net/projects/passwordsafe/files/Translation Tools for Windows (MFC) Version/

ResText

ResText extract <resource.dll> [<resource.dll> ...] <po-file> [-quiet] [-noupdate]
Extracts all strings from the resource only DLL and writes them to the specified po-file
-quiet:		don't print progress messages
-noupdate:	overwrite (rather than update) the specified po-file

ResText apply <src resource.dll> <dst resource.dll> <po-file> [langID] [-quiet] [-rtl] [-showdefault]
Uses the all strings in the source resource only DLL using the PO file translations to produce the destination resource only DLL.
-quiet:		don't print progress messages
-rtl:		change the controls to RTL reading
-showdefault:	print un-translated values to stderr

ResPWSL

ResPWSL list <resource.dll>
Lists the version information of a specified resource only DLL.

ResPWSL apply < resource.dll> LCID
Creates the resource-only DLL: pwsafeLL.dll or pwsafeLL_CC.dll from the supplied resource-only DLL.
It also changes the OriginalFilename and ProductName version strings to reflect the language and location.
The locale LCID value should be specified as "0xnnnn", as specified in the Windows XP section of http://www.microsoft.com/globaldev/nlsweb/default.mspx.  Using a LCID value "0xmmnn” where mm=00 will generate the pwsafeLL.dll version, whereas any other value will produce the corresponding pwsafeLL_CC.dll version.

For example 0x0007 produces pwsafeEN.dll and 0x0407 produces pwsafeEN_US.dll

Resource-Only Language DLL Build Instructions

In order to build the Resource-Only language DLLs, we use 4 files as described above.

1.	Input file "pwasafe_base.dll", which contains the current version of the strings embedded within the application.
2.	The language PO file - named "pwsafe_LL.po" or “pwsafe_LL_CC.po”, where LL is the 2-character language ID and LL_CC also has the country specific ID.
3.	The ResText program to create a language specific.
4.	The ResPWSL program to convert the last language specific DLL into one that can be used by PasswordSafe.

In order for you to create your own resource-only language DLL, you should put the "ResText.exe", "ResPWSL.exe" and the "pwsafe_base.dll" in a directory of your choice.  Open a Command window and change to this directory.
Simple Method

We have provided two simple scripts that automate the process of creating your translation of the PasswordSafe English strings shown in its menus, dialogs and messages.  They are in the zip file “simple_scripts.zip” in the “Translation” file area and are described below.
Create Updated PO files

To create an updated PO file from the current Base DLL, you should enter the following command into the Command Window you have opened above:

cscript UpdatePOs.vbs All
or
cscript UpdatePOs.vbs CC
or
cscript UpdatePOs.vbs /?

Where:
a.	Specifying ‘All’ will update any existing PO files in this directory with the latest updates to the strings in PasswordSafe for all currently supported countries.  If a PO file for a supported country does not exist, it will be created.
b.	Specifying ‘CC’ will update the existing PO file for this country code, e.g. DE for Germany, in this directory with the latest updates to the strings in PasswordSafe.  If a PO file for this country does not exist, it will be created.
c.	Specifying ‘/?’ will display how to use the script.

Messages from the ResText program will be written to a file ‘#Update_POs.log’ in this directory.  Information is appended to this file when the script is run.  You may wish to delete it between runs.
Create new language DLLs

To create a new language DLL from an updated PO file, you should enter the following command into the Command Window you have opened above:

cscript Create_DLLs.vbs All
or
cscript Create_DLLs.vbs CC
or
cscript Create_DLLs.vbs /?

Where:
a.	Specifying ‘All’ will create the language DLL files in this directory with the latest updates to the strings from the associated PO file for all currently supported countries.  If a PO file for a supported country does not exist, the corresponding DLL will not be created.
b.	Specifying ‘CC’ will create the language DLL files in this directory with the latest updates to the strings from the associated PO file for this country code, e.g. DE for Germany.  If a PO file for a supported country does not exist, the corresponding DLL will not be created.
c.	Specifying ‘/?’ will display how to use the script.

Messages from the ResText and ResPWSL programs, if any, will be written to a file ‘#Create_DLLs.log’ in this directory.  Information is appended to this file when the script is run.  You may wish to delete it between runs.
Method if you wish to “do it yourself”

The following command will create a new PO file for your language:

ResText extract pwsafe_base.dll pwsafe_LL.po
or
ResText extract pwsafe_base.dll pwsafe_LL_CC.po

If you copy your existing PO file into this directory and issue the same command, it will update this PO file with the new strings from a later Base DLL.  You may want to save a copy of original version of the PO file so that you can do a compare after running this command to highlight the differences.

Note: by updating an existing PO file, certain fields may be reset ("PO-Revision-Date” and "Last-Translator”).  If so, you may want to update them again.  Also, ResText may add an extra copy of the instructions for dealing with Accelerator keys near the beginning of the file and you may wish to remove the duplicates.

After updating your PO file to cater for new or changed translations, issue the following commands to produce a new language specific resource-only DLL:

ResText apply pwsafe_base.dll foo.dll pwsafe_LL.po
ResPWSL apply foo.dll LCID
delete foo.dll
rename pwsafeLL_CC.dll pwsafeLL.dll
or
ResText apply pwsafe_base.dll foo.dll pwsafe_LL_CC.po
ResPWSL apply foo.dll LCID
delete foo.dll

You should then copy the resulting pwsafeLL.dll or pwsafeLL_CC.dll file to the folder containing the PasswordSafe executable corresponding to the pwsafe_base.dll you used as input to ResText and ResPWSL.

The following are the values of LCID, LL_CC and LL for the currently supported languages.  You can find more at Windows XP version at:
http://www.microsoft.com/resources/msdn/goglobal/default.mspx:

	LCID	LL_CC	LL	
Chinese (Simplified)	0x0804	ZH_CN	ZH	
Danish	0x0406	DA_DK	DA	
Dutch	0x0413	NL_NL	NL	
French	0x040c	FR_FR	FR	
German	0x0407	DE_DE	DE	
Italian	0x0410	IT_IT	IT	
Korean	0x0412	KO_KR	KR	
Polish	0x0415	PL_PL	PL	
Russian	0x0419	RU_RU	RU	
Spanish	0x0c0a	ES_ES	ES	
Swedish	0x041d	SV_SE	SV	

So for example for Danish (to create the pwsafeDA.dll), the commands will be:

ResText apply pwsafe_base.dll foo.dll pwsafe_DA.po
ResPWSL apply foo.dll 0x0406
delete foo.dll
rename pwsafeDA_DK.dll pwsafeDA.dll

and for French (to create the pwsafeFR.dll), the commands will be:

ResText apply pwsafe_base.dll foo.dll pwsafe_FR.po
ResPWSL apply foo.dll 0x040c
delete foo.dll
rename pwsafeFR_FR.dll pwsafeFR.dll

The resulting language specific resource-only DLL should then be copied to the directory containing the PasswordSafe executable and it will be eligible for selection via the new “Manage → Change Language” menu item.

Whichever method you use, don’t forget to copy your newly created language DLL to the directory containing the PasswordSafe application file of the same major and minor version.  For example: both application and DLL have major version 3 and minor version 25.

Hints and Tips

The PO file has a number of entries at the beginning of the file that you should update as part of your translation effort.  They are:

"PO-Revision-Date” & "Last-Translator”.

Whether you put just your name in the translator field or also add your email address is your decision but you should bear in mind that this file will be visible on the internet.

Please follow the format of the original text.  For example, if there are leading spaces in the original, then there should be the same number in the translation e.g.

msgid " 'Notes'"
msgstr "'xyz'"

is incorrect, but

msgid " 'Notes'"
msgstr " 'xyz'"

is correct.

Do not remove any fields beginning ‘%’.  You must also have exactly the same number of these fields in exactly the same order as the original.  Failure to do so may cause PasswordSafe to crash if it has to issue a message or display a menu or dialog with this string.  The most common occurrences are ‘%s’ and ‘%d’.  The first will be replaced by a string and the second by a number.

The following characters have special meanings when preceded by the escape character ‘\’:
\t	tab character
\r	carriage return
\n	line feed

If you wish to add a double-quote character into a string, it must be preceded by the escape character \ e.g. \”.

There are a number of editors freely available that can be used to edit PO files (also known as GNU gettext) e.g. Poedit (http://www.poedit.net/).

However, you can use any text editor that understands Unicode characters e.g. Notepad++ (http://notepad-plus-plus.org/).

Although it is possible to ‘compile’ PO files to produce a ‘MO’ file, PasswordSafe does not use this file at this time, since we use the ResText program to produce the resource-only language files.