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 04 Mar 2015, 04:41
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
localizing-shell-scripts-without bashisms, gettext or ...
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 5 of 5 Posts_count   Goto page: Previous 1, 2, 3, 4, 5
Author Message
L18L

Joined: 19 Jun 2010
Posts: 2724
Location: www.eussenheim.de/

PostPosted: Tue 07 Feb 2012, 17:12    Post_subject: Re: xdelta_gui
Sub_title: really strange
 

rodin.s wrote:
Same with version 0.5. Here is my translation. You can try it by yourself. It has something to do with UTF-8. Console messages were interesting.


I have used your file to /usr/share/locales/ru/xdelta_gui
-t12s from woof : did not translate, used UNDO button
-t12s v 0.5 : everything OK
-t12s from woof again: everything OK

Really strange

What are your console messages?
Back to top
View user's profile Send_private_message 
rodin.s

Joined: 22 Sep 2010
Posts: 339
Location: Ukraine

PostPosted: Tue 07 Feb 2012, 17:31    Post_subject: t12s console messages  

Here is console messages file.
t12s_conslole.txt.gz
Description 
gz

 Download 
Filename  t12s_conslole.txt.gz 
Filesize  713 Bytes 
Downloaded  172 Time(s) 
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2724
Location: www.eussenheim.de/

PostPosted: Tue 07 Feb 2012, 18:07    Post_subject: Re: t12s console messages  

rodin.s wrote:
Here is console messages file.

I see: just WARNINGs

# echo $LANG
de_DE.UTF-8
#
I have no such warnings and can read everything fine.
t12s_ru.png
 Description   
 Filesize   6.13 KB
 Viewed   339 Time(s)

t12s_ru.png

Back to top
View user's profile Send_private_message 
cusco-travel-services

Joined: 02 Mar 2015
Posts: 4

PostPosted: Mon 02 Mar 2015, 19:13    Post_subject:  Usage of [ -f $LOCALES ] && . $LOCALES  

Hi L18L et al,

I've been using Linux for less than a year and 2 days ago I discovered this topic.

I like Technosaurus's idea for localisation of Bash scripts. It somewhat matches my thoughts of localisation for applications in that I think an indexed database containing all translations and using an Integer based index would be a more efficient mechanism instead of passing long strings of text as an index. There may be some valid reasons I don't know about but as someone who has programmed with databases for many years, I think that an indexed database should be much more efficient.

It appears that the following line of code is required each time a translation is to be accessed. Is that correct? If so, please explain for people new to Linux why it is needed each time.

Code:
[ -f $LOCALES ] && . $LOCALES

Also, in version 0.5 of your script the following block is different to what I have seen used and quoted elsewhere.

Code:
###################### copy this block into any other script that... ##########
app=\`basename \$0\`
T=/usr/share/locales # TEXTDOMAINDIR
# a one-liner to find existing translation file LOCALES allowing 'dialects'
[ ! -f \${T}/\${LANG%.*}/\${app} ] && LOCALES=\${T}/\${LANG%_*}/\${app} || LOCALES=\${T}/\${LANG%.*}/\${app}
[ -f \$LOCALES ] && . \$LOCALES # (re)load translation file (when using variables)
###################### ... uses this _ M _ method of internationalization #####

Notice, for example, that && is replaced by &&.

Thanks, Michael.
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4468

PostPosted: Mon 02 Mar 2015, 22:15    Post_subject: Re: Usage of [ -f $LOCALES ] && . $LOCALES  

cusco-travel-services wrote:
Notice, for example, that && is replaced by &&.

Thanks, Michael.
That looks like the result of pasting to a webpage (where "&" is represented by "&")
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
cusco-travel-services

Joined: 02 Mar 2015
Posts: 4

PostPosted: Mon 02 Mar 2015, 22:47    Post_subject: Re: Usage of [ -f $LOCALES ] && . $LOCALES  

technosaurus wrote:
That looks like the result of pasting to a webpage (where "&" is represented by "&")


That's what I was thinking also.

What about all the \ characters?
Back to top
View user's profile Send_private_message 
cusco-travel-services

Joined: 02 Mar 2015
Posts: 4

PostPosted: Mon 02 Mar 2015, 22:53    Post_subject:    

Additionally, if [ -f $LOCALES ] && . $LOCALES is required each time, which of the following will work?

Code:
[ -f $LOCALES ] && . $LOCALES # load translation file
[[ $DISPLAY ]] || { echo "${_M_04:-There is no xserver running. Exiting...}" ; exit 1 ; }

or
Code:
[ -f $LOCALES ] && . $LOCALES # load translation file
NoXserver="${_M_04:-There is no xserver running. Exiting...}"
[[ $DISPLAY ]] || { echo "$NoXserver" ; exit 1 ; }
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2724
Location: www.eussenheim.de/

PostPosted: Yesterday, at 06:21    Post_subject: Re: Usage of [ -f $LOCALES ] && . $LOCALES  

Hello Michael
you wrote:
I like Technosaurus's idea for localisation of Bash scripts. It somewhat matches my thoughts of localisation for applications in that I think an indexed database containing all translations and using an Integer based index would be a more efficient mechanism instead of passing long strings of text as an index. There may be some valid reasons I don't know about but as someone who has programmed with databases for many years, I think that an indexed database should be much more efficient.

Thanks for making me search about official documentation about this method using index _M_nnn.

Actually not found any more.

Nobody has been using it.
And yes, there are reasons for not using it in Puppy.

So for me it is history now. Cool

I am thinking if you are developper, coder and maintainer all in one person you could give it a try.

Reloading the translation file is of course not always required,
-- only if the variable in the message has changed/another value than last loading.
-- and never required if command eval is used.

You could try everything if you had a Puppy Linux installed...
I am assuming you have not because of your
Quote:
Notice, for example, that && is replaced by &&.

Cheers
L

EDIT:
...and please do NOT use that crazy automatic translations
Quote:
Das Ziel des Cusco Travel Services ist, Reisende zu versorgen, zu und vom Cusco Gebiet von Peru, der beste Dienst der möglich ist für Ihre Bedürfnisse in Unterkunft, Passagiertransport und Touren wie zum die Inca-Spur, Beispiel Mountain-bike und Pferderücken Fahrend Ausflüge und Vorbehalte für Zugfahrkarten für die Züge der Inca Rail Bedienung zwischen Ollantaytambo und Machu Picchu und den Zügen der Peru Rail Bedienung zwischen Cusco (Poroy), Ollantaytambo und Machu Picchu und zwischen Cusco und Puno (See Titicaca).
Shocked Mad
Back to top
View user's profile Send_private_message 
cusco-travel-services

Joined: 02 Mar 2015
Posts: 4

PostPosted: Yesterday, at 15:52    Post_subject:  Re: Usage of [ -f $LOCALES ] && . $LOCALES  

Hi L,

Thanks for your reply. I will continue modifying the script I want to interface with t12s and I'll let you know how it goes.

L18L wrote:
...and please do NOT use that crazy automatic translations
Quote:
Das Ziel des Cusco Travel Services ist, Reisende zu versorgen, zu und vom Cusco Gebiet von Peru, der beste Dienst der möglich ist für Ihre Bedürfnisse in Unterkunft, Passagiertransport und Touren wie zum die Inca-Spur, Beispiel Mountain-bike und Pferderücken Fahrend Ausflüge und Vorbehalte für Zugfahrkarten für die Züge der Inca Rail Bedienung zwischen Ollantaytambo und Machu Picchu und den Zügen der Peru Rail Bedienung zwischen Cusco (Poroy), Ollantaytambo und Machu Picchu und zwischen Cusco und Puno (See Titicaca).
Shocked Mad


Google Translate and Im Translator are what I used to create the German Translations for my website. Is "Google Translate" what you are referring to regarding "automatic translations"?

How bad is the German?

I wonder if Google Translate is better now? Laughing

Thanks for visiting my website.

Hasta luego, Michael.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 5 of 5 Posts_count   Goto page: Previous 1, 2, 3, 4, 5
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Cutting edge
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.0772s ][ Queries: 12 (0.0048s) ][ GZIP on ]