-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9483a24
commit 513e25d
Showing
5 changed files
with
47 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# pylint: disable=missing-docstring,no-self-use,wrong-import-order,wrong-import-position,invalid-name | ||
|
||
import sys | ||
from glob import glob | ||
|
||
import polib | ||
|
||
original_file = 'resources/language/resource.language.en_gb/strings.po' | ||
original = polib.pofile(original_file, wrapwidth=0) | ||
|
||
for translated_file in glob('resources/language/resource.language.*/strings.po'): | ||
# Skip original file | ||
if translated_file == original_file: | ||
continue | ||
print('Updating %s...' % translated_file) | ||
|
||
# Load po-files | ||
translated = polib.pofile(translated_file, wrapwidth=0) | ||
|
||
for entry in original: | ||
# Find a translation | ||
translation = translated.find(entry.msgctxt, 'msgctxt') | ||
|
||
if translation and entry.msgid == translation.msgid: | ||
entry.msgstr = translation.msgstr | ||
|
||
original.metadata = translated.metadata | ||
|
||
if sys.platform.startswith('win'): | ||
# On Windows save the file keeping the Linux return character | ||
with open(translated_file, 'wb') as _file: | ||
content = str(original).encode('utf-8') | ||
content = content.replace(b'\r\n', b'\n') | ||
_file.write(content) | ||
else: | ||
# Save it now over the translation | ||
original.save(translated_file) |
This file was deleted.
Oops, something went wrong.