Program internationalization: problem with gettext!

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

Program internationalization: problem with gettext!

#1 Post by Argolance »

Hello,
I created a script using the Shinobar's "simple localization script" and this works fine! Now I plan to use gettext instead but have got a problem that I tried to solve without success. In this part of code:

Code: Select all

TMP=$(grep -A 1 default "$HOME/.config/rox.sourceforge.net/ROX-Filer/globicons" | sed 's#<rule match=\"/usr/local/bin/#exec#g' | sed 's#\">##g' | sed 's#\">##g' | sed 's#<icon>#icon#g'| sed 's#</icon>##g' | sed 's# ##g'); echo "$TMP" > $HOME/.2Palt/temp

awk '/^exec/{LINE=substr($0,0);TARGET_FILE_NAME=substr($0,5);getline;print LINE"\n"substr($0,0)>TARGET_DIR"/""0_"TARGET_FILE_NAME}' TARGET_DIR="$HOME/.tray_apps" $HOME/.2Palt/temp

for I in $HOME/.tray_apps/0_default*; do
VAR="$(grep 'default' $I | sed 's/exec//g')"
echo "popup${!VAR}" >> "$I"; mv -f "$I" /$HOME/.tray_apps/"0_${!VAR}"
done
... I have to call variables ${!VAR} using gettext. Tried many possibilities but these don't work! For example, please see the (quite imperfectly translated!) *.mo English file below and affected variables
#english file for 2Palt, 2011 june

#2Palt
Loc_button="Activate applications launch tray"
Loc_button_="Deactivate applications launch tray"
Loc_title="Applications launch tray"
Loc_not_lab_1="Applications"
Loc_not_lab_2="Configuration"
Loc_not_lab_3="About"
Loc_frame_1=" Load/Modify/Move tray shortcuts "
Loc_tree_1="Available applications"
Loc_button_1="Update applications list"
Loc_tree_2="Tray shortcuts"
Loc_button_tooltip_1="Click this button to (re)build available applications list..."
Loc_button_tooltip_2="Add selected item from the 'Available applications list' to the 'Tray shortcuts' or simply double-click"
Loc_button_tooltip_3="Remove selected item from Tray shortcuts list"
Loc_button_tooltip_4="Move up selected item"
Loc_button_tooltip_5="Move down selected item"
Loc_button_tooltip_6="Clear Tray shortcuts list"
Loc_button_tooltip_7="Load saved applications launch tray"
Loc_frame_2="Activate/deactivate tray"
Loc_frame_3="Tray Position/size/behavior"
Loc_text_1="Position:"
Loc_text_4="Size:"
Loc_item_1="Up"
Loc_item_2="Right"
Loc_item_3="Left"
Loc_item_4="Down"
Loc_text_2="Behavior:"
Loc_checkbox_1="Hide automatically"
Loc_button_tooltip_8=" Edit/Modify JWM configuration file"
Loc_button_2="Apply"
Loc_frame_4="Manage trays"
Loc_tree_3="Saved trays"
Loc_button_tooltip_9="Save current tray"
Loc_button_tooltip_10="Delete selected item from saved trays"
Loc_text_3="<i><b>

2Palt - Applications launch tray
Argolance</b> (2011 july)

Partly based on Ptray 0.4 by Sigmund Berglund.</i>"

#box_splash
Loc_bs_frame="Actualizing Tray..."

#combo_trays
Loc_frame_5="Available trays"
Loc_button_tooltip_11="Select tray to load"

#func
Loc_msg_1="Success!"
Loc_msg_2="Tray deactivated..."
Loc_msg_3="Tray activated..."
Loc_splash_msg="Please wait..."
Loc_JWM_popup_1="Manage and configure applications launch tray"
Loc_JWM_popup_2="File manager"
Loc_JWM_popup_4="Shutdown computer"
##Applications tab
Loc_msg_4="Information!"
Loc_msg_5="Please, select item to add into the available applications list!"
Loc_msg_6="Please, select item to remove from shorcuts list!"
Loc_msg_7="Please, select item to move inside shorcuts list!"
##Configuration tab
Loc_msg_9="Please, type a name for the tray!\n\nNote: no space(s)."
Loc_msg_10="Abort..."
Loc_msg_11="Tray already exists, replace it?"
Loc_msg_12="Tray replaced..."
Loc_msg_13="Done..."
Loc_msg_14="Please, select item to be deleted from saved trays list!"
Loc_msg_15="Deleted..."

#first run/help
Loc_title_1="2Palt $VERSION - First run help"
Loc_msg_16="
* * * Applications launch tray * * *

First run
* * *
I - 'Applications' tab:
Add Items of your choice to the shortcuts list, then click on 'Apply'

II - 'Configuration' tab:
1 - Define tray position and behavior, then click on 'Apply'
2 - Click on 'Activate applications launch tray'

Further information
* * *
You can manage as many trays as you wish:

1 - 'Configuration' tab:
Manage trays/'Save current tray' button

... and load saved tray of your choice later.

2 - 'Applications' tab:
'Load saved applications launch tray' button
*
- Fonctions of buttons are displayed while crossing them over with mouse cursor.

- The head button of the tray let user run 2Palt directly from.
"
########################

defaultcalendar="Default_calendar"
defaultbrowser="Default_browser"
defaultaudioplayer="Default_audio_player"
defaulthtmlviewer="Default_html_viewer"
defaultpaint="Default_paint"
defaultmusicplayer="Default_music_player"
defaultimageeditor="Default_image_editor"
defaulttexteditor="Default_text_editor"
defaultmediaplayer="Default_media_player"
defaultimageviewer="Default_image_viewer"
defaulttextviewer="Default_text_viewer"
defaultemail="Default_email"
defaultburner="Default_burner"
defaultspreadsheet="Default_spread_sheet"
defaultconnect="Default_connect"
defaulthtmleditor="Default_html_editor"
defaultwordprocessor="Default_word_processor"
defaultcontact="Default_contact"
defaultdraw="Default_draw"
defaultchat="Default_chat"
splitbar="Split_bar"
The corresponding mo French file:
[...]
defaultcalendar="Agenda_personnel_par_défaut"
defaultbrowser="Navigateur_Internet_par_défaut"
defaultaudioplayer="Lecteur_audio_par_défaut"
defaulthtmlviewer="Visionneuse_de_fichiers_html_par_défaut"
defaultpaint="Programme_de_dessin_par_défaut"
defaultmusicplayer="Lecteur_de_musique_par_défaut"
defaultimageeditor="Editeur_d'images_par_défaut"
defaulttexteditor="Editeur_de_texte_par_défaut"
defaultmediaplayer="Lecteur_média_par_défaut"
defaultimageviewer="Visionneuse_d'images_par_défaut"
defaulttextviewer="Visionneuse_de_texte_par_défaut"
defaultemail="Courriels_par_défaut"
defaultburner="Logiciel_de_gravage_par_défaut"
defaultspreadsheet="Feuilles_de_calcul_par_défaut"
defaultconnect="Connexion_par_défaut"
defaulthtmleditor="Editeur_de_fichiers_html_par_défaut"
defaultwordprocessor="Traitement_de_textes_par_défaut"
defaultcontact="Carnet_d'adresses_par_défaut"
defaultdraw="Programme_de_dessin_vectoriel_par_défaut"
defaultchat="Programme_de_tchat_par_défaut"
splitbar="Barre_de_séparation"
And so on for others languages...

Thank for your attention.

Cordialement.
Last edited by Argolance on Sun 31 Jul 2011, 16:52, edited 1 time in total.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Program internationalization: problem with gettext!

#2 Post by L18L »

Where is there text string?
15.3.3 Shell Format Strings

Shell format strings, as supported by GNU gettext and the ‘envsubst’ program, are strings with references to shell variables in the form $variable or ${variable}. References of the form ${variable-default}, ${variable:-default}, ${variable=default}, ${variable:=default}, ${variable+replacement}, ${variable:+replacement}, ${variable?ignored}, ${variable:?ignored}, that would be valid inside shell scripts, are not supported. The variable names must consist solely of alphanumeric or underscore ASCII characters, not start with a digit and be nonempty; otherwise such a variable reference is ignored.
quoted from 15.3.3 Shell Format Strings

PMed :)

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#3 Post by Argolance »

Hello, thank you for your answer!
What a pity! :cry: This should be patched... :wink:

Cordialement.

Post Reply