Merge pull request #128 from MightyCreak/update-translations

Update POTFILES.in and .pot
This commit is contained in:
Creak 2021-11-24 12:22:38 -05:00 committed by GitHub
commit 3fcb76d22c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 3090 additions and 9455 deletions

View File

@ -1,6 +1,7 @@
[flake8] [flake8]
builtins = _ builtins = _
max-line-length = 100 max-line-length = 100
show-source = true
# Temporary # Temporary
exclude = src/diffuse/main.py exclude = src/diffuse/main.py

View File

@ -22,10 +22,10 @@ jobs:
- run: pip install -r requirements.txt - run: pip install -r requirements.txt
- name: Flake8 - name: Flake8
run: flake8 src/ run: flake8 src/ po/
- name: MyPy - name: MyPy
run: mypy src/ run: mypy src/ po/
meson-build-test: meson-build-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Added
- Added a `--remove-obsolete` option for the update-translation.py script
### Changed
- Updated the translation files
- Renamed POTFILES.in to POTFILES
- Renamed io.github.mightycreak.Diffuse.metadata.xml.in to
io.github.mightycreak.Diffuse.appdata.xml.in
## 0.7.3 - 2021-11-22 ## 0.7.3 - 2021-11-22
### Added ### Added
@ -16,7 +25,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- main.py slimmed down by about 5000 lines - main.py slimmed down by about 5000 lines
- The new widgets.py is a bit fat though (~4000 lines) - The new widgets.py is a bit fat though (~4000 lines)
- Updated the translation files
### Fixed ### Fixed
- The intense code cleaning seems to have fixed a bug with the `-c` argument - The intense code cleaning seems to have fixed a bug with the `-c` argument

View File

@ -36,6 +36,10 @@ This is the easiest way to install Diffuse:
flatpak install io.github.mightycreak.Diffuse flatpak install io.github.mightycreak.Diffuse
``` ```
## Translators
Please refer to the [translation documentation](po/README.md).
## Developers ## Developers
### Setup ### Setup
@ -128,7 +132,7 @@ the on-line help documentation using a web browser.
Diffuse is under the [GPLv2](COPYING). Diffuse is under the [GPLv2](COPYING).
The file [io.github.mightycreak.Diffuse.metainfo.xml](src/usr/share/metainfo/io.github.mightycreak.Diffuse.metainfo.xml) The file [io.github.mightycreak.Diffuse.appdata.xml.in](data/io.github.mightycreak.Diffuse.appdata.xml.in)
is licensed under the [FSF-AP](https://www.gnu.org/prep/maintain/html_node/License-Notices-for-Other-Files.html) is licensed under the [FSF-AP](https://www.gnu.org/prep/maintain/html_node/License-Notices-for-Other-Files.html)
license. license.

View File

@ -8,18 +8,25 @@
Diffuse is a graphical tool for comparing and merging text files. It can retrieve files for comparison from Bazaar, CVS, Darcs, Git, Mercurial, Monotone, RCS, Subversion, and SVK repositories. Diffuse is a graphical tool for comparing and merging text files. It can retrieve files for comparison from Bazaar, CVS, Darcs, Git, Mercurial, Monotone, RCS, Subversion, and SVK repositories.
</p> </p>
</description> </description>
<metadata_license>FSFAP</metadata_license> <metadata_license>FSFAP</metadata_license>
<project_license>GPL-2.0-or-later</project_license> <project_license>GPL-2.0-or-later</project_license>
<content_rating type="oars-1.1"/> <content_rating type="oars-1.1"/>
<launchable type="desktop-id">io.github.mightycreak.Diffuse.desktop</launchable> <launchable type="desktop-id">io.github.mightycreak.Diffuse.desktop</launchable>
<url type="homepage">https://mightycreak.github.io/diffuse/</url> <url type="homepage">https://mightycreak.github.io/diffuse/</url>
<url type="bugtracker">https://github.com/MightyCreak/diffuse/issues</url> <url type="bugtracker">https://github.com/MightyCreak/diffuse/issues</url>
<screenshots> <screenshots>
<screenshot type="default"> <screenshot type="default">
<caption>Main window: diff between two files</caption> <caption>Main window: diff between two files</caption>
<image>https://mightycreak.github.io/diffuse/images/screenshot_v0.7.0.png</image> <image>https://mightycreak.github.io/diffuse/images/screenshot_v0.7.0.png</image>
</screenshot> </screenshot>
</screenshots> </screenshots>
<!-- Translators: no need to translate after this comment -->
<developer_name>Romain Failliot</developer_name>
<update_contact>romain.failliot@foolstep.com</update_contact>
<releases> <releases>
<release version="0.7.3" date="2021-11-22"> <release version="0.7.3" date="2021-11-22">
<description> <description>
@ -207,6 +214,4 @@
</description> </description>
</release> </release>
</releases> </releases>
<developer_name>Romain Failliot</developer_name>
<update_contact>romain.failliot@foolstep.com</update_contact>
</component> </component>

View File

@ -17,8 +17,8 @@ if desktop_utils.found()
endif endif
appstream_file = i18n.merge_file( appstream_file = i18n.merge_file(
input: 'io.github.mightycreak.Diffuse.metainfo.xml.in', input: 'io.github.mightycreak.Diffuse.appdata.xml.in',
output: 'io.github.mightycreak.Diffuse.metainfo.xml', output: 'io.github.mightycreak.Diffuse.appdata.xml',
po_dir: '../po', po_dir: '../po',
install: true, install: true,
install_dir: join_paths(get_option('datadir'), 'appdata') install_dir: join_paths(get_option('datadir'), 'appdata')

12
po/POTFILES Normal file
View File

@ -0,0 +1,12 @@
# List of source files which contain translatable strings.
# Copyright (C) 2020 Romain Failliot <romain.failliot@foolstep.com>
data/io.github.mightycreak.Diffuse.desktop.in
data/io.github.mightycreak.Diffuse.appdata.xml.in
src/diffuse/constants.py.in
src/diffuse/diffuse.in
src/diffuse/main.py
src/diffuse/vcs/cvs.py
src/diffuse/vcs/rcs.py
src/diffuse/vcs/svn.py
src/diffuse/vcs/vcs_registry.py

View File

@ -1,12 +0,0 @@
# List of source files which contain translatable strings.
# Copyright (C) 2020 Romain Failliot <romain.failliot@foolstep.com>
data/io.github.mightycreak.Diffuse.desktop.in
data/io.github.mightycreak.Diffuse.metainfo.xml.in
src/constants.py.in
src/diffuse.in
src/main.py
src/vcs/cvs.py
src/vcs/rcs.py
src/vcs/svn.py
src/vcs/vcs_registry.py

View File

@ -15,7 +15,9 @@ Create PO template
To create or update the PO template (`po/diffuse.pot`), use this command at the To create or update the PO template (`po/diffuse.pot`), use this command at the
repo root: repo root:
xgettext -o po/diffuse.pot -f po/POTFILES.in ```sh
xgettext -o po/diffuse.pot -f po/POTFILES.in
```
Create a new translation Create a new translation
------------------------ ------------------------
@ -23,42 +25,37 @@ Create a new translation
To create a new translation file, you'll need a PO template. If not already To create a new translation file, you'll need a PO template. If not already
created, refer to previous section "Create PO template". created, refer to previous section "Create PO template".
1. Create a .po file for the translation: 1. Create a .po file for the translation (replace `<lang>` with your language):
msginit -l ja -o ja.po -i diffuse.pot ```sh
msginit -l <lang> -o <lang>.po -i diffuse.pot
```
2. Manually complete in the translations in the .po file: 2. Manually complete in the translations in the .po file using either an
application for that such as [Gtranslator][gtranslator] or directly with a
text editor such as [gedit][gedit] or [vim][vim].
vim ja.po [gtranslator]: https://www.flathub.org/apps/details/org.gnome.Gtranslator
[gedit]: https://www.flathub.org/apps/details/org.gnome.gedit
[vim]: https://www.vim.org/
Update a translation Update a translation
-------------------- --------------------
Use `update-translations.py` to update one or more PO files. Use `update-translations.py` to update one or more PO files.
Here is an example with `ja.po` and `ko.po`: Here is an example with the Japanese and Korean translations, respectively
`ja.po` and `ko.po`:
Command-line: Command-line:
```sh ```sh
./update-translations.py ja.po ko.po ./update-translations.py ja.po ko.po
``` ```
Output: This command also validate the files, so if you see a message saying "N
``` untranslated messages", use the text editor of your choice to complete the
Generate 'diffuse.pot'. translations.
Updating translation file 'ja.po'...
Created /tmp/tmp0gtniydu/ja.empty.po.
Validate ja.po:
183 translated messages, 2 untranslated messages.
Update done.
Updating translation file 'ko.po'...
Created /tmp/tmp0gtniydu/ko.empty.po.
Validate ko.po:
183 translated messages, 2 untranslated messages.
Update done.
```
Then use the text editor of your choice to complete the translations.
Validate a translation Validate a translation
---------------------- ----------------------
@ -72,40 +69,30 @@ Command-line:
./update-translations.py --check-only ja.po ko.po ./update-translations.py --check-only ja.po ko.po
``` ```
Output:
```
Validate ja.po:
183 translated messages, 2 untranslated messages.
Validate ko.po:
183 translated messages, 2 untranslated messages.
```
System Integration System Integration
================== ==================
Localised text for the system menu (name and comment) should be manually Localized text for the Microsoft Windows installer is stored in separate ISL
added to the desktop file: files. Copy the [English version][english-win-docs] and replace the text to the
right of each equal sign.
../src/usr/share/applications/diffuse.desktop [english-win-docs]: ../windows-installer/en.isl
Localised text for the Microsoft Windows installer is stored in separate ISL
files. Copy the English version (../windows-installer/en.isl) and replace the
text to the right of each equal sign.
Documentation Documentation
============= =============
Documentation is stored in DocBook format. Start a new translation of the Documentation is stored in DocBook format. Start a new translation of the
manual by copying the English version of the DocBook manual manual by copying the English version of the [DocBook manual][docbook-manual]
(../src/usr/share/gnome/help/diffuse/C/diffuse.xml) and then edit the and then edit the contents.
contents.
The DocBook manual is converted to HTML for Windows and Unix man pages for The DocBook manual is converted to HTML for Windows and Unix man pages for
POSIX platforms. The conversion tools insert some English text that gets POSIX platforms. The conversion tools insert some English text that gets
localised using search and replace. Manually add new search and replace rules localized using search and replace. Manually add new search and replace rules
to these files: to these files:
../windows-installer/translations.txt ../windows-installer/translations.txt
../utils/translations.txt ../utils/translations.txt
The format of each line is: \<language id\>:\<English text\>:\<localised text\> The format of each line is: \<language id\>:\<English text\>:\<localised text\>
[docbook-manual]: ../data/usr/share/gnome/help/diffuse/C/diffuse.xml

857
po/cs.po

File diff suppressed because it is too large Load Diff

838
po/de.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

833
po/es.po

File diff suppressed because it is too large Load Diff

832
po/it.po

File diff suppressed because it is too large Load Diff

826
po/ja.po

File diff suppressed because it is too large Load Diff

819
po/ko.po

File diff suppressed because it is too large Load Diff

829
po/pl.po

File diff suppressed because it is too large Load Diff

834
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

824
po/ru.po

File diff suppressed because it is too large Load Diff

826
po/sv.po

File diff suppressed because it is too large Load Diff

801
po/th.po

File diff suppressed because it is too large Load Diff

View File

@ -20,64 +20,77 @@
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import argparse import argparse
import glob
import os import os
import subprocess import subprocess
import shutil
import tempfile import tempfile
def check_translation(filename): def check_translation(filename):
subprocess.run(["msgfmt", "-c", "-v", filename]) print(f'Validate file "{filename}":')
subprocess.run(['msgfmt', '-c', '-v', filename])
def remove_obsolete_messages(filename):
print(f'Removing obsolete messages in file "{filename}"...')
subprocess.run(['msgattrib', '--no-obsolete', '-o', filename, filename])
def update_translation(filename): def update_translation(filename):
print(f"Updating translation file '{filename}'...") print(f'Updating translation file "{filename}"...')
# Get language # Get language
lang = os.path.splitext(filename)[0] lang = os.path.splitext(filename)[0]
# Move existing .po file to working directory with tempfile.NamedTemporaryFile() as ftmp:
tmpfile = os.path.join(tmpdir, filename) # Create temporary .po file for this language
shutil.move(filename, tmpfile) subprocess.run([
'msginit',
'--no-translator',
'-l',
lang,
'-o',
ftmp.name,
'-i',
'diffuse.pot'])
# Create a new .po file for this language # Merge with the previous translation
emptypofile = os.path.join(tmpdir, f"{lang}.empty.po") subprocess.run(['msgmerge', '-q', '--no-wrap', '-o', filename, filename, ftmp.name])
subprocess.run(["msginit", "--no-wrap", "--no-translator", "-l", lang, "-o", emptypofile, "-i", "diffuse.pot"])
# Merge with the old translation
subprocess.run(["msgmerge", "-q", "--no-wrap", tmpfile, emptypofile, "-o", filename])
# Validate translation # Validate translation
print(f"Validate {filename}:")
check_translation(filename) check_translation(filename)
print(f"Update done.") print('Update done.')
# Setup argument parser
parser = argparse.ArgumentParser(description='Update translation files (.po).')
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')
# Parse command-line arguments if __name__ == '__main__':
args = parser.parse_args() # Setup argument parser
parser = argparse.ArgumentParser(description='Update translation files (.po).')
parser.add_argument('po_files', metavar='filename.po', nargs='+',
help='the translation file')
parser.add_argument('--remove-obsolete', action='store_true',
help='remove obsolete (#~) messages')
parser.add_argument('--check-only', action='store_true',
help='check the PO files')
# Get PO files from command-line # Parse command-line arguments
po_files = args.po_files args = parser.parse_args()
po_files.sort()
if args.check_only: # Get PO files from command-line
for file in po_files: po_files = args.po_files
print(f"Validate {file}:") po_files.sort()
check_translation(file)
exit(0) if args.check_only:
# Validate PO files
for file in po_files:
check_translation(file)
exit(0)
if args.remove_obsolete:
# Remove obsolete messages
for file in po_files:
remove_obsolete_messages(file)
exit(0)
# Create temporary working directory
tmpdir = tempfile.mkdtemp()
try:
# Update PO files # Update PO files
for file in po_files: for file in po_files:
update_translation(file) update_translation(file)
finally:
# Remove working directory
shutil.rmtree(tmpdir)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff