2
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
> Version 7 of Zren's i18n scripts.
|
||||
|
||||
## New Translations
|
||||
|
||||
Fill out [`template.pot`](template.pot) with your translations then open a [new issue](https://github.com/exequtic/apdatifier/issues/new), name the file with the extension `.txt`, attach the txt file to the issue (drag and drop).
|
||||
|
||||
Or if you know how to make a pull request:
|
||||
|
||||
Copy the [`template.pot`](template.pot) file to [`./po`](po) directory and name it your locale's code (Eg: `en`/`de`/`fr`) with the extension `.po`. Then fill out all the `msgstr ""`.
|
||||
|
||||
## Scripts
|
||||
|
||||
* `sh ./merge` will parse the `i18n()` calls in the `*.qml` files and write it to the `template.pot` file. Then it will merge any changes into the `*.po` language files.
|
||||
* `sh ./build` will convert the `*.po` files to it's binary `*.mo` version and move it to `contents/locale/...`
|
||||
|
||||
## Links
|
||||
|
||||
* https://zren.github.io/kde/docs/widget/#translations-i18n
|
||||
* https://github.com/Zren/plasma-applet-lib/tree/master/package/translate
|
||||
|
||||
## Status
|
||||
| Locale | Lines | % Done|
|
||||
|----------|---------|-------|
|
||||
| Template | 256 | |
|
||||
| de | 256/256 | 100% |
|
||||
| es | 256/256 | 100% |
|
||||
| fr | 256/256 | 100% |
|
||||
| ko | 130/256 | 50% |
|
||||
| nl | 256/256 | 100% |
|
||||
| pl | 256/256 | 100% |
|
||||
| pt_BR | 256/256 | 100% |
|
||||
| ru | 256/256 | 100% |
|
||||
| zh | 256/256 | 100% |
|
||||
@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
# Version: 6
|
||||
|
||||
# This script will convert the *.po files to *.mo files, rebuilding the package/contents/locale folder.
|
||||
# Feature discussion: https://phabricator.kde.org/D5209
|
||||
# Eg: contents/locale/fr_CA/LC_MESSAGES/plasma_applet_org.kde.plasma.eventcalendar.mo
|
||||
|
||||
DIR=`cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd`
|
||||
plasmoidName=com.github.exequtic.apdatifier
|
||||
widgetName="${plasmoidName##*.}" # Strip namespace
|
||||
website=https://github.com/exequtic/apdatifier
|
||||
bugAddress="$website"
|
||||
packageRoot=".." # Root of translatable sources
|
||||
projectName="plasma_applet_${plasmoidName}" # project name
|
||||
|
||||
#---
|
||||
if [ -z "$plasmoidName" ]; then
|
||||
echo "[build] Error: Couldn't read plasmoidName."
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$(which msgfmt)" ]; then
|
||||
echo "[build] Error: msgfmt command not found. Need to install gettext"
|
||||
echo "[build] Running 'sudo apt install gettext'"
|
||||
sudo apt install gettext
|
||||
echo "[build] gettext installation should be finished. Going back to installing translations."
|
||||
fi
|
||||
|
||||
#---
|
||||
echo "[build] Compiling messages"
|
||||
|
||||
catalogs=`find ./po -name '*.po' | sort`
|
||||
for cat in $catalogs; do
|
||||
catLocale=`basename ${cat%.*}`
|
||||
msgfmt -o "${catLocale}.mo" "$cat"
|
||||
|
||||
installPath="$DIR/../contents/locale/${catLocale}/LC_MESSAGES/${projectName}.mo"
|
||||
|
||||
echo "[build] Install ${cat} to ${installPath}"
|
||||
mkdir -p "$(dirname "$installPath")"
|
||||
mv "${catLocale}.mo" "${installPath}"
|
||||
done
|
||||
|
||||
echo "[build] Done building messages"
|
||||
|
||||
if [ "$1" = "--restartplasma" ]; then
|
||||
echo "[build] Restarting plasmashell"
|
||||
killall plasmashell
|
||||
kstart5 plasmashell
|
||||
echo "[build] Done restarting plasmashell"
|
||||
else
|
||||
echo "[build] (re)install the plasmoid and restart plasmashell to test."
|
||||
fi
|
||||
@ -0,0 +1,165 @@
|
||||
#!/bin/bash
|
||||
# Version: 22
|
||||
|
||||
# https://techbase.kde.org/Development/Tutorials/Localization/i18n_Build_Systems
|
||||
# https://techbase.kde.org/Development/Tutorials/Localization/i18n_Build_Systems/Outside_KDE_repositories
|
||||
# https://invent.kde.org/sysadmin/l10n-scripty/-/blob/master/extract-messages.sh
|
||||
|
||||
DIR=`cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd`
|
||||
plasmoidName=com.github.exequtic.apdatifier
|
||||
widgetName="${plasmoidName##*.}" # Strip namespace
|
||||
website=https://github.com/exequtic/apdatifier
|
||||
bugAddress="$website"
|
||||
packageRoot=".." # Root of translatable sources
|
||||
projectName="plasma_applet_${plasmoidName}" # project name
|
||||
|
||||
#---
|
||||
if [ -z "$plasmoidName" ]; then
|
||||
echo "[merge] Error: Couldn't read plasmoidName."
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$(which xgettext)" ]; then
|
||||
echo "[merge] Error: xgettext command not found. Need to install gettext"
|
||||
echo "[merge] Running 'sudo apt install gettext'"
|
||||
sudo apt install gettext
|
||||
echo "[merge] gettext installation should be finished. Going back to merging translations."
|
||||
fi
|
||||
|
||||
#---
|
||||
echo "[merge] Extracting messages"
|
||||
potArgs="--from-code=UTF-8 --width=200 --add-location=file"
|
||||
|
||||
# See Ki18n's extract-messages.sh for a full example:
|
||||
# https://invent.kde.org/sysadmin/l10n-scripty/-/blob/master/extract-messages.sh#L25
|
||||
# The -kN_ and -kaliasLocale keywords are mentioned in the Outside_KDE_repositories wiki.
|
||||
# We don't need -kN_ since we don't use intltool-extract but might as well keep it.
|
||||
# I have no idea what -kaliasLocale is used for. Googling aliasLocale found only listed kde1 code.
|
||||
# We don't need to parse -ki18nd since that'll extract messages from other domains.
|
||||
find "${packageRoot}" -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.qml' -o -name '*.js' -o -name 'messages' | sort > "${DIR}/infiles.list"
|
||||
xgettext \
|
||||
${potArgs} \
|
||||
--files-from="${DIR}/infiles.list" \
|
||||
-C -kde \
|
||||
-ci18n \
|
||||
-ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 \
|
||||
-kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \
|
||||
-kxi18n:1 -kxi18nc:1c,2 -kxi18np:1,2 -kxi18ncp:1c,2,3 \
|
||||
-kkxi18n:1 -kkxi18nc:1c,2 -kkxi18np:1,2 -kkxi18ncp:1c,2,3 \
|
||||
-kI18N_NOOP:1 -kI18NC_NOOP:1c,2 \
|
||||
-kI18N_NOOP2:1c,2 -kI18N_NOOP2_NOSTRIP:1c,2 \
|
||||
-ktr2i18n:1 -ktr2xi18n:1 \
|
||||
-kN_:1 \
|
||||
-kaliasLocale \
|
||||
--package-name="${widgetName}" \
|
||||
--msgid-bugs-address="${bugAddress}" \
|
||||
-D "${packageRoot}" \
|
||||
-D "${DIR}" \
|
||||
-o "template.pot.new" \
|
||||
|| \
|
||||
{ echo "[merge] error while calling xgettext. aborting."; exit 1; }
|
||||
|
||||
sed -i 's/"Content-Type: text\/plain; charset=CHARSET\\n"/"Content-Type: text\/plain; charset=UTF-8\\n"/' "template.pot.new"
|
||||
sed -i 's/# SOME DESCRIPTIVE TITLE./'"# Translation of ${widgetName} in LANGUAGE"'/' "template.pot.new"
|
||||
sed -i 's/# Copyright (C) YEAR THE PACKAGE'"'"'S COPYRIGHT HOLDER/'"# Copyright (C) $(date +%Y)"'/' "template.pot.new"
|
||||
|
||||
if [ -f "template.pot" ]; then
|
||||
newPotDate=`grep "POT-Creation-Date:" template.pot.new | sed 's/.\{3\}$//'`
|
||||
oldPotDate=`grep "POT-Creation-Date:" template.pot | sed 's/.\{3\}$//'`
|
||||
sed -i 's/'"${newPotDate}"'/'"${oldPotDate}"'/' "template.pot.new"
|
||||
changes=`diff "template.pot" "template.pot.new"`
|
||||
if [ ! -z "$changes" ]; then
|
||||
# There's been changes
|
||||
sed -i 's/'"${oldPotDate}"'/'"${newPotDate}"'/' "template.pot.new"
|
||||
mv "template.pot.new" "template.pot"
|
||||
|
||||
addedKeys=`echo "$changes" | grep "> msgid" | cut -c 9- | sort`
|
||||
removedKeys=`echo "$changes" | grep "< msgid" | cut -c 9- | sort`
|
||||
echo ""
|
||||
echo "Added Keys:"
|
||||
echo "$addedKeys"
|
||||
echo ""
|
||||
echo "Removed Keys:"
|
||||
echo "$removedKeys"
|
||||
echo ""
|
||||
|
||||
else
|
||||
# No changes
|
||||
rm "template.pot.new"
|
||||
fi
|
||||
else
|
||||
# template.pot didn't already exist
|
||||
mv "template.pot.new" "template.pot"
|
||||
fi
|
||||
|
||||
potMessageCount=`expr $(grep -Pzo 'msgstr ""\n(\n|$)' "template.pot" | grep -c 'msgstr ""')`
|
||||
echo "| Locale | Lines | % Done|" > "./Status.md"
|
||||
echo "|----------|---------|-------|" >> "./Status.md"
|
||||
entryFormat="| %-8s | %7s | %5s |"
|
||||
templateLine=`perl -e "printf(\"$entryFormat\", \"Template\", \"${potMessageCount}\", \"\")"`
|
||||
echo "$templateLine" >> "./Status.md"
|
||||
|
||||
rm "${DIR}/infiles.list"
|
||||
echo "[merge] Done extracting messages"
|
||||
|
||||
#---
|
||||
echo "[merge] Merging messages"
|
||||
catalogs=`find ./po -name '*.po' | sort`
|
||||
for cat in $catalogs; do
|
||||
echo "[merge] $cat"
|
||||
catLocale=`basename ${cat%.*}`
|
||||
|
||||
widthArg=""
|
||||
catUsesGenerator=`grep "X-Generator:" "$cat"`
|
||||
if [ -z "$catUsesGenerator" ]; then
|
||||
widthArg="--width=400"
|
||||
fi
|
||||
|
||||
compendiumArg=""
|
||||
if [ ! -z "$COMPENDIUM_DIR" ]; then
|
||||
langCode=`basename "${cat%.*}"`
|
||||
compendiumPath=`realpath "$COMPENDIUM_DIR/compendium-${langCode}.po"`
|
||||
if [ -f "$compendiumPath" ]; then
|
||||
echo "compendiumPath=$compendiumPath"
|
||||
compendiumArg="--compendium=$compendiumPath"
|
||||
fi
|
||||
fi
|
||||
|
||||
cp "$cat" "$cat.new"
|
||||
sed -i 's/"Content-Type: text\/plain; charset=CHARSET\\n"/"Content-Type: text\/plain; charset=UTF-8\\n"/' "$cat.new"
|
||||
|
||||
msgmerge \
|
||||
${widthArg} \
|
||||
--add-location=file \
|
||||
--no-fuzzy-matching \
|
||||
${compendiumArg} \
|
||||
-o "$cat.new" \
|
||||
"$cat.new" "${DIR}/template.pot"
|
||||
|
||||
sed -i 's/# SOME DESCRIPTIVE TITLE./'"# Translation of ${widgetName} in ${catLocale}"'/' "$cat.new"
|
||||
sed -i 's/# Translation of '"${widgetName}"' in LANGUAGE/'"# Translation of ${widgetName} in ${catLocale}"'/' "$cat.new"
|
||||
sed -i 's/# Copyright (C) YEAR THE PACKAGE'"'"'S COPYRIGHT HOLDER/'"# Copyright (C) $(date +%Y)"'/' "$cat.new"
|
||||
|
||||
poEmptyMessageCount=`expr $(grep -Pzo 'msgstr ""\n(\n|$)' "$cat.new" | grep -c 'msgstr ""')`
|
||||
poMessagesDoneCount=`expr $potMessageCount - $poEmptyMessageCount`
|
||||
poCompletion=`perl -e "printf(\"%d\", $poMessagesDoneCount * 100 / $potMessageCount)"`
|
||||
poLine=`perl -e "printf(\"$entryFormat\", \"$catLocale\", \"${poMessagesDoneCount}/${potMessageCount}\", \"${poCompletion}%\")"`
|
||||
echo "$poLine" >> "./Status.md"
|
||||
|
||||
# mv "$cat" "$cat.old"
|
||||
mv "$cat.new" "$cat"
|
||||
done
|
||||
echo "[merge] Done merging messages"
|
||||
|
||||
#---
|
||||
# Populate ReadMe.md
|
||||
echo "[merge] Updating translate/ReadMe.md"
|
||||
sed -i -E 's`share\/plasma\/plasmoids\/(.+)\/translate`share/plasma/plasmoids/'"${plasmoidName}"'/translate`' ./ReadMe.md
|
||||
if [[ "$website" == *"github.com"* ]]; then
|
||||
sed -i -E 's`\[new issue\]\(https:\/\/github\.com\/(.+)\/(.+)\/issues\/new\)`[new issue]('"${website}"'/issues/new)`' ./ReadMe.md
|
||||
fi
|
||||
sed -i '/^|/ d' ./ReadMe.md # Remove status table from ReadMe
|
||||
cat ./Status.md >> ./ReadMe.md
|
||||
rm ./Status.md
|
||||
|
||||
echo "[merge] Done"
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user