PO-Localization #
This is an open-source library designed to help C++ developers create multi-language Windows applications using non-compiled PO-files. The project provides a utility to convert existing application resources into PO-files. The PO-file is a native format of poEdit, a useful application for translators.
Features #
- The poEdit translation utility is used.
- Any user can translate an application independently.
- The MFC Windows application can be easily integrated.
Instructions #
- Download and unpack latest ZIP-archive.
- Download and install poEdit.
- Add Localization.h and Localization.cpp from archive to your project for example to
StdAfx.h
andStdAfx.cpp
files correspondingly. - Add
CLocalization
class instantiation code and calls ofCLocalization::Load()
andCLocalization::Select()
methods to load all available translations and to select current language. - Add calls of
CLocalization::Translate()
methods to translate dialogs and menus. - Replace
CString::LoadString()
byCLocalization::LoadString()
to load localized strings. - Compile your project.
- Run exe2po utility from archive for your binary file to produce initial POT-file (PO and POT files are the same but POT used by poEdit as template and PO as work translation file):
exe2po.exe your_application.exe your_application.exe.pot
- Rename POT-file to PO-file by setting language identifier (Language Identifier Constants and Strings) in 2-digit or 4-digit hexadecimal format of future translation. For example
your_application.exe.09.po
for English (0x09) oryou_application.exe.19.po
for Russian (0x19). - Edit the PO-file in poEdit and save it to the folder of your application.
- To test, run your application and then repeat the preceding step.
- You can leave translated PO files near your application or embed them directly into its resources. Import files as “PO” resources (including quotes) with the resource ID equal to the language ID. The library first looks for external PO files and only after that uses the embedded ones. This way, every user can help translate your application without having to recompile it.
The library internally utilizes ATL for the CString, CAtlMap, and CAtlFile classes.
Compression #
The library is capable of loading translations in compressed or uncompressed formats, but only those compressed with the Lempel-Ziv algorithm. Uncompressed files have a “.po” extension, and compressed files have a “.p_” extension. Compressed files can be created using the Microsoft File Compression Utility, “compress.exe”. This utility can be found on any old Microsoft operating system or Resource Kit.
Example Usage:
compress.exe you_application.exe.09.po you_application.exe.09.p_
Compressed files can also be included as resources, detected by the magic number ‘SZDD’ at the beginning of the file.
The library uses the WinAPI LZExpand library (Lz32.dll) to handle compressed files.
Note: Some versions of ‘compress.exe’ produce compressed files with a single-byte difference. In such cases, obtain another version of the utility.
Applications #
Applications that use this library:
License #
Copyright © 2011-2023 Nikolay Raspopov.
Microsoft ® File Compression Utility Version 2.50
Copyright © Microsoft Corp. 1990-1994. All rights reserved.