Scripting - Chapter 10: Script Translation

From PlayOnLinux
Jump to: navigation, search

A chapter dedicated to script translations; is it that important?

Yes. PlayOnLinux scripts must be translated in all languages so that as many people as possible can use them.

But I do not speak Russian!

Don't worry! You won't be doing all of the translations. It will be the job of the Launchpad team of translators, that we gratefully thank here for all of their work. Nevertheless, to make it possible for the Launchpad team to translate your script, your script requires a few things.

All messages must be written in English!

This is the core requirement for translations to take place (messages being translated from English to the other languages).

Messages reuse

To lessen translators workload, messages should be as much as possible identical among scripts (because if the message has already been translated, it won't need to be translated again for the new script). Hence, we made a list of the most common messages.

List of messages:

  1. Please select the setup file to run.
  2. Please insert the game media into your disk drive.
  3. Please wait while $TITLE is installed.
  4. $TITLE has been successfully installed.

Use those whenever you can. If you need some message that is not in this list, go ahead and write it in English. What you must avoid are messages that are not in this list but have the same meaning as one that does.

The eval_gettext command

The command eval_gettext takes an English message as argument, and returns its translation into current user's language (as automatically determined).

Example:

eval_gettext 'Please select the setup file to run.'

Usage: The problem is, how to simply pass the return value of the eval_gettext function to, say, the POL_SetupWindow_message command? The solution is to evaluate eval_gettext inside arguments. One can evaluate a function inside an argument? Wow, this is getting complicated! This is achieve by inserting the function eval_gettext between the symbols: $() meaning that the code between ( and ) is to be executed.

Example:

POL_SetupWindow_message "$(eval_gettext 'Please select the setup file to run.')" "$TITLE"

That may look a bit twisted, but you'll get used to it.

THE END

That is all, the tutorial ends here, you should have enough knowledge to stand on your own feet. An annex is available in the next chapter, that lists all the variables and all the functions that can be used in PlayOnLinux scripts, because we have seen something like one quarter of existing functions. One of those may come handy in a specific script, so think about having a look to this annex at that time. Note however, that the functions used in this tutorial will be all what you need for most scripts.

If you have any question, do not hesitate to ask it in the forums.

Previous: Chapter 9: Standardization

Next: Chapter 11: List of Functions