Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 01 Oct 2014, 14:50
All times are UTC - 4
 Forum index » Advanced Topics » Puppy Projects » Localization Project
MoManager tips for gettext translations
Moderators: Lobster, MU, raffy
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 2 Posts_count   Goto page: 1, 2 Next
Author Message
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Mon 04 Feb 2013, 20:03    Post_subject:  MoManager tips for gettext translations  

MoManager tips for gettext translations of scripts

See pupmd5sum.sh as a model to follow.

A utility to make minor changes to entries
build_gettext is available.

Shinobar does a good job explaining how to localize HERE

Note to make a mo file for French your $LANG must be French
and devx file for your distribution must be loaded.
Run a recent version of MoManager (Dec 2012) since
there was bugs in early versions.

Here are my experiences with using MoManager on a script...

1)Barry K has instructions (in MoManager help)
about adding a couple of lines near beginning of script.
Near beginning of script put two lines
Code:
export TEXTDOMAIN=script_name
export OUTPUT_CHARSET=UTF-8

(where you do a replacement for script_name)

if you want to use eval_gettext (rare) then you must also
put the following before eval_gettext is evoked

Code:
. gettext.sh



Go thru script and replace English expressions with
$(gettext "TEXT_to_TRANSLATE")




2) If text has an apostophe see this page
http://murga-linux.com/puppy/viewtopic.php?t=84086

3) Check script file in Geany by using Find 'get' command
This will list all occurrences of 'gettext'. Check the spelling
carefully. I guarantee that there will be mistakes.

4) Run the script in a terminal (you can use ./script_name)
and read error messages. Script must be executable of course.
Line numbers reported by terminal won't be accurate
if you have a gtkdialog script.

5) When your script will run without complaint in the terminal, then
put it in a folder that holds executable apps (example /usr/bin/)

6) I suggest that you install poedit It can be found HERE

7) Launch MoManager from start menu or terminal (it is launched in terminal by typing
'poeditor'). At the top right of window there will be a list of scripts
that need a mo file. --> mo file is the final file of translations.
Tick 'edit with poedit' and click Create button. The procedure is
fairly straight forward but if you haven't prepared your script properly
you will have problems. If you do have problems it is
time to quit. Unfortunately MoManager creates files on your hard disk
that will cause subsequent problems even if you do correct your script.

...But here is the solution to these problems....

1)Trash the folder /tmp/momanager
2) Trash the mo file if it has been created in
/usr/share/locale/fr/LC_MESSAGES/ (assuming French is current
language) In fact you should remove the German,Spanish and other
translations of your script if they exist.
Note: You can check the time of creation if in doubt about who
created the mo file

3) Trash the pot file in /usr/share/doc/nls/script_name

You now have a fresh system that won't confuse MoManager.
Correct your script and run MoManager again.


Another tip ---> I've had problems when I add more gettext
entries to a script. This means that more translation entries are needed.

The method I used ---> make a pet package, holding just the script.
Be careful the correct files are inside!! No mo or pot files inside.
Save old mo files somewhere safe.

Now go through the 3 step procedure I wrote above to obtain a fresh installation.
Now install your script which is easy since
you made a pet package. Now run Momanager and it will
think the script has no tranlation yet and create a mo file from scratch.
It's fairly easy to fill in the entries again.

Alternatively you can put back a mo file (if it is correctly formed!!)
just before launching MoManager and poedit will look
like this (see image) The untranslated expressions will
be on top of list. A nice feature of poedit. Everything
should be straight forward. mo and pot files can be created and saved.



____________________________________________________

Edited_times_total
Back to top
View user's profile Send_private_message 
vicmz


Joined: 15 Jan 2012
Posts: 1114

PostPosted: Mon 04 Feb 2013, 23:22    Post_subject:  

Thank you don570, very useful.

I recommend to link to this POedit package, often links from the openlab repo break.

_________________
OB Precise 14.07.26 Woof-CE|Puppy Linux en español
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2507
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Thu 07 Feb 2013, 15:23    Post_subject: Re: MoManager tips for gettext translations  

don570 wrote:
...
Here are my experiences with using MoManager on a script...
...


The experiences described here are
not with "just translate"
but with changing the code in a script to enable translations

momanager was built to enable translations of puppy in one GUI.

-------

For people who want to try making a script "international" I suggest another approach (how I do it):

1- put in the 2 lines (TEXTDOMAIN and OUTPUT_CHARSET) into the script
2- start with "gettexting" 1 message (title or frame)
3- start your script to make sure it can run
4- start momanager and select the new item and translate that 1 message
5- (re)start your script, you should see that translated message
6- if not search the fault and/or ask!
7- have a break or stop for this day or finish
8- goto 2
Back to top
View user's profile Send_private_message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Thu 07 Feb 2013, 15:56    Post_subject:  

L18L wrote:
2- start with "gettexting" 1 message (title or frame)


When I gettexted 'pupmd5sum.sh I used a different method as you noted.

I worked entirely in English. By a miracle Laughing I was able to convert
to gettext and track down the errors fairly quickly but working with
MoManager is tough. I had a bad experience because I had typed in the
wrong script name(Shinobar had given pupmd5sum.sh a different name)
export TEXTDOMAIN=script_name

It took me some time to track down that error and then it took me
more time to realize that I needed to clean my installation of old
files created by MoManager . In other words I needed a 'fresh' installation.

What irks me about MoManager is that it takes 2 minutes at least for
it to launch on my machine, so if I have to do that each time
I do a conversion of a expression into English gettext I'll go nuts. Crying or Very sad

So I think the best method is to do just one translation of an expression
into French and check that everything is okay.

Then proceed to do a conversion of all the English gettext script expressions using Geany.

Then switch to French with country wizard and launch MoManager
to translate script to French. Hopefully MoManager will see the
previous mo file that was created and react appropriately i.e. create
a po file that poedit can open.

____________________________________________________________
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2507
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Thu 07 Feb 2013, 16:24    Post_subject:  

don570 wrote:
export TEXTDOMAIN=script_name

Yes, that is exactly why I suggest to start with just 1 message!

Of course you advance to make more than 1 per run

2 minutes for momanager is slow
my (1.5GHz) box needs exactly 1 minute (very long for small changes)

The great advantage with momanager is the easy update after changes in the script.

Note, use command line
Code:
msgfmt script.po -o - > /usr/share/locale/fr/LC_MESSAGES/script.mo
to test new translation and you are faster.

If your LANG is en_CA then you can start your script in french
Code:
LANGUAGE=fr script
Back to top
View user's profile Send_private_message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Thu 07 Feb 2013, 16:37    Post_subject:  

My computer is so slow because it is an old installation of Exprimo that
has a lot of scripts loaded. I will set up a new install that has
the minimum number of scripts for max speed.

______________________________
Back to top
View user's profile Send_private_message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Mon 11 Feb 2013, 18:36    Post_subject:  

I have found the following useful to test a script to see if its gettext
expression is suitable...


Method:

1) change name of old script from script_name to script_name1

2) change the line near beginning of script from
export TEXTDOMAIN=script_name
to
export TEXTDOMAIN=script_name1

3) the script must be executable for MoManager to detect it....
chmod 755 script_name1

Now make sure you're in a foreign language such as de
and launch MoManager , and find script_name1 in upper rightside
of window (It will be listed with the untranslated scripts)

After translating the expression with Poedit
--> check German translation by launching script in terminal
Code:
Language=de script_name1


If everything has gone well then the German translation will show
correctly




.
Back to top
View user's profile Send_private_message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Sat 16 Feb 2013, 15:59    Post_subject: quick update mo-file  

Sometimes when translating a script I need to see if it looks good on GUI and I make some small changes to translation. But MoManager updates long time so my solution is go to /tmp/momanager:
Code:
cd /tmp/momanager

and do this
Code:
cp jwmconfig2.mo /usr/share/locale/ru/LC_MESSAGES/

every time when I do small changes to translation. Then I run the translated application to see how it looks.
As I use Poedit mo-file is created when I press Save button. When translation is complete I use MoManager.
Back to top
View user's profile Send_private_message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Sat 16 Feb 2013, 16:23    Post_subject:  

Can it be done as one command line in the terminal?

Code:
cp /tmp/momanager/jwmconfig2.mo /usr/share/locale/ru/LC_MESSAGES/


_______________________________________

L18L warned me about pre-existing pot files. I read Barry's
instructions and saw the following...


Quote:
MoManager will automatically use any pre-existing .pot file that it
finds in /usr/share/doc/nls, rather than use xgettext to extract the strings
from the script(s).


I now realize why I was having problems with moManager


I did a check of this and I found that if make modifications
to the text strings that deleting the pot file in /usr/share/doc/nls was
absolutely necessary!!!

.
Back to top
View user's profile Send_private_message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Sat 16 Feb 2013, 16:58    Post_subject: one line  

Of course it could be done in one line but I usually go to /tmp/momanager and I use "ls" command to see the content of that directory to choose needed mo-file. Or I could use:
Code:
ls /tmp/momanager

and then use above one line.
Back to top
View user's profile Send_private_message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Tue 19 Feb 2013, 14:16    Post_subject: error in translation - characters wrong type  

While I was putting together my textstrings script (for the
localisation of my rightclick pet package)I found the following
command line to create a pot file valuable...

Code:
xgettext -L shell textstrings -o textstrings.pot



It produced an error message in the terminal --->
saying that I hadn't used ASCII characters at line 50

For some strange reason an entry "Add file to pmusic list"
had bad characters??? I rewrote the line in utf-8 characters
and the line of code worked fine.

So this command is a good way to check for bad characters.
The application POEDIT doesn't give a proper warning!!


.

Edited_time_total
Back to top
View user's profile Send_private_message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Tue 19 Feb 2013, 14:30    Post_subject: xgettext  

I always use this command while adding gettext to scripts to check if everything is correct. I usually use output to terminal like this:
Code:
xgettext -L shell some_script.sh -o -
Back to top
View user's profile Send_private_message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Wed 20 Feb 2013, 16:38    Post_subject:  

This is the file that has the bad characters at line 50

People can use it to test the command xgettext.

Remove the extension to obtain script...

.
textstrings.gz
Description  bad script at line 50
gz

 Download 
Filename  textstrings.gz 
Filesize  3.61 KB 
Downloaded  408 Time(s) 
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2507
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Thu 21 Feb 2013, 08:58    Post_subject:  

Your white space between Pmusic and Playlist is not ASCII.
It is not really bad, just UTF-8 Cool
Code:
# xgettext -L shell textstrings
xgettext: Non-ASCII string at textstrings:50.
          Please specify the source encoding through --from-code.
#
# xgettext --from-code=UTF-8 -L shell textstrings
#
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2507
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sun 05 May 2013, 14:03    Post_subject: Re: quick update mo-file
Sub_title: use latest momanager
 

rodin.s wrote:
Sometimes when translating a script I need to see if it looks good on GUI and I make some small changes to translation. But MoManager updates long time...


Long time for update is history now. Smile

Try latest momanager please.
Get it from 5th post of http://www.murga-linux.com/puppy/viewtopic.php?p=701995
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 2 Posts_count   Goto page: 1, 2 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Puppy Projects » Localization Project
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1079s ][ Queries: 13 (0.0047s) ][ GZIP on ]