raspi-config
raspi-config copied to clipboard
Adding support for more languages
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.
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
OK, so noone cares about implementing this, right?
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.
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.
I have started to do the i18n. I will also do the l10n for Romanian.
Ok, so I will try to make the script translateable.
asb: are there any other RasPi-specific applications in the Foundation's image?
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
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.
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.
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.
Take a look in to my branch. It is almost ready, but it is not fully tested.
Jamstah: thanks for pointing this out.
mircea-vutcovici: just modified it a bit, see my branch.
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
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
andlog_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.
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.
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.
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 :)
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.
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.
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.
Sorry - I didn't know that.
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.
Just an FYI here - recent updates to raspi-config have added more translatable strings. One of the perils of NLS.
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.