mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-09 13:24:35 +00:00
Added the --normpo build option
This build command normalizes all PO so that I stop getting spurious diffs whenever I pull from Transifex.
This commit is contained in:
parent
e5ce6680ca
commit
ff782a09f5
10
build.py
10
build.py
@ -45,6 +45,8 @@ def parse_args():
|
||||
help="Generate .pot files from source code.")
|
||||
parser.add_option('--mergepot', action='store_true', dest='mergepot',
|
||||
help="Update all .po files based on .pot files.")
|
||||
parser.add_option('--normpo', action='store_true', dest='normpo',
|
||||
help="Normalize all PO files (do this before commit).")
|
||||
(options, args) = parser.parse_args()
|
||||
return options
|
||||
|
||||
@ -238,6 +240,12 @@ def build_mergepot():
|
||||
loc.merge_pots_into_pos(op.join('qtlib', 'locale'))
|
||||
loc.merge_pots_into_pos(op.join('cocoalib', 'locale'))
|
||||
|
||||
def build_normpo():
|
||||
loc.normalize_all_pos('locale')
|
||||
loc.normalize_all_pos(op.join('hscommon', 'locale'))
|
||||
loc.normalize_all_pos(op.join('qtlib', 'locale'))
|
||||
loc.normalize_all_pos(op.join('cocoalib', 'locale'))
|
||||
|
||||
def build_cocoa_proxy_module():
|
||||
print("Building Cocoa Proxy")
|
||||
import objp.p2o
|
||||
@ -339,6 +347,8 @@ def main():
|
||||
build_updatepot()
|
||||
elif options.mergepot:
|
||||
build_mergepot()
|
||||
elif options.normpo:
|
||||
build_normpo()
|
||||
elif options.cocoa_ext:
|
||||
build_cocoa_proxy_module()
|
||||
build_cocoa_bridging_interfaces(edition)
|
||||
|
@ -77,6 +77,24 @@ def merge_po_and_preserve(source, dest):
|
||||
destpo.append(entry)
|
||||
destpo.save()
|
||||
|
||||
def normalize_all_pos(base_folder):
|
||||
"""Normalize the format of .po files in base_folder.
|
||||
|
||||
When getting POs from external sources, such as Transifex, we end up with spurious diffs because
|
||||
of a difference in the way line wrapping is handled. It wouldn't be a big deal if it happened
|
||||
once, but these spurious diffs keep overwriting each other, and it's annoying.
|
||||
|
||||
Our PO files will keep polib's format. Call this function to ensure that freshly pulled POs
|
||||
are of the right format before committing them.
|
||||
"""
|
||||
langs = get_langs(base_folder)
|
||||
for lang in langs:
|
||||
pofolder = op.join(base_folder, lang, LC_MESSAGES)
|
||||
pofiles = files_with_ext(pofolder, '.po')
|
||||
for pofile in pofiles:
|
||||
p = polib.pofile(pofile)
|
||||
p.save()
|
||||
|
||||
#--- Cocoa
|
||||
def all_lproj_paths(folder):
|
||||
return files_with_ext(folder, '.lproj')
|
||||
|
Loading…
x
Reference in New Issue
Block a user