PCSX2 Documentation/Translation Guide: Difference between revisions

no edit summary
mNo edit summary
No edit summary
Line 1: Line 1:
{{DocTabs|Section=2}}
==PCSX2 and GNU gettext Translations==
PCSX2 and GNU gettext Translations
PCSX2 uses an enhanced version of the wxWidgets internationalization module, which itself is based around GNU's gettext system. I'll cover the basics of gettext first, and then apply the PCSX2 enhancements afterward.
PCSX2 uses an enhanced version of the wxWidgets internationalization module, which itself is based around GNU's gettext system. I'll cover the basics of gettext first, and then apply the PCSX2 enhancements afterward.


How gettext Works (sorta)
==How gettext Works (sorta)==
GNU gettext works by taking a program which is written in English, and finds the matching translated message in a language file (which is what you as a translator would be making). This means that the actual English version of each message is specified directly in the code itself where the message is used, like so:
GNU gettext works by taking a program which is written in English, and finds the matching translated message in a language file (which is what you as a translator would be making). This means that the actual English version of each message is specified directly in the code itself where the message is used, like so:


<source lang="cpp">
MessageBox( _('PCSX2 Critical Error'), _('Your game sucks and we refuse to emulate it properly.') );
MessageBox( _('PCSX2 Critical Error'), _('Your game sucks and we refuse to emulate it properly.') );
</source>
... in the above example the _() portion is what invokes the GNU gettext translator, and the strings inside the _() are what gettext uses to look up the translation. The translation is stored in a language file which is given a *.mo extension type, and this file is created from a human-readable text database (clled a *.po file) which is typically generated by the gettext tool itself, and then updated by hand by the translator, using a text editor.
... in the above example the _() portion is what invokes the GNU gettext translator, and the strings inside the _() are what gettext uses to look up the translation. The translation is stored in a language file which is given a *.mo extension type, and this file is created from a human-readable text database (clled a *.po file) which is typically generated by the gettext tool itself, and then updated by hand by the translator, using a text editor.


Line 13: Line 15:
See our UsingPoedit page for details on how to download, install, and configure Poedit.
See our UsingPoedit page for details on how to download, install, and configure Poedit.


PCSX2-specific Extension: Iconized gettext Identifiers
==PCSX2-specific Extension: Iconized gettext Identifiers==
The gettext system has many conveniences over other methods of internationalization, which typically rely on the use of pre-processor macros or dynamically linked functions that return string values. The main drawback is that this method relies on the exact English representation, including punctuation, which means that even the slightest change to a text string in PCSX2 will break the translation for that string. For most short messages, such as menu items and button labels, this is fine and is in fact desirable behavior. But for longer messages that serve as descriptions of actions or checkbox options, some of which include formating to fit them to the dialog box more neatly, it can be problematic. This is why PCSX2 has an extension to gettext that uses iconized string matching instead ot the usual literal string matching.
The gettext system has many conveniences over other methods of internationalization, which typically rely on the use of pre-processor macros or dynamically linked functions that return string values. The main drawback is that this method relies on the exact English representation, including punctuation, which means that even the slightest change to a text string in PCSX2 will break the translation for that string. For most short messages, such as menu items and button labels, this is fine and is in fact desirable behavior. But for longer messages that serve as descriptions of actions or checkbox options, some of which include formating to fit them to the dialog box more neatly, it can be problematic. This is why PCSX2 has an extension to gettext that uses iconized string matching instead ot the usual literal string matching.


How String Iconization Works
==How String Iconization Works==
For especially long strings (such as dialog box option descriptions), or strings that contain newline or tab formatting, PCSX2 will use an iconized identifier for it's gettext lookup. These are identified in the gettext database of messages via their '!' prefix, which was chosen to help search and sort for these messages. Because this is a special PCSX2 extension to GNU gettext, you will need to reference the PCSX2 source code when translating them. You should probably be referencing source code during translation as a generla habit anyway, since the source code gives good hints as to the context of messages.
For especially long strings (such as dialog box option descriptions), or strings that contain newline or tab formatting, PCSX2 will use an iconized identifier for it's gettext lookup. These are identified in the gettext database of messages via their '!' prefix, which was chosen to help search and sort for these messages. Because this is a special PCSX2 extension to GNU gettext, you will need to reference the PCSX2 source code when translating them. You should probably be referencing source code during translation as a generla habit anyway, since the source code gives good hints as to the context of messages.


When referencing the source code, these iconized translation messages are used like so:
When referencing the source code, these iconized translation messages are used like so:


<source lang="cpp">
someCheckBox->SetToolTip( pxE( "!ContextTip:SomeOption", L"This is some option which will make your game run a lot faster, but probably makes it uglier too." ) );
someCheckBox->SetToolTip( pxE( "!ContextTip:SomeOption", L"This is some option which will make your game run a lot faster, but probably makes it uglier too." ) );
</source>
The first string is the icon, which reads "!Tooltips:SomeOption". The second string is the current English literal translation. Poedit will show you the iconized version in its messages list, and you will need to open the source code reference for it to see what the current English translation is. It is important that your Poedit options are set up properly so that viewing the PCSX2 program source code works.
The first string is the icon, which reads "!Tooltips:SomeOption". The second string is the current English literal translation. Poedit will show you the iconized version in its messages list, and you will need to open the source code reference for it to see what the current English translation is. It is important that your Poedit options are set up properly so that viewing the PCSX2 program source code works.


Message icons use a somewhat standard naming convention which will help you decide what's important for translating and/or what sort of formatting you should apply to the message. The common classes are:
Message icons use a somewhat standard naming convention which will help you decide what's important for translating and/or what sort of formatting you should apply to the message. The common classes are:
 
*Popup - Messages that are popped up to the user for errors or confirmations. Very High Priority!
Popup - Messages that are popped up to the user for errors or confirmations. Very High Priority!
*Panel - This is a top-level message on a dialog box or panel. These have a high translation priority.
Panel - This is a top-level message on a dialog box or panel. These have a high translation priority.
*Tooltip - These are tips that appear over toolbar buttons. Since button images are rarely fully self-explanatory these types of messages should be translated, so they have a high translation priority. (typically most or all such tooltips won't be iconized anyway, but I'm leaving the door open in case some would be better suited as such).
Tooltip - These are tips that appear over toolbar buttons. Since button images are rarely fully self-explanatory these types of messages should be translated, so they have a high translation priority. (typically most or all such tooltips won't be iconized anyway, but I'm leaving the door open in case some would be better suited as such).
*ContextTip - This is a popup box that gives additional extra information or details about various options on dialog boxes. Because these are usually supplementary to the dialog box option name and top-level description, translating them is not really necessary for someone to use the program. Translation priority is low.
ContextTip - This is a popup box that gives additional extra information or details about various options on dialog boxes. Because these are usually supplementary to the dialog box option name and top-level description, translating them is not really necessary for someone to use the program. Translation priority is low.
Compile/Generate pot/po/mo file on linux
Compile/Generate pot/po/mo file on linux
A script (generate_pot.sh) is provided to generates all files on linux. The script does the 3 following steps:
*A script (generate_pot.sh) is provided to generates all files on linux. The script does the 3 following steps:
xgettext -> parse all source files then build the several pot files.
*#xgettext -> parse all source files then build the several pot files.
msgmerge -> sync already translated po files with the previous pot generated. It would drop old string, add new ones and fuzzy string which was updated.
*#msgmerge -> sync already translated po files with the previous pot generated. It would drop old string, add new ones and fuzzy string which was updated.
msgfmt -> compile the po files into mo files then install the results into bin/Langs directory.
*#msgfmt -> compile the po files into mo files then install the results into bin/Langs directory.
To update/upload a new translation, it is as easy as copy the new po into the locales directory, call the script, commit the result.
To update/upload a new translation, it is as easy as copy the new po into the locales directory, call the script, commit the result.
Downloading and Using POT files
Downloading and Using POT files
ninja
782

edits