Skip to content

Commit

Permalink
Adding localization
Browse files Browse the repository at this point in the history
  • Loading branch information
gasparfm committed Jun 4, 2015
1 parent a21c753 commit 2c8d6cd
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 14 deletions.
30 changes: 30 additions & 0 deletions _gscripts_common.sh
@@ -0,0 +1,30 @@
#!/bin/bash
GETTEXT=`which gettext`
DOMAIN="gscripts"

# Possible locale paths:
# * /usr/share/locale (gettext default)
# * $SCRIPT_SOURCE/locale
# * $SCRIPT_SOURCE/gscripts/locale
if [ -z "`ls -R /usr/share/locale | grep $DOMAIN.mo`" ]; then
if [ -n "`ls -R $SCRIPT_SOURCE/gscripts/locale | grep $DOMAIN.mo`" ]; then
TEXTDOMAINDIR=$SCRIPT_SOURCE/gscripts/locale
else
TEXTDOMAINDIR=$SCRIPT_SOURCE/locale
fi
fi

echo $TEXTDOMAINDIR

function __()
{
ARGS=$@

if [ -z "$GETTEXT" ]; then
printf "$ARGS"
else
LINE="$1"
shift
printf "$(gettext "$DOMAIN" "$LINE")" $@
fi
}
15 changes: 9 additions & 6 deletions gchangewn.sh
Expand Up @@ -3,25 +3,28 @@ WMCTRL=`which wmctrl`
ZENITY=`which zenity`
NOTIFY_SEND=`which notify-send`
NOTIFY_SEND_ARGS="-t 2000 -i window-duplicate"
# First implementation. No locales. Spanish for now

SCRIPT_SOURCE=`dirname $BASH_SOURCE[0]`
. $SCRIPT_SOURCE/_gscripts_common.sh

function get_window()
{
if [ "$1" == "Using" ]; then
WINDOWLIST="`$WMCTRL -l`"
if [ -z "`echo $WINDOWLIST | grep $3`" ]; then
$ZENITY --error --text "No se encuentra la ventana seleccionada"
$ZENITY --error --text "$(__ "Couldn't find selected window")"
exit
fi
NEWTITLE="`zenity --entry --width 350 --title "Cambiar título de ventana" --text "Nuevo título de la ventana"`"
NEWTITLE="`zenity --entry --width 350 --title "$(__ "Change window title")" --text "$(__ "New window title")"`"
if [ -z "$NEWTITLE" ]; then
$NOTIFY_SEND $NOTIFY_SEND_ARGS "No se ha cambiado el título."
$NOTIFY_SEND $NOTIFY_SEND_ARGS "$(__ "Title hasn't been changed.")"
exit
fi
$WMCTRL -i -r $3 -N "$NEWTITLE"
$NOTIFY_SEND $NOTIFY_SEND_ARGS "El titulo se ha cambiado correctamente"
$NOTIFY_SEND $NOTIFY_SEND_ARGS "$(__ "Title changed successfully")"
fi
}

$NOTIFY_SEND $NOTIFY_SEND_ARGS "Seleccione la ventana para cambiar su nombre"
$NOTIFY_SEND $NOTIFY_SEND_ARGS "$(__ "Please, select a Window to change it's title")"
$WMCTRL -a :SELECT: -v 2>&1 | while read line; do get_window $line; done

18 changes: 10 additions & 8 deletions gpwin.sh
Expand Up @@ -6,20 +6,22 @@ ZENITY=`which zenity`
WINDOWID=
NOTIFY_SEND=`which notify-send`
NOTIFY_SEND_ARGS="-t 2000 -i window-duplicate"
# First implementation. No locales. Spanish for now

SCRIPT_SOURCE=`dirname $BASH_SOURCE[0]`
. $SCRIPT_SOURCE/_gscripts_common.sh

