Merge pull request #128 from MightyCreak/update-translations
Update POTFILES.in and .pot
This commit is contained in:
commit
3fcb76d22c
1
.flake8
1
.flake8
|
@ -1,6 +1,7 @@
|
|||
[flake8]
|
||||
builtins = _
|
||||
max-line-length = 100
|
||||
show-source = true
|
||||
|
||||
# Temporary
|
||||
exclude = src/diffuse/main.py
|
||||
|
|
|
@ -22,10 +22,10 @@ jobs:
|
|||
- run: pip install -r requirements.txt
|
||||
|
||||
- name: Flake8
|
||||
run: flake8 src/
|
||||
run: flake8 src/ po/
|
||||
|
||||
- name: MyPy
|
||||
run: mypy src/
|
||||
run: mypy src/ po/
|
||||
|
||||
meson-build-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## 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
|
||||
|
||||
### Added
|
||||
|
@ -16,7 +25,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Changed
|
||||
- main.py slimmed down by about 5000 lines
|
||||
- The new widgets.py is a bit fat though (~4000 lines)
|
||||
- Updated the translation files
|
||||
|
||||
### Fixed
|
||||
- The intense code cleaning seems to have fixed a bug with the `-c` argument
|
||||
|
|
|
@ -36,6 +36,10 @@ This is the easiest way to install Diffuse:
|
|||
flatpak install io.github.mightycreak.Diffuse
|
||||
```
|
||||
|
||||
## Translators
|
||||
|
||||
Please refer to the [translation documentation](po/README.md).
|
||||
|
||||
## Developers
|
||||
|
||||
### Setup
|
||||
|
@ -128,7 +132,7 @@ the on-line help documentation using a web browser.
|
|||
|
||||
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)
|
||||
license.
|
||||
|
||||
|
|
|
@ -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.
|
||||
</p>
|
||||
</description>
|
||||
|
||||
<metadata_license>FSFAP</metadata_license>
|
||||
<project_license>GPL-2.0-or-later</project_license>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<launchable type="desktop-id">io.github.mightycreak.Diffuse.desktop</launchable>
|
||||
<url type="homepage">https://mightycreak.github.io/diffuse/</url>
|
||||
<url type="bugtracker">https://github.com/MightyCreak/diffuse/issues</url>
|
||||
|
||||
<screenshots>
|
||||
<screenshot type="default">
|
||||
<caption>Main window: diff between two files</caption>
|
||||
<image>https://mightycreak.github.io/diffuse/images/screenshot_v0.7.0.png</image>
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
|
||||
<!-- Translators: no need to translate after this comment -->
|
||||
<developer_name>Romain Failliot</developer_name>
|
||||
<update_contact>romain.failliot@foolstep.com</update_contact>
|
||||
|
||||
<releases>
|
||||
<release version="0.7.3" date="2021-11-22">
|
||||
<description>
|
||||
|
@ -207,6 +214,4 @@
|
|||
</description>
|
||||
</release>
|
||||
</releases>
|
||||
<developer_name>Romain Failliot</developer_name>
|
||||
<update_contact>romain.failliot@foolstep.com</update_contact>
|
||||
</component>
|
|
@ -17,8 +17,8 @@ if desktop_utils.found()
|
|||
endif
|
||||
|
||||
appstream_file = i18n.merge_file(
|
||||
input: 'io.github.mightycreak.Diffuse.metainfo.xml.in',
|
||||
output: 'io.github.mightycreak.Diffuse.metainfo.xml',
|
||||
input: 'io.github.mightycreak.Diffuse.appdata.xml.in',
|
||||
output: 'io.github.mightycreak.Diffuse.appdata.xml',
|
||||
po_dir: '../po',
|
||||
install: true,
|
||||
install_dir: join_paths(get_option('datadir'), 'appdata')
|
||||
|
|
|
@ -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
|
|
@ -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
|
67
po/README.md
67
po/README.md
|
@ -15,7 +15,9 @@ Create PO template
|
|||
To create or update the PO template (`po/diffuse.pot`), use this command at the
|
||||
repo root:
|
||||
|
||||
```sh
|
||||
xgettext -o po/diffuse.pot -f po/POTFILES.in
|
||||
```
|
||||
|
||||
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
|
||||
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
|
||||
--------------------
|
||||
|
||||
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:
|
||||
|
||||
```sh
|
||||
./update-translations.py ja.po ko.po
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
Generate 'diffuse.pot'.
|
||||
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.
|
||||
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
|
||||
translations.
|
||||
|
||||
Validate a translation
|
||||
----------------------
|
||||
|
@ -72,40 +69,30 @@ Command-line:
|
|||
./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
|
||||
==================
|
||||
|
||||
Localised text for the system menu (name and comment) should be manually
|
||||
added to the desktop file:
|
||||
Localized text for the Microsoft Windows installer is stored in separate ISL
|
||||
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
|
||||
|
||||
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.
|
||||
[english-win-docs]: ../windows-installer/en.isl
|
||||
|
||||
Documentation
|
||||
=============
|
||||
|
||||
Documentation is stored in DocBook format. Start a new translation of the
|
||||
manual by copying the English version of the DocBook manual
|
||||
(../src/usr/share/gnome/help/diffuse/C/diffuse.xml) and then edit the
|
||||
contents.
|
||||
manual by copying the English version of the [DocBook manual][docbook-manual]
|
||||
and then edit the contents.
|
||||
|
||||
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
|
||||
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:
|
||||
|
||||
../windows-installer/translations.txt
|
||||
../utils/translations.txt
|
||||
|
||||
The format of each line is: \<language id\>:\<English text\>:\<localised text\>
|
||||
|
||||
[docbook-manual]: ../data/usr/share/gnome/help/diffuse/C/diffuse.xml
|
||||
|
|
783
po/diffuse.pot
783
po/diffuse.pot
File diff suppressed because it is too large
Load Diff
829
po/pt_BR.po
829
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
|
@ -20,43 +20,56 @@
|
|||
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
|
||||
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):
|
||||
print(f"Updating translation file '{filename}'...")
|
||||
print(f'Updating translation file "{filename}"...')
|
||||
|
||||
# Get language
|
||||
lang = os.path.splitext(filename)[0]
|
||||
|
||||
# Move existing .po file to working directory
|
||||
tmpfile = os.path.join(tmpdir, filename)
|
||||
shutil.move(filename, tmpfile)
|
||||
with tempfile.NamedTemporaryFile() as ftmp:
|
||||
# Create temporary .po file for this language
|
||||
subprocess.run([
|
||||
'msginit',
|
||||
'--no-translator',
|
||||
'-l',
|
||||
lang,
|
||||
'-o',
|
||||
ftmp.name,
|
||||
'-i',
|
||||
'diffuse.pot'])
|
||||
|
||||
# Create a new .po file for this language
|
||||
emptypofile = os.path.join(tmpdir, f"{lang}.empty.po")
|
||||
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])
|
||||
# Merge with the previous translation
|
||||
subprocess.run(['msgmerge', '-q', '--no-wrap', '-o', filename, filename, ftmp.name])
|
||||
|
||||
# Validate translation
|
||||
print(f"Validate {filename}:")
|
||||
check_translation(filename)
|
||||
|
||||
print(f"Update done.")
|
||||
print('Update done.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 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',
|
||||
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')
|
||||
|
||||
# Parse command-line arguments
|
||||
|
@ -67,17 +80,17 @@ po_files = args.po_files
|
|||
po_files.sort()
|
||||
|
||||
if args.check_only:
|
||||
# Validate PO files
|
||||
for file in po_files:
|
||||
print(f"Validate {file}:")
|
||||
check_translation(file)
|
||||
exit(0)
|
||||
|
||||
# Create temporary working directory
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
try:
|
||||
if args.remove_obsolete:
|
||||
# Remove obsolete messages
|
||||
for file in po_files:
|
||||
remove_obsolete_messages(file)
|
||||
exit(0)
|
||||
|
||||
# Update PO files
|
||||
for file in po_files:
|
||||
update_translation(file)
|
||||
finally:
|
||||
# Remove working directory
|
||||
shutil.rmtree(tmpdir)
|
||||
|
|
800
po/zh_CN.po
800
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
800
po/zh_TW.po
800
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue