Localization/Testing: Difference between revisions

From OLPC
Jump to navigation Jump to search
m (→‎Logging in as root: update.1-673 requires sudo)
(Added sections on testing with sugar-jhbuild and an actual XO-1)
Line 1: Line 1:
=How to test your translation=
=How to test your translation=
This article is meant for a translator making localization of some part of XO software - sugar or activities, not being a software developer. In that case setting up complete development workstation just for testing localization is not the best option.
This article is meant for a translator making localization of some part of XO software - sugar or activities, not being a software developer. In that case setting up complete development workstation just for testing localization is not the best option.

There are a number of ways to test out translations.


== In a XO-1 laptop ==

=== Downloading the latest PO files ===

Pootle provides a way for you to download the latest PO files for your project. You can use the "Show Editing Functions" link in Pootle to enable links to the PO files under a given subproject. For example, to download the PO files for Spanish (subproject being XO Core), you can visit the URL https://dev.laptop.org/translate/es/xo_core/index.html?editing=1 From that page, you can download the latest [https://dev.laptop.org/translate/es/xo_core/sugar.po PO] file for Sugar.

=== Transferring the PO files to the laptop ===

If you have a wifi connection, you can use the ''scp'' command to transfer files from your computer to the XO-1. If you use Windows, you can use the [http://winscp.net/eng/index.php WinSCP] utility to transfer the files. If you do not have a wireless connection, a USB drive should be useful.

=== Compiling the PO file ===

The ''msgfmt'' command can be used to compile the PO file into corresponding MO files. The software you run is going to expect the MO files in specific locations, and you will have to use the ''-o'' option to specify where the output MO goes.

==== MO files for Sugar ====

Sugar MO files should be in ''/usr/share/locale/NN/LC_MESSAGES/sugar.mo'', where sugar-jhbuild is the directory where you have your sugar-jhbuild setup and NN is your language code (eg, for Spanish, the language code is es).

So the appropriate command to generate the mo file would be

msgfmt -o /usr/share/locale/NN/LC_MESSAGES/sugar.mo sugar.po

(assuming that sugar.po is in the directory you are issuing the command from)

Note that you will need to be root to do this. In recent builds, doing a ''sudo su -'' should give you root access.

==== MO files for the Activities ====

MO files for individual activities should usually be in ''/usr/share/activities/FOO.activity/locale/NN/LC_MESSAGES/org.laptop.FOOActivity.mo'', where sugar-jhbuild is the directory where you have your sugar-jhbuild setup and NN is your language code (eg, for Spanish, the language code is es), and FOO is the name of the activity.

So the appropriate command to generate the mo file would be

msgfmt -o /usr/share/activities/FOO.activity/locale/NN/LC_MESSAGES/org.laptop.FOOActivity.mo foo.po

(assuming that foo.po is in the directory you are issuing the command from)
Note that you will need to be root to do this. In recent builds, doing a ''sudo su -'' should give you root access.

=== Changing the language ===

Once all the MO files are in place, from Terminal activity in the GUI, issue the command

sugar-control-panel -s language LANGUAGE

Where LANGUAGE is your language. For a list of supported languages, you can issue the command

sugar-control-panel -h language


== Sugar-Jhbuild ==

[[sugar-jhbuild]] helps you download, install and run the latest bleeding edge version of sugar and a few related activities in you computer.

=== Setting up and running sugar-jhbuild ===

The [[Sugar-jhbuild]] page has the relevant directions which should let you install, set up and run sugar-jhbuild. When you are satisfied that the command

./sugar-jhbuild run

is working, you can proceed to the next step.

=== Downloading the latest PO files ===

Pootle provides a way for you to download the latest PO files for your project. You can use the "Show Editing Functions" link in Pootle to enable links to the PO files under a given subproject. For example, to download the PO files for Spanish (subproject being XO Core), you can visit the URL https://dev.laptop.org/translate/es/xo_core/index.html?editing=1 From that page, you can download the latest [https://dev.laptop.org/translate/es/xo_core/sugar.po PO] file for Sugar.

=== Compiling the PO file ===

The ''msgfmt'' command can be used to compile the PO file into corresponding MO files. The software you run is going to expect the MO files in specific locations, and you will have to use the ''-o'' option to specify where the output MO goes.

==== MO files for Sugar ====

Sugar MO files should be in ''sugar-jhbuild/build/share/locale/NN/LC_MESSAGES/sugar.mo'', where sugar-jhbuild is the directory where you have your sugar-jhbuild setup and NN is your language code (eg, for Spanish, the language code is es).

So the appropriate command to generate the mo file would be

msgfmt -o sugar-jhbuild/build/share/locale/NN/LC_MESSAGES/sugar.mo sugar.po

(assuming that sugar.po is in the directory you are issuing the command from)

==== MO files for the Activities ====

MO files for individual activities should usually be in ''sugar-jhbuild/build/share/activities/FOO.activity/locale/NN/LC_MESSAGES/org.laptop.FOOActivity.mo'', where sugar-jhbuild is the directory where you have your sugar-jhbuild setup and NN is your language code (eg, for Spanish, the language code is es), and FOO is the name of the activity.

So the appropriate command to generate the mo file would be

msgfmt -o sugar-jhbuild/build/share/activities/FOO.activity/locale/NN/LC_MESSAGES/org.laptop.FOOActivity.mo foo.po

(assuming that foo.po is in the directory you are issuing the command from)

=== Changing the language ===

Once all the MO files are in place, run the Sugar with the following command

LANG=NN sugar-jhbuild run

where NN is your language code.


== Emulation ==
Emulation lets your software emulate the hardware of a XO-1 laptop. It is a bit resource intensive, but the easiest way to get started if you do not have a actual XO-1 laptop.

=== Emulating XO ===


I assume that translator uses Windows XP, but most topics apply also for other operating systems.
I assume that translator uses Windows XP, but most topics apply also for other operating systems.


== Emulating XO ==
First, you should set up an emulated XO using software called QEMU. That way you can test translation in the close-to-real environment.
First, you should set up an emulated XO using software called QEMU. That way you can test translation in the close-to-real environment.


Line 13: Line 117:
It may be worth noting that popular commercial software emulators such as VMWare and Parallels usually run the XO ext3 images just fine and are considerably faster and more pleasant to use than qemu on their supported platforms.
It may be worth noting that popular commercial software emulators such as VMWare and Parallels usually run the XO ext3 images just fine and are considerably faster and more pleasant to use than qemu on their supported platforms.


== Preparing emulated XO for localization ==
=== Preparing emulated XO for localization ===
{{Latest Releases | devel = inline}}
{{Latest Releases | devel = inline}}
First of all, set up your language.
First of all, set up your language.
Line 26: Line 130:




===Logging in as root===
====Logging in as root====
Second, you'll need a way to log in to emulated XO as root. The easiest way is pressing Ctrl-Alt-F2 in QEMU window (you can always return to the Sugar interface by pressing Ctrl-Alt-F3).
Second, you'll need a way to log in to emulated XO as root. The easiest way is pressing Ctrl-Alt-F2 in QEMU window (you can always return to the Sugar interface by pressing Ctrl-Alt-F3).


Line 45: Line 149:
uid=0(root) gid=0(root) groups=0(root),1(bin) [usw]
uid=0(root) gid=0(root) groups=0(root),1(bin) [usw]


===Setting password===
====Setting password====
Now set a password to the root account so that you can copy files to and from XO later:
Now set a password to the root account so that you can copy files to and from XO later:
# passwd
# passwd
Line 57: Line 161:
As noted above this usage of the root account is deprecated in [[Joyride]] and future releases, according to discussion on the devel list. Please use the olpc account and sudo.
As noted above this usage of the root account is deprecated in [[Joyride]] and future releases, according to discussion on the devel list. Please use the olpc account and sudo.


===Installing software===
====Installing software====
Check that you have tools for converting .po files to .mo files which are used by the machine:
Check that you have tools for converting .po files to .mo files which are used by the machine:
bash-3.2# msgfmt
bash-3.2# msgfmt
Line 80: Line 184:
Now you can download a .po file to your PC.
Now you can download a .po file to your PC.


==Converting .po file==
===Converting .po file===
Copy the .po file to the correct directory of emulated XO, with proper name.
Copy the .po file to the correct directory of emulated XO, with proper name.


===Activities===
====Activities====
For Activities, the correct directory is: '''/usr/share/activities/<ActivityName>.activity/po'''.
For Activities, the correct directory is: '''/usr/share/activities/<ActivityName>.activity/po'''.


Line 106: Line 210:
That will restart Sugar. Start the activity by clicking its icon and enjoy!
That will restart Sugar. Start the activity by clicking its icon and enjoy!


===Sugar===
====Sugar====
The procedure for Sugar .po files is very similar to Activities procedure, but the directory structure is a bit different.
The procedure for Sugar .po files is very similar to Activities procedure, but the directory structure is a bit different.


Line 116: Line 220:




== Things to See ==
=== Things to See ===
* [[Sugar Control Panel]]
* [[Sugar Control Panel]]

Revision as of 18:40, 25 January 2008

How to test your translation

This article is meant for a translator making localization of some part of XO software - sugar or activities, not being a software developer. In that case setting up complete development workstation just for testing localization is not the best option.

There are a number of ways to test out translations.


In a XO-1 laptop

Downloading the latest PO files

Pootle provides a way for you to download the latest PO files for your project. You can use the "Show Editing Functions" link in Pootle to enable links to the PO files under a given subproject. For example, to download the PO files for Spanish (subproject being XO Core), you can visit the URL https://dev.laptop.org/translate/es/xo_core/index.html?editing=1 From that page, you can download the latest PO file for Sugar.

Transferring the PO files to the laptop

If you have a wifi connection, you can use the scp command to transfer files from your computer to the XO-1. If you use Windows, you can use the WinSCP utility to transfer the files. If you do not have a wireless connection, a USB drive should be useful.

Compiling the PO file

The msgfmt command can be used to compile the PO file into corresponding MO files. The software you run is going to expect the MO files in specific locations, and you will have to use the -o option to specify where the output MO goes.

MO files for Sugar

Sugar MO files should be in /usr/share/locale/NN/LC_MESSAGES/sugar.mo, where sugar-jhbuild is the directory where you have your sugar-jhbuild setup and NN is your language code (eg, for Spanish, the language code is es).

So the appropriate command to generate the mo file would be

 msgfmt -o /usr/share/locale/NN/LC_MESSAGES/sugar.mo sugar.po

(assuming that sugar.po is in the directory you are issuing the command from)

Note that you will need to be root to do this. In recent builds, doing a sudo su - should give you root access.

MO files for the Activities

MO files for individual activities should usually be in /usr/share/activities/FOO.activity/locale/NN/LC_MESSAGES/org.laptop.FOOActivity.mo, where sugar-jhbuild is the directory where you have your sugar-jhbuild setup and NN is your language code (eg, for Spanish, the language code is es), and FOO is the name of the activity.

So the appropriate command to generate the mo file would be

 msgfmt -o /usr/share/activities/FOO.activity/locale/NN/LC_MESSAGES/org.laptop.FOOActivity.mo foo.po

(assuming that foo.po is in the directory you are issuing the command from) Note that you will need to be root to do this. In recent builds, doing a sudo su - should give you root access.

Changing the language

Once all the MO files are in place, from Terminal activity in the GUI, issue the command

 sugar-control-panel -s language LANGUAGE

Where LANGUAGE is your language. For a list of supported languages, you can issue the command

 sugar-control-panel -h language


Sugar-Jhbuild

sugar-jhbuild helps you download, install and run the latest bleeding edge version of sugar and a few related activities in you computer.

Setting up and running sugar-jhbuild

The Sugar-jhbuild page has the relevant directions which should let you install, set up and run sugar-jhbuild. When you are satisfied that the command

 ./sugar-jhbuild run

is working, you can proceed to the next step.

Downloading the latest PO files

Pootle provides a way for you to download the latest PO files for your project. You can use the "Show Editing Functions" link in Pootle to enable links to the PO files under a given subproject. For example, to download the PO files for Spanish (subproject being XO Core), you can visit the URL https://dev.laptop.org/translate/es/xo_core/index.html?editing=1 From that page, you can download the latest PO file for Sugar.

Compiling the PO file

The msgfmt command can be used to compile the PO file into corresponding MO files. The software you run is going to expect the MO files in specific locations, and you will have to use the -o option to specify where the output MO goes.

MO files for Sugar

Sugar MO files should be in sugar-jhbuild/build/share/locale/NN/LC_MESSAGES/sugar.mo, where sugar-jhbuild is the directory where you have your sugar-jhbuild setup and NN is your language code (eg, for Spanish, the language code is es).

So the appropriate command to generate the mo file would be

 msgfmt -o sugar-jhbuild/build/share/locale/NN/LC_MESSAGES/sugar.mo sugar.po

(assuming that sugar.po is in the directory you are issuing the command from)

MO files for the Activities

MO files for individual activities should usually be in sugar-jhbuild/build/share/activities/FOO.activity/locale/NN/LC_MESSAGES/org.laptop.FOOActivity.mo, where sugar-jhbuild is the directory where you have your sugar-jhbuild setup and NN is your language code (eg, for Spanish, the language code is es), and FOO is the name of the activity.

So the appropriate command to generate the mo file would be

 msgfmt -o sugar-jhbuild/build/share/activities/FOO.activity/locale/NN/LC_MESSAGES/org.laptop.FOOActivity.mo foo.po

(assuming that foo.po is in the directory you are issuing the command from)

Changing the language

Once all the MO files are in place, run the Sugar with the following command

 LANG=NN sugar-jhbuild run

where NN is your language code.


Emulation

Emulation lets your software emulate the hardware of a XO-1 laptop. It is a bit resource intensive, but the easiest way to get started if you do not have a actual XO-1 laptop.

Emulating XO

I assume that translator uses Windows XP, but most topics apply also for other operating systems.

First, you should set up an emulated XO using software called QEMU. That way you can test translation in the close-to-real environment.

The easiest way of installing emulated XO is using quick start procedure, but you can also use manual installation.

When you check that your emulated XO is working correctly, you can prepare it to translation testing.

It may be worth noting that popular commercial software emulators such as VMWare and Parallels usually run the XO ext3 images just fine and are considerably faster and more pleasant to use than qemu on their supported platforms.

Preparing emulated XO for localization


First of all, set up your language.

Start Terminal Activity. It should be available as an icon with $_. If you can't find it that maybe you have too old system version. Download the newest devel-ext3 using a green box on the right and start over.

Check the list of available languages:

[olpc@xo-12-34-56 ~]$ sugar-control-panel -h language

Now set the language, i.e.:

[olpc@xo-12-34-56 ~]$ sugar-control-panel -s language Polish


Logging in as root

Second, you'll need a way to log in to emulated XO as root. The easiest way is pressing Ctrl-Alt-F2 in QEMU window (you can always return to the Sugar interface by pressing Ctrl-Alt-F3).

You should get

xo-12-34-56 login: _

Enter root and press Enter.

You should get:

-bash-3.2# _

Now you have full access to all XO files and directories as you logged in as user "root".

If you are unable to login as root, please try logging in as olpc (with no password) and using sudo to run commands as root. (Joyride builds now use sudo, and this will be the default in future releases (update.1-673 requires sudo), according to discussion on the devel list.) This example is from Terminal activity in Joyride 1470:

 [olpc@xo-97-62-C9 ~]$ sudo id
 uid=0(root) gid=0(root) groups=0(root),1(bin) [usw]

Setting password

Now set a password to the root account so that you can copy files to and from XO later:

# passwd
Changing password for user root.
New UNIX password: _

If your password will be too simple, the system would warn you, but the password will be changed.

You can try a new password by typing exit and logging in back as root.

As noted above this usage of the root account is deprecated in Joyride and future releases, according to discussion on the devel list. Please use the olpc account and sudo.

Installing software

Check that you have tools for converting .po files to .mo files which are used by the machine:

bash-3.2# msgfmt
msgfmt: no input file given
Try `msgfmt --help' for more information.
bash-3.2#

Now install two scripts that make using pybabel easier: makemo.sh and makemo-sugar.sh.

First, download them on your PC. Then, copy them to your emulated XO, using SSH. I'm using TotalCommander with SFTP plugin, but WinSCP seems to be easier. More info here.

You should copy them to home directory of root, that is /root.

Set executable permissions for them:

-bash-3.2# chmod +x *.sh
-bash-3.2# ls -l
total 8
-rwxr-xr-x 1 root root 190 Dec 12 11:03 makemo-sugar.sh
-rwxr-xr-x 1 root root 307 Dec 12 12:00 makemo.sh

Now you need some .po file. If there is some translation to your desired language available, you can download such a file from laptop.org. Go to https://dev.laptop.org/translate/ then select your language and project, then select "Show Editing Functions". Now you can download a .po file to your PC.

Converting .po file

Copy the .po file to the correct directory of emulated XO, with proper name.

Activities

For Activities, the correct directory is: /usr/share/activities/<ActivityName>.activity/po.

The name of the file is <language code>.po.

For example, file for Web activity and polish language (language code: pl) should be placed as: /usr/share/activities/Web.activity/po/pl.po

Now edit makemo.sh script a little bit.

-bash-3.2# nano /root/makemo.sh

Change the name of activity and language to yours:

ACTIVITY="Web"
LOCALE="pl"

Save the file and run it:

-bash-3.2# /root/makemo.sh
compiling catalog 'locale/pl/LC_MESSAGES/org.laptop.WebActivity.po' to 'locale/pl/LC_MESSAGES/org.laptop.WebActivity.mo'

That's it! Now let's try your new language:

-bash-3.2# killall -i X

That will restart Sugar. Start the activity by clicking its icon and enjoy!

Sugar

The procedure for Sugar .po files is very similar to Activities procedure, but the directory structure is a bit different.

Instead of activity directory, put the .po file to /usr/share/sugar/po. The name is the country code - i.e. pl.po for Polish (pl).

The script for converting file is /root/makemo-sugar.sh. Edit it with nano, setting LOCALE variable.

After running /root/makemo-sugar.sh you need to restart Sugar as with Activity localization.


Things to See