Merge pull request #80 from MightyCreak/fix-translations
Add POTFILES.in and update translations
This commit is contained in:
commit
524b5c4fc0
|
@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Changed AppID to io.github.mightycreak.Diffuse (as explained in
|
- Changed AppID to io.github.mightycreak.Diffuse (as explained in
|
||||||
[Flatpak documentation](https://docs.flatpak.org/en/latest/conventions.html#application-ids))
|
[Flatpak documentation](https://docs.flatpak.org/en/latest/conventions.html#application-ids))
|
||||||
- Renamed `translations/` to `po/`
|
- Renamed `translations/` to `po/`
|
||||||
|
- Now uses POTFILES.in to list the files to translate
|
||||||
|
- Translation strings are no longer sorted alphabetically, this will help when there will be
|
||||||
|
several files in POTFILES.in
|
||||||
|
- Updated the documentation and script in the `po/` directory
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
# List of source files which contain translatable strings.
|
||||||
|
src/usr/bin/diffuse.py.in
|
27
po/README.md
27
po/README.md
|
@ -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
|
translations. Replace all instances of "ja" with the code for the desired
|
||||||
language.
|
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.
|
Use `update-translations.py` to update one or more PO files.
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,6 @@ import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
def generate_pot_file():
|
|
||||||
subprocess.run(["xgettext", "-s", "-o", "diffuse.pot", "-L", "Python", "../src/usr/bin/diffuse"])
|
|
||||||
|
|
||||||
def check_translation(filename):
|
def check_translation(filename):
|
||||||
subprocess.run(["msgfmt", "-c", "-v", filename])
|
subprocess.run(["msgfmt", "-c", "-v", filename])
|
||||||
|
|
||||||
|
@ -61,8 +58,6 @@ parser.add_argument('po_files', metavar='filename.po', nargs='+',
|
||||||
help='the translation file')
|
help='the translation file')
|
||||||
parser.add_argument('-c', '--check-only', action='store_true',
|
parser.add_argument('-c', '--check-only', action='store_true',
|
||||||
help='check the PO files')
|
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
|
# Parse command-line arguments
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -77,11 +72,6 @@ if args.check_only:
|
||||||
check_translation(file)
|
check_translation(file)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if not args.no_pot_generation:
|
|
||||||
# Generate diffuse.pot file
|
|
||||||
print("Generate 'diffuse.pot'.")
|
|
||||||
generate_pot_file()
|
|
||||||
|
|
||||||
# Create temporary working directory
|
# Create temporary working directory
|
||||||
tmpdir = tempfile.mkdtemp()
|
tmpdir = tempfile.mkdtemp()
|
||||||
try:
|
try:
|
||||||
|
|
1444
po/zh_CN.po
1444
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1470
po/zh_TW.po
1470
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue