site  contact  subhomenews

Racy build with MoManager and SSS

February 09, 2012 — BarryK
These are recent Woof commit comments for 2012-02-09:

[2b7e120e96] SSS bugfixes: fixdesk, rc.update
[0958a9147f] bugfixes of SSS infrastructure, add /usr/sbin/fixscripts symlink and /usr/share/sss/script_strings SSS-domain, reverted /etc/rc.d/functions4puppy4 from gettext to sss translation method
[5415937e5e] added /usr/sbin/fixdesk and desk_strings sss-domain, plus rest of infrastructure


Something that is very interesting about the SSS technique is that it handles any kind of text files, including scripts. I created a special "SSS domain" for scripts, /usr/share/sss/script_strings/. The file /usr/share/sss/script_strings/script_strings is the template, and I have put in one target-script to demonstrate it:

[general]

#this SSS domain is intended for any scripts that need translation.
#this is an alternative method to gettext and t12s, as they are runtime translations, hence script runs slower.
#the translations in this SSS-domain, that is, this file script_strings*, are performed by /usr/sbin/fixscripts,
#which in turn is called from quicksetup/chooselocale whenever locale is changed, also by rc.update whenever a version upgrade.
#the section-ids are a full path, for example _etc_rc.d_functions4puppy4 means /etc/rc.d/functions4puppy4
# ...i originally imposed this substitution for / as i thought there might be a problem with having / in the section-id
# however, now i think not. anyway, fixscripts will accept any substitution, ex XetcXrc.dXfunctions4puppy4
#note, the text with \n in it (in the target file), this must be double-escaped to properly translate: \\n

[_etc_rc.d_functions4puppy4]
#target file is /etc/rc.d/functions4puppy4
CODESTRING='MOUSEINTRO="INSERTMARKER"' ; ENGLISH='Only very old PCs may have a serial mouse. These are recognised by the fairly large rectangular plug, technically known as a DB9 or the even larger DB25 (where the 9 or 25 refers to the number of pins in the plug). Press the UP and DOWN arrow keys to choose your mouse type, then press the ENTER key:' ; TRANSLATION=''
CODESTRING="MOUSEMENU1b='INSERTMARKER' #ttyS" ; ENGLISH='(mouse in very old computers)' ; TRANSLATION=''
CODESTRING="MOUSEMENU2b='INSERTMARKER' #ttyS" ; ENGLISH='(mouse or touchpad in all modern computers)' ; TRANSLATION=''
CODESTRING="MOUSEMENU1b='INSERTMARKER' #usb-ps2" ; ENGLISH='(mouse or touchpad in all modern computers)' ; TRANSLATION=''
CODESTRING="MOUSEMENU2b='INSERTMARKER' #usb-ps2" ; ENGLISH='(mouse in very old computers)' ; TRANSLATION=''
CODESTRING='INSERTMARKER" 0 0 0 "$MOUSEMENU1a" "$MOUSEMENU1b"' ; ENGLISH='Please choose mouse type...' ; TRANSLATION=''
CODESTRING='--menu "INSERTMARKER" 0 0 0 ttyS0' ; ENGLISH='Serial port mouse plugged into...\\nUse UP/DOWN ARROW keys, ENTER key to finish' ; TRANSLATION=''
CODESTRING='"COM1 INSERTMARKER" ttyS1' ; ENGLISH='(most likely)' ; TRANSLATION=''


If you want to create say a German translation, you make a copy of that file named script_strings.de and fill in the TRANSLATION variables. That's it.

The target script, in that example, /etc/rc.d/functions4puppy4, is the original unmodified script. Note, I had earlier implemented gettext in that script, but I changed it back to it's pre-gettext state. The SSS mechanism translates the script to the required language, so there is no run-time translation, so the script runs faster.

This mechanism works for any script. MoManager is the GUI tool for creating and editing these SSS translations, and the actual translation of the scripts occurs whenever there is a locale change or a version upgrade.

I don't envisage using the SSS technique on all scripts, as we have 100+ of them, which might take rather a long time. Or maybe not, I haven't timed it. I was thinking of applying it to a few of the time-critical scripts.

Anyway, I have built a Racy Puppy for anyone who wants to try this out (113.5MB):
http://distro.ibiblio.org/quirky/test/racy-5.2.2.5-alpha/racy-5.2.2.5-alpha.iso
http://distro.ibiblio.org/quirky/test/racy-5.2.2.5-alpha/racy-5.2.2.5-alpha.iso.md5.txt

I have only done German translations, so at first boot, choose the de_DE locale, with UTF-8 enabled, then restart X. You will see the desktop icons and JWM menu in german.

To study how it is done, look at MoManager in the Utility menu, and for the SSS stuff look in /usr/share/sss and the scripts /usr/sbin/fixmenus, fixdesk and fixscripts. The scripts quicksetup and rc.update call these.

If anyone wants to add translations of any text data-files or scripts, just add them into /usr/share/sss/desk_strings/ or script_strings/.

Testing can be done easily. For example, say that you add a new file into /usr/share/sss/desk_strings/desk_strings, and a translation file /usr/share/sss/desk_strings/desk_strings.de, you can test translation of the target file by running this:

# fixdesk de
# fixdesk en

...to convert the target data-files to de then back to en.

Note that if you use MoManager to edit an existing desk_strings.de file, there is automatic syncronisation with the master (template) file desk_strings, so the latter is the only one that you need to change if the target files are changed, added or removed.

Anyway, it is better if I don't overload the reader with lengthy explanations. It is quite simple, as you will see.

Note, the the Racy build is "alpha", meaning that it hasn't had much testing and bugs could show up.

Comments

Great!
Username: rodin.s
MoManager is great! I like it. Although I prefer to use poedit rather then geany. Poedit has translation memory and spell-checking if Abispell is installed. But I managed to open po files from /tmp/momanager in poedit. Automatic system of sending files is also great. Some issues: fixdesk doesn't work though. I've made Russian translation but it switched PuppyPin into German, then half-Russian half-English. File .jwmrc-tray should also be i18n-ed (two lines in it: 'Menu' and 'Show desktop') I have also noticed a mistake in pupdial_wizard_helper (line 36) - gettext closing bracket is missing and script doesn't work. But my impression is positive.

Re half-Russian
Username: BarryK
"That's interesting :happy: Could you pm me your Russian translation file /usr/share/sss/desk_strings/desk_strings.ru? I'll see if I can find out where fixdesk is going wrong. It seems that you must have changed the locale to de_DE, then later to ru_RU, and somehow that has confused fixdesk. fixdesk is supposed to handle that situation, by translating the target files back to English (from de) then to ru. It would seem that the de -> en has a problem.

wizard helper fixed
Username: BarryK
"Thanks, I fixed the typo in pupdial_wizard_helper. I just tested: # fixdesk de # fixdesk en and PuppyPin successfully changed to de then back to en. So, I will need your ru translation to test it more fully. If there are issues with the translation back to en, then I know how to fix it, by reverting to the original en file in the SFS layer, rather than a translation back (or keep a backup copy of the en file in the case of a full hd installation).

What's coming next
Username: BarryK
"just to keep everyone informed... I know that there are various to-do items that I need to attend to, but I need to keep going with the internationalization of Puppy for awhile. Apart from fixing bugs and adding some more files into the SSS domains (such as some ROX-Filer AppInfo.xml files), I also plan for a mechanism to download all _NLS packages. That is, when a user chooses a locale, there will also be an offer to download all the _NLS packages and extract all of the user's locale from them. ...I am still thinking of the best way to implement this.

MoManager needs devx
Username: BarryK
"While I remember it, MoManager needs the devx SFS loaded. Just grab devx_racy_5.2.2.sfs and rename it to devx_racy_5.2.2.5.sfs.

MoManager
Username: rodin.s
"Here is an archive that MoManager has made with all needed files. http://ompldr.org/vY3Fmbw/MoManager-ru_UA-WOOF.tar.gz I'm making a PET with Russian mo-files. Will post it later.

Language packs
Username: Sage
"Frankly, can't see the point. Most Germans speak better English than the Brits, and certainly the Yanks. All Chinese engaged in IT industries and most domestic user speak adequate English. Russians have a long and excellent history of making their own Cyrillic conversions. The Spanish governments, national and local, do their own OSes. The Brazilians release excellent Portuguese distros. Of the major nations, that only leaves the French. Last time I was over there, despite aeons of smouldering animosity, even Parisian taxi were speaking better English than many of my former students. If you want to do languages, why not read The Iliad in the original?!

Runtime speed?
Username: shinobar
"Barry> #this is an alternative method to gettext and t12s, as they are runtime translations, hence script runs slower. Runtime translation slows down the script, yes. But it is not a problem as i already posted. Messaging is not required its speed and never be in frequent loop. http://www.murga-linux.com/puppy/viewtopic.php?p=599234#599234

'Simple' way
Username: shinobar
" do not think your fixscripts a good idea, but it is easily gettexted. [_etc_rc.d_functions4puppy4] #target file is /etc/rc.d/functions4puppy4 CODESTRING='MOUSEINTRO="INSERTMARKER"' ; REPLACEMENT=$(gettext 'Only very old PCs may have a serial mouse. These are recognised by the fairly large rectangular plug, technically known as a DB9 or the even larger DB25 (where the 9 or 25 refers to the number of pins in the plug). Press the UP and DOWN arrow keys to choose your mouse type, then press the ENTER key:') CODESTRING="MOUSEMENU1b='INSERTMARKER' #ttyS" ; REPLACEMENT=$(getext '(mouse in very old computers)') CODESTRING="MOUSEMENU2b='INSERTMARKER' #ttyS" ; REPLACEMENT=$(gettext '(mouse or touchpad in all modern computers)') The point is what is 'simple' way. Offer unified method that is gettext to the translators. It is most simple for the translators.

re alsaconf
Username: BarryK
"rodin.s, Ok, I have put alsaconf.pot into Woof and made the exception /usr/sbin/momanager.

Re 'simple' way
Username: BarryK
"shinobar, I am not sure, but you seem to have misunderstood the SSS method. The target files are the original, unmodified files, which is the main point of the technique. They do not have "INSERTMARKER" in them.

SSS method, ISO download
Username: BarryK
"A note about the SSS translations files described in first post of this thread. That has changed, they are now simple sed expressions: s%english text%translation text% vicmz, Racy 5.2.2.5 has been removed, as at Feb. 17, 2012, Racy 5.2.2.6 is available, see later blog post.


Tags: woof