Skip to content

Commit

Permalink
Allow single lang updatepo.sh, and update translation docs
Browse files Browse the repository at this point in the history
  • Loading branch information
selfhoster1312 authored and kbengs committed Dec 19, 2024
1 parent 054c83b commit 3680096
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 35 deletions.
51 changes: 23 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,27 @@ python3 -m pdfarranger

## For translators

* Download the main branch (see [For developers](#for-developers))
Translations are located in the following files:

* [`po`](po)`/LANG.po` for interface translation strings
* [data/com.github.jeromerobert.pdfarranger.metainfo.xml](data/com.github.jeromerobert.pdfarranger.metainfo.xml) for repository integration
* [data/com.github.jeromerobert.pdfarranger.desktop](data/com.github.jeromerobert.pdfarranger.desktop) for desktop integration

* Run `po/genpot.sh`. The `pot` is an automatically generated file and as such
should not be in the repository. It is to make life of some translators
easier, but it might be out of sync with the source code. If you can
regenerate it before adding or updating a translation, then do it.

* Translations are in the following files:
* [`po`](po)`/*.po`
* [data/com.github.jeromerobert.pdfarranger.metainfo.xml](data/com.github.jeromerobert.pdfarranger.metainfo.xml)
* [data/com.github.jeromerobert.pdfarranger.desktop](data/com.github.jeromerobert.pdfarranger.desktop)

* For mnemonics accelerators (letters preceded by an underscore) try to follow
those rules by priority order:
* be consistent with other GTK/GNOME software
* pick a unique letter **within that given menu** if possible
* pick the same letter as the original string if available
* pick a strong letter (e.g. in "Search and replace" rather pick `s`, `r` or `p` than `a`)

* If possible, test your translation to see it in context
(see [For developers](#for-developers))

* Do not include `pdfarranger.pot` (or any `*.po` file which was just
automatically regenerated) in your pull request. Submit only the translations
you actually updated or added.

* If you don’t want or can’t use the developers tooling (`git`,
`po/genpot.sh`, `python`, …) you can edit, download or upload the `*.po`
files from the GitHub web pages.
If you are not comfortable working with git, **you may edit translations directly from Github's web interface**. However, in the normal case
you would contribute translations by following these steps:

* Download the main branch (see [For developers](#for-developers))
* Checkout a new branch to save your changes: `git checkout -b update-translation-LANG`
* Run `po/updatepo.sh LANG`, where `LANG` is the locale you'd like to update
* Update your translations in `po/LANG.po` file, and commit them; do not commit changes to `po/pdfarranger.pot` which may have been
automatically regenerated
* If possible, test your translation to see it in context (see [For developers](#for-developers))
* Create a new pull request with your changes to the main branch

If you are editing mnemonics accelerators (letters preceded by an underscore), here are some additional guidelines. However, if you have no idea what this means, don't worry about it.
Try to follow these rules by priority order:

* be consistent with other GTK/GNOME software
* pick a unique letter **within that given menu** if possible
* pick the same letter as the original string if available
* pick a strong letter (e.g. in "Search and replace" rather pick `s`, `r` or `p` than `a`)
43 changes: 36 additions & 7 deletions po/updatepo.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
#!/bin/bash

# Update translation files, after updating pdfarranger.pot
# - all translation files if no argument is passed
# - $1.po if an argument is passed (for example `updatepo.sh fr` for french locale)

#
# pdfarranger - GTK+ based utility for splitting, rearrangement and
Expand All @@ -20,10 +24,35 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

# Update translation files
cd "$(dirname "$0")/.."
for po in po/*.po
do
msgmerge --backup none -U "$po" po/pdfarranger.pot
msgattrib --no-obsolete --clear-fuzzy --empty -o "$po" "$po"
done

updatepo() {
msgmerge --backup none -U "$1" po/pdfarranger.pot
msgattrib --no-obsolete --clear-fuzzy --empty -o "$1" "$1"
}

# Make sure pdfarranger.pot is up-to-date
po/genpot.sh

if [[ "$1" = "" ]]; then
for po in po/*.po
do
updatepo "$po"
done
else
if [ -f "po/$1.po" ]; then
updatepo "po/$1.po"
else
echo "No such translation locale: $1."
read -r -p "Would you like to create new translation locale $1? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
cp po/pdfarranger.pot "po/$1.po"
;;
*)
echo "Unknown translation: $1"
exit 1
;;
esac
fi
fi

0 comments on commit 3680096

Please sign in to comment.