Update PO template generation to use POTFILES.in

Don't sort template lines (will be problematic when dealing with
multiple source files later on).
This commit is contained in:
Romain Failliot 2020-12-08 13:15:33 -05:00
parent 9cc2b4896e
commit 552c45141b
2 changed files with 17 additions and 20 deletions

View File

@ -9,23 +9,30 @@ The example commands below show how to create and manage the Japanese
translations. Replace all instances of "ja" with the code for the desired
language.
Creating a new translation
--------------------------
Create PO template
------------------
1. Create a .pot file for Diffuse:
To create or update the PO template (`po/diffuse.pot`), use this command at the
repo root:
$ xgettext -s -o diffuse.pot -L Python ../src/usr/bin/diffuse
xgettext -o po/diffuse.pot -f po/POTFILES.in
2. Create a .po file for the translation:
Create a new translation
------------------------
$ msginit -l ja -o ja.po -i diffuse.pot
To create a new translation file, you'll need a PO template. If not already
created, refer to previous section "Create PO template".
3. Manually complete in the translations in the .po file:
1. Create a .po file for the translation:
$ vi ja.po
msginit -l ja -o ja.po -i diffuse.pot
Updating an existing translation
--------------------------------
2. Manually complete in the translations in the .po file:
vim ja.po
Update a translation
--------------------
Use `update-translations.py` to update one or more PO files.

View File

@ -26,9 +26,6 @@ import subprocess
import shutil
import tempfile
def generate_pot_file():
subprocess.run(["xgettext", "-s", "-o", "diffuse.pot", "-L", "Python", "../src/usr/bin/diffuse"])
def check_translation(filename):
subprocess.run(["msgfmt", "-c", "-v", filename])
@ -61,8 +58,6 @@ parser.add_argument('po_files', metavar='filename.po', nargs='+',
help='the translation file')
parser.add_argument('-c', '--check-only', action='store_true',
help='check the PO files')
parser.add_argument('--no-pot-generation', action='store_true',
help='don\'t generate the POT file')
# Parse command-line arguments
args = parser.parse_args()
@ -77,11 +72,6 @@ if args.check_only:
check_translation(file)
exit(0)
if not args.no_pot_generation:
# Generate diffuse.pot file
print("Generate 'diffuse.pot'.")
generate_pot_file()
# Create temporary working directory
tmpdir = tempfile.mkdtemp()
try: