Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations scripts improved #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ Installation

### CMake ###

If you need localisation (i18n/l10n) support, please use `cmake` to install this widget to your system-wide directory. You also would need root permission.
If you need localization (i18n/l10n) support, please use `cmake` to install this widget to your system-wide directory. You also would need root permission.

````Shell
git clone https://github.com/dhabyx/plasma-simpleMonitor.git plasma-simpleMonitor
cd plasma-simpleMonitor/plasmoid
cd plasma-simpleMonitor
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$(kf5-config --prefix) -DCMAKE_BUILD_TYPE=Release -DKDE_INSTALL_USE_QT_SYS_PATHS=ON ../
make
sudo make install
````
### Plasma PKG ###

This way may be more convenient, but localisation support is not possible via `plasmapkg2`. This widget will be installed into your home directory.
This way may be more convenient, but localization support is not possible via `plasmapkg2`. This widget will be installed into your home directory.

Replace the version number as needed.

Expand Down
34 changes: 25 additions & 9 deletions translations/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
cmake_minimum_required(VERSION 2.8.12)

FILE(GLOB_RECURSE MO_FILES RELATIVE ${CMAKE_CURRENT_LIST_DIR} "*.mo")
set(_trDir locales)
set(catalogName plasma_applet_org.kde.simpleMonitor)

FOREACH(_mo ${MO_FILES})
GET_FILENAME_COMPONENT(_langLocation ${_mo} DIRECTORY)
GET_FILENAME_COMPONENT(_moFile ${_mo} NAME)

SET(_relname ${_moFile})
find_program(GETTEXT_MSGFMT_EXEC msgfmt)

INSTALL(FILES ${_mo} DESTINATION ${LOCALE_INSTALL_DIR}/${_langLocation}/ RENAME ${_relname})
add_custom_target(translations-plasmoid ALL)

ENDFOREACH(_mo ${MO_FILES})
if(NOT GETTEXT_MSGFMT_EXEC)
message(WARNING "-- msgfmt: not found. Translations will *not* be installed")
else()
file(GLOB_RECURSE PO_FILES RELATIVE ${CMAKE_CURRENT_LIST_DIR} "${catalogName}.po")
message(${CMAKE_CURRENT_LIST_DIR})

foreach(_PO ${PO_FILES})
# message("file: ${_PO}")
set(_MO ${CMAKE_CURRENT_BINARY_DIR}/${_trDir}/${_langLocation}/${catalogName}.mo)
get_filename_component(_langLocation ${_PO} DIRECTORY)
# message("path: ${_MO}")
get_filename_component(_moLocation ${_MO} DIRECTORY)
file(MAKE_DIRECTORY ${_moLocation})
add_custom_command(TARGET translations-plasmoid
COMMAND ${GETTEXT_MSGFMT_EXEC} --check -o ${_MO} ${CMAKE_CURRENT_LIST_DIR}/${_PO}
DEPENDS ${_PO})
install(FILES ${_MO}
DESTINATION ${LOCALE_INSTALL_DIR}/${KF5_LOCALE_PREFIX}/${_langLocation}/)
endforeach(_PO ${PO_FILES})
endif()
58 changes: 21 additions & 37 deletions translations/Messages.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,33 @@
#!/bin/sh

# Go to script dir

cd "${0%/*}"
cd "$(dirname $0)"
DIR=$(pwd)

LANGDIR="$1"
NAME="plasma_applet_"$(grep "X-KDE-PluginInfo-Name" ../plasmoid/metadata.desktop | sed 's/.*=//')
VERSION=$(grep "X-KDE-PluginInfo-Version" ../plasmoid/metadata.desktop | sed 's/.*=//')

XGETTEXT="xgettext --from-code=UTF-8 -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 \
-ki18ncp:1c,2,3 -ktr2i18n:1 -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale \
-kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3xgettext -ki18n -ki18nc
-ki18ncp -ki18np"
set -e

if [ "x$1" != "x" ]; then
if [ ! -d "$1" ]; then
mkdir -p "$1/LC_MESSAGES"
if [ -n "$LANGDIR" ]; then
if [ ! -d "$LANGDIR" ]; then
mkdir -p "${LANGDIR}/LC_MESSAGES"
fi
else
echo "Missing LANG parameter
usage: $0 LANG

example:
$0 es"
exit
fi

$XGETTEXT `find ../plasmoid -name \*.qml -o -name \*.js` -L JavaScript -o "$NAME.pot"
sed -e 's/charset=CHARSET/charset=UTF-8/g' -i "$NAME.pot"
sed -e 's/SOME DESCRIPTIVE TITLE./plasma-simpleMonitor language translation file./g' -i "$NAME.pot"
sed -e "s/Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER/Copyright (C) 2013-2016 Dhaby Xiloj, Konstantin Shtepa/g" -i "$NAME.pot"
sed -e 's/This file is distributed under the same license as the PACKAGE package./This file is distributed under the same license as the plasma-simpleMonitor package./g' -i "$NAME.pot"
sed -e 's/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.//g' -i "$NAME.pot"
sed -e "s/Project-Id-Version: PACKAGE VERSION/Project-Id-Version: $VERSION/g" -i "$NAME.pot"

for d in *; do
if [ -d "$d" ]; then
if [ -f "$d/LC_MESSAGES/$NAME.po" ]; then
echo "Merging $NAME.pot -> $d/LC_MESSAGES/$NAME.po ..."
msgmerge -U --backup=none "$d/LC_MESSAGES/$NAME.po" "$NAME.pot"
else
echo "Copying $NAME.pot -> $d/LC_MESSAGES/$NAME.po ..."
cp "$NAME.pot" "$d/LC_MESSAGES/$NAME.po"
fi
if [ -d "$LANGDIR" ]; then
if [ -f "${LANGDIR}/LC_MESSAGES/$NAME.po" ]; then
echo "Merging $NAME.pot -> ${LANGDIR}/LC_MESSAGES/$NAME.po ..."
msgmerge -U --backup=none "${LANGDIR}/LC_MESSAGES/$NAME.po" "$NAME.pot"
else
echo "Copying $NAME.pot -> ${LANGDIR}/LC_MESSAGES/$NAME.po ..."
cp "$NAME.pot" "${LANGDIR}/LC_MESSAGES/$NAME.po"
fi
done

for d in *; do
if [ -d "$d" ]; then
echo "Making $d/LC_MESSAGES/$NAME.mo ..."
msgfmt "$d/LC_MESSAGES/$NAME.po" -o "$d/LC_MESSAGES/$NAME.mo"
fi
done

# rm -f $NAME.pot
fi
28 changes: 23 additions & 5 deletions translations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,33 @@
Please fork this repository and sync with master if you haven't done so.

1. If you you're going to add support for a new language run `./Messages.sh lang_name` (e.g. `./Messages.sh fr` to add support for French)
2. If you want to refine translation of already supported language run `./Messages.sh` before modifying `.po` files to ensure they have latest translatable strings.
2. If you want to refine translation of already supported language run `./Messages.sh lang_name` again before modifying `.po` files to ensure they have latest translatable strings.
3. Open `.po` file in any text redactor or any Language Tool(e.g. Qt Linguist).
4. Fill in `msgstr` with translated strings
5. Check if there are any `fuzzy` translations that need your attention.
6. Save
7. Run `./Messages.sh` again to update .mo files

### Before commiting: ###
### Before committing: ###

1. Check that your translations works and looks fine(test it)
2. Run git status and check that other translations not affected by your actions.
2. Run git status and check that other translations not affected by your actions.
3. Exclude .pot file from commit(if it doesn't has any major changes other that creation date)
4. In the end your commit should only contain `.po` and `.mo` files of your newly added/modified language. If so then add a git commit and send a pull request.
4. In the end your commit should only contain `.po` files of your newly added/modified language. If so then add a git commit and send a pull request.

## Regenerate all translation strings: ##

If you are an developer or you has made changes on the plasmoid, specially if you has had added some i18n strings, you need to reload all strings from the project.

For this task you simply run:

````Shell
./translation.sh
````

This script collect and update the template catalog `plasma_applet_org.kde.simpleMonitor.pot`.

If you want to update all language catalogs you need to run the script with `--upgrade-all` parameter:

````Shell
./translation.sh --update-all
````
161 changes: 161 additions & 0 deletions translations/es/LC_MESSAGES/plasma_applet_org.kde.simpleMonitor.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# plasma-simpleMonitor language translation file.
# Copyright (C) 2013-2016 Dhaby Xiloj, Konstantin Shtepa
# This file is distributed under the same license as the plasma-simpleMonitor package.
#
#
# Dhaby Xiloj <[email protected]>, 2017.
msgid ""
msgstr ""
"Project-Id-Version: 0.6\n"
"Report-Msgid-Bugs-To: https://github.com/dhabyx/plasma-simpleMonitor/issues\n"
"POT-Creation-Date: 2017-04-07 19:44-0600\n"
"PO-Revision-Date: 2017-04-07 18:26-0600\n"
"Last-Translator: Dhaby Xiloj <[email protected]>\n"
"Language-Team: Spanish <[email protected]>\n"
"Language: es_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: Lokalize 2.0\n"

#: ../plasmoid/contents/ui/monitorWidgets/DatePicker.qml:52
msgid "mie"
msgstr ""

#: ../plasmoid/contents/ui/monitorWidgets/DatePicker.qml:75
msgid "dic"
msgstr ""

#: ../plasmoid/contents/ui/monitorWidgets/MemArea.qml:49
msgid "Mem:"
msgstr "Memoria:"

#: ../plasmoid/contents/ui/monitorWidgets/MemArea.qml:54
#: ../plasmoid/contents/ui/monitorWidgets/MemArea.qml:71
#: ../plasmoid/contents/ui/monitorWidgets/MemArea.qml:82
msgid "%1 GiB"
msgstr ""

#: ../plasmoid/contents/ui/monitorWidgets/MemArea.qml:65
msgid "Used:"
msgstr "Usada:"

#: ../plasmoid/contents/ui/monitorWidgets/MemArea.qml:76
msgid "Free:"
msgstr "Libre:"

#: ../plasmoid/contents/ui/monitorWidgets/CoreTempList.qml:49
msgid "Core %1:"
msgstr "Núcleo %1"

#: ../plasmoid/contents/ui/monitorWidgets/UptimePicker.qml:37
msgid "Uptime:"
msgstr "Actividad desde:"

#: ../plasmoid/contents/ui/monitorWidgets/UptimePicker.qml:43
msgid "%1d %2:%3"
msgstr ""

#: ../plasmoid/contents/ui/monitorWidgets/CpuWidget.qml:58
msgid "CPU %1:"
msgstr ""

#: ../plasmoid/contents/ui/skins/ColumnSkin.qml:113
#: ../plasmoid/contents/ui/skins/DefaultSkin.qml:92
msgid "Lock image scaling"
msgstr "Mantener escala de la imagen"

#: ../plasmoid/contents/ui/skins/ColumnSkin.qml:113
#: ../plasmoid/contents/ui/skins/DefaultSkin.qml:92
msgid "Unlock image scaling"
msgstr "No mantener escala de la imagen"

#: ../plasmoid/contents/ui/skins/ColumnSkin.qml:251
#: ../plasmoid/contents/ui/skins/DefaultSkin.qml:250
msgid "Swap:"
msgstr ""

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:94
msgid "Parts settings:"
msgstr "Configuración de secciones:"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:101
msgid "Logo:"
msgstr "Logo:"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:134
msgid "Background color:"
msgstr "Color de fondo"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:143
msgid "Standard"
msgstr "Estándar"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:150
msgid "Crystal"
msgstr "Cristal"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:157
msgid "Translucent"
msgstr "Translúcido"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:162
msgid "Show:"
msgstr "Mostar:"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:170
msgid "Swap"
msgstr ""

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:175
msgid "Uptime"
msgstr ""

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:181
msgid "Temp settings:"
msgstr "Configuración de temperatura:"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:190
msgid ""
"<i>(You can use the <strong>sensors</strong> command to place the "
"appropriate values ​​for this section.)</i>"
msgstr ""
"<i>(Use el comando <strong>sensors</strong> para colocar los valores "
"apropiados en ésta sección.)</i>"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:196
msgid "Temperature units:"
msgstr "Unidades de Temperatura:"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:205
msgid "Celsius °C"
msgstr ""

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:212
msgid "Fahrenheit °F"
msgstr ""

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:217
msgid "CPU High Temperature:"
msgstr "Temperatura Alta (CPU High):"

#: ../plasmoid/contents/ui/config/ConfigGeneral.qml:227
msgid "CPU Critical Temperature:"
msgstr "Temperatura Crítica (CPU Critical):"

#: ../plasmoid/contents/ui/config/ConfigSkins.qml:52
msgid "Skin:"
msgstr "Tema:"

#: ../plasmoid/contents/ui/config/ConfigSkins.qml:77
msgid "preview:"
msgstr "Previsualizar:"

#: ../plasmoid/contents/config/config.qml:25
msgid "General"
msgstr "General"

#: ../plasmoid/contents/config/config.qml:30
msgid "Skins"
msgstr "Temas"
Binary file not shown.
Binary file not shown.
38 changes: 38 additions & 0 deletions translations/translation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

# Go to script dir
cd "$(dirname $0)"
DIR=$(pwd)

BUGLNK='https://github.com/dhabyx/plasma-simpleMonitor/issues'
AUTHORS="Dhaby Xiloj, Konstantin Shtepa"

NAME="plasma_applet_"$(grep "X-KDE-PluginInfo-Name" ../plasmoid/metadata.desktop | sed 's/.*=//')
VERSION=$(grep "X-KDE-PluginInfo-Version" ../plasmoid/metadata.desktop | sed 's/.*=//')

XGETTEXT="xgettext --from-code=UTF-8 -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 \
-ki18ncp:1c,2,3 -ktr2i18n:1 -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale \
-kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3xgettext -ki18n -ki18nc
-ki18ncp -ki18np --package-version=${VERSION} --package-name=${NAME}\
--msgid-bugs-address=${BUGLNK}"

$XGETTEXT --copyright-holder="${AUTHORS}" `find ../plasmoid -name \*.qml -o -name \*.js` -L JavaScript -o "$NAME.pot"

sed -e 's/SOME DESCRIPTIVE TITLE./plasma-simpleMonitor language translation file./g' -i "$NAME.pot"
sed -e "s/YEAR/2013-2017/g" -i "$NAME.pot"
sed -e '/FIRST AUTHOR <EMAIL@ADDRESS>.*/d' -i "$NAME.pot"

if [ "$1" == "--update-all" ]; then
echo "Upgrading all translations."
for d in *; do
if [ -d "$d" ]; then
if [ -f "$d/LC_MESSAGES/$NAME.po" ]; then
echo "Merging $NAME.pot -> $d/LC_MESSAGES/$NAME.po ..."
msgmerge -U --backup=none "$d/LC_MESSAGES/$NAME.po" "$NAME.pot"
else
echo "Copying $NAME.pot -> $d/LC_MESSAGES/$NAME.po ..."
cp "$NAME.pot" "$d/LC_MESSAGES/$NAME.po"
fi
fi
done
fi
Binary file not shown.