raspi-config icon indicating copy to clipboard operation
raspi-config copied to clipboard

Adding support for more languages

Open gyeben opened this issue 12 years ago • 24 comments

Hi!

Since Raspbian is available in a lot of languages I think it would be nice if raspi-config could be multi-language, too. Translation could have been done by the community of Raspberry Pi users.

Users could run raspi-config in another language (than English) by typing raspi-config --lang=XX, where XX would stay for the language code for a language - or raspi-config could include a screen where a user can select a language.

gyeben avatar Aug 23 '12 07:08 gyeben

It would be good to be able to change the default language and set of default keyboard options too, in a custom build image. Such images would be very useful for the French school system.

Regards, Will

williamhbell avatar Sep 02 '12 18:09 williamhbell

OK, so noone cares about implementing this, right?

gyeben avatar Sep 06 '12 14:09 gyeben

NLS of bash scripts isn't easy, but it is possible.

It would need someone to do the initial work to make the script translatable, there is a good tutorial here: http://mywiki.wooledge.org/BashFAQ/098

Do you fancy giving it a go?

After you have the .po files, getting them into the debian package should be easy.

Jamstah avatar Sep 06 '12 14:09 Jamstah

I would love to accept a patch implementing this functionality, or indeed any improvements for multi-language support in general for the Foundation's image.

asb avatar Sep 06 '12 15:09 asb

I have started to do the i18n. I will also do the l10n for Romanian.

mircea-vutcovici avatar Sep 06 '12 19:09 mircea-vutcovici

Ok, so I will try to make the script translateable.

asb: are there any other RasPi-specific applications in the Foundation's image?

gyeben avatar Sep 07 '12 16:09 gyeben

There's the /opt/vc/bin stuff, but that's not currently open source. Otherwise, I think that's it. I suppose someone might be interested in internationalising omxplayer

asb avatar Sep 07 '12 16:09 asb

I might give up. Following the tutorial linked by Jamstah (mywiki.wooledge.org/BashFAQ/098), I just can't do it. I could generate pot, po and then mo files, and modified raspi-config, but it still doesn't use the locale files.

gyeben avatar Sep 08 '12 13:09 gyeben

Did you put the files in the right places? Did you run "dpkg-reconfigure locales" to generate the locale you're testing?

If you know how to make a branch on github, you could do that, then we can look at your code.

Jamstah avatar Sep 08 '12 13:09 Jamstah

Having just had a check myself, if you see a $ in front of all the string when you use the tool, its because you need to change #!/bin/sh at the top to #!/bin/bash, otherwise the shell won't use all the bash features, including localization.

You know its working if you add the $'s, and the text looks normal in english.

Jamstah avatar Sep 08 '12 14:09 Jamstah

Take a look in to my branch. It is almost ready, but it is not fully tested.

mircea-vutcovici avatar Sep 08 '12 18:09 mircea-vutcovici

Jamstah: thanks for pointing this out.

mircea-vutcovici: just modified it a bit, see my branch.

gyeben avatar Sep 08 '12 19:09 gyeben

OK, so far I posted a new thread in the Raspbian topic on the forum: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=16864

gyeben avatar Sep 09 '12 15:09 gyeben

Couple of things from a quick look:

  • You can move the TEXTDOMAIN down below the first comment, it doesn't need to be the first line, and the package information should really be first.
  • In do_expand_rootfs, you don't need translations for the parts in the init script (I believe), like echo $"Usage:" "$0 start" >&2 and log_daemon_msg $"Starting"
  • Where there is a variable substitution, you should change it to a printf to allow for proper translation. Example below.

MEMSPLIT_LIST_DESCRIPTION=$SPLIT$"MiB for ARM, "$SPLIT$"MiB for VideoCore" could be (and it looks like there's a bug in the line too - same MiB for ARM and Video): MEMSPLIT_LIST_DESCRIPTION=$( printf $"%sMiB for ARM, %sMiB for VideoCore" ${CURRENT_MEMSPLIT} $((256 - $CURRENT_MEMSPLIT)) ) It just means that if the number doesn't come at the start of the line in the second language, the translator can move it.

Jamstah avatar Sep 09 '12 20:09 Jamstah

Also, if you add "./locale/hu/LC_MESSAGES/raspi-config.mo /usr/share/locale/hu/LC_MESSAGES/" to the debian/raspi-config.install file, you should be able to run "dpkg-buildpackage" in the folder, and build a debian package that contains the translations.

You don't need the en translations, that will be the fallback translation anyway.

Jamstah avatar Sep 09 '12 20:09 Jamstah

Thank you! I will change the stuff to include your suggestions. You can see the work in progress in my branch. It is not finished yet, but at least it works fine.

mircea-vutcovici avatar Sep 10 '12 22:09 mircea-vutcovici

You two should really get together and choose one of your branches to concentrate on, otherwise you will end up with two slightly different sets of strings to translate, which won't really help :)

Jamstah avatar Sep 11 '12 07:09 Jamstah

mircea-vutcovici: I'm pretty sure that you need .mo files instead of .po (they're pretty much similar, .mo is kind of a compiled .po file). Also, the .mo files should be all called raspi-config.mo when the program is installed. The structure for language files should be (when installed): /usr/share/locale/langcode/LC_MESSAGES/raspi-config.mo eg.: /usr/share/locale/ro/LC_MESSAGES/raspi-config.mo

I have deleted my branch because I saw that you had more bugfixes. But then I had to make a new branch, because github allows me only to work on branches that I forked for myself. :) Anyway, before Friday I'll try to finish and test the Hungarian translation and then I'll make a pull request.

gyeben avatar Sep 11 '12 18:09 gyeben

It was more that I thought your po files should match up, so you could share translation efforts when its ready to go, so a new branch from the same english source is a good idea.

You don't need mo files in the package, you could add a build step to generate the mo from the po at build time.

Jamstah avatar Sep 11 '12 19:09 Jamstah

The .pot file is the template. The .mo are binary files and should not be in the source control. Only the .po and the .pot. The .mo files should be part of the .deb package.

mircea-vutcovici avatar Sep 11 '12 19:09 mircea-vutcovici

Sorry - I didn't know that.

gyeben avatar Sep 12 '12 03:09 gyeben

I've added a doc for translations, it is the README fiel in the po folder. If you are ready I can integrate other translation into my tree. Next on my list is to update the package specifications.

mircea-vutcovici avatar Sep 12 '12 03:09 mircea-vutcovici

Just an FYI here - recent updates to raspi-config have added more translatable strings. One of the perils of NLS.

Jamstah avatar Sep 19 '12 13:09 Jamstah

Well, as I can see, there have been several commits which cause the localization not to work, so I'm going to redo this whole thing.

gyeben avatar Feb 14 '13 07:02 gyeben