function already_stopped()
{
WINPID=$1
NAME="$2"

$ZENITY --question --text "El proceso $2 está pausado. ¿Desea reanudarlo?" --title "Proceso pausado"
$ZENITY --question --text "$(__ "Process %s is paused. Do you wanto to resume it?" "$2")" --title "$(__ "Process paused")"
RES=$?
if [ "$RES" == "0" ]; then
kill -SIGCONT $WINPID
RES=$?
if [ "$RES" == "0" ]; then
$NOTIFY_SEND $NOTIFY_SEND_ARGS "Se ha reanudado el proceso $NAME"
$NOTIFY_SEND $NOTIFY_SEND_ARGS "$(__ "Process %s has been resumed" "$NAME")"
fi
fi
}
Expand All @@ -28,14 +30,14 @@ function already_running()
{
WINPID=$1
NAME="$2"
PCPU=`ps ax -o pid,pcpu | grep $WINPID | awk '{print $2}'`
$ZENITY --question --text "El proceso $2 está corriendo y consumiendo "$PCPU"% de CPU. ¿Desea pausarlo?" --title "Proceso en curso"
PCPU="`ps ax -o pid,pcpu | grep $WINPID | awk '{print $2}'`"
$ZENITY --question --text "$(__ "Process %s is running and using %s%% CPU. Do you want to pause it?" "$NAME" "$PCPU")" --title "$(__ "Process running")"
RES=$?
if [ "$RES" == "0" ]; then
kill -SIGSTOP $WINPID
RES=$?
if [ "$RES" == "0" ]; then
$NOTIFY_SEND $NOTIFY_SEND_ARGS "Se ha pausado el proceso $NAME"
$NOTIFY_SEND $NOTIFY_SEND_ARGS "$(__ "Process %s has been paused" "$NAME")"
fi
fi
}
Expand All @@ -59,14 +61,14 @@ function get_window()
if [ "$1" == "Using" ]; then
WINDOWLIST="`$WMCTRL -l -p | grep $3`"
if [ -z "$WINDOWLIST" ]; then
$ZENITY --error --text "No se encuentra la ventana seleccionada"
$ZENITY --error --text "$(__ "Couldn't find selected window")"
exit
fi
WINPID=`echo "$WINDOWLIST" | awk '{print $3}'`
state_changer $WINPID
fi
}

$NOTIFY_SEND $NOTIFY_SEND_ARGS "Seleccione la ventana para ver el estado del proceso"
$NOTIFY_SEND $NOTIFY_SEND_ARGS "$(__ "Please, click on a window to change its state")"
$WMCTRL -a :SELECT: -v 2>&1 | while read line; do get_window $line; done

Binary file added locale/es/LC_MESSAGES/gscripts.mo
Binary file not shown.
71 changes: 71 additions & 0 deletions locale/es/LC_MESSAGES/gscripts.po
@@ -0,0 +1,71 @@
# gscripts - Daily tools.
# Copyright (C) 2015 Gaspar Fernández
# This file is distributed under the same license as the gscripts package.
# Gaspar Fernández <gaspar.fernandez@totaki.com>, 2015.
#
msgid ""
msgstr ""
"Project-Id-Version: 0.2\n"
"Report-Msgid-Bugs-To: gaspar.fernandez@totaki.com\n"
"POT-Creation-Date: 2015-06-04 15:57+0200\n"
"PO-Revision-Date: 2015-06-04 16:31+0100\n"
"Last-Translator: Gaspar Fernández <gaspar.fernandez@totaki.com>\n"
"Language-Team: Spanish\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.5.4\n"

#: gchangewn.sh:15 gpwin.sh:64
msgid "Couldn't find selected window"
msgstr "No se puede encontrar la ventana seleccionada"

#: gchangewn.sh:18
msgid "Change window title"
msgstr "Cambiar título de ventana"

#: gchangewn.sh:18
msgid "New window title"
msgstr "Nuevo título de ventana"

#: gchangewn.sh:20
msgid "Title hasn't been changed."
msgstr "El título no se ha cambiado"

#: gchangewn.sh:24
msgid "Title changed successfully"
msgstr "Título cambiado con éxito"

#: gchangewn.sh:28
msgid "Please, select a Window to change it's title"
msgstr "Por favor, haga click en una ventana para cambiar su título"

#: gpwin.sh:18
msgid "Process %s is paused. Do you wanto to resume it?"
msgstr "El proceso %s está detenido. ¿Quiere reanudarlo?"

#: gpwin.sh:18
msgid "Process paused"
msgstr "Proceso detenido"

#: gpwin.sh:24
msgid "Process %s has been resumed"
msgstr "El proceso %s ha sido reanudado"

#: gpwin.sh:34
msgid "Process %s is running and using %s%% CPU. Do you want to pause it?"
msgstr "El proceso %s está en marcha usando un %s%% de CPU. ¿Quiere pausarlo?"

#: gpwin.sh:34
msgid "Process running"
msgstr "Proceso en curso"

#: gpwin.sh:40
msgid "Process %s has been paused"
msgstr "El proceso %s ha sido detenido"

#: gpwin.sh:72
msgid "Please, click on a window to change its state"
msgstr "Por favor, haga click en una ventana para cambiar su estado."

0 comments on commit 2c8d6cd

Please sign in to comment.