Skip to content

Commit

Permalink
Merge pull request #66 from edx/skip-merg-files-check
Browse files Browse the repository at this point in the history
-force argument to skip merge files check in Validate script
  • Loading branch information
Ayub-Khan authored Apr 4, 2018
2 parents 1ac3341 + 6c2cfe7 commit 73b9fbc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
9 changes: 7 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,17 @@ Details of the config.yaml file are in `edx-platform/conf/locale/config.yaml

Changes
=======
0.4.3
v0.4.4
-------

* Added check-all (check all po files) argument to validate command.

v0.4.3
-------

* Specify Language header for generated dummy po files.

0.4.2
v0.4.2
-------

* Specified utf-8 encoding for .yaml file.
Expand Down
2 changes: 1 addition & 1 deletion i18n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from . import config

__version__ = '0.4.3'
__version__ = '0.4.4'


class Runner:
Expand Down
17 changes: 12 additions & 5 deletions i18n/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
log = logging.getLogger(__name__)


def validate_po_files(configuration, locale_dir, root_dir=None, report_empty=False):
def validate_po_files(configuration, locale_dir, root_dir=None, report_empty=False, check_all=False):
"""
Validate all of the po files found in the root directory that are not product of a merge.
Expand All @@ -35,9 +35,9 @@ def validate_po_files(configuration, locale_dir, root_dir=None, report_empty=Fal
__, ext = os.path.splitext(name)
filename = os.path.join(dirpath, name)

# Validate only .po files that are not product of a merge (see generate.py).
# Validate only .po files that are not product of a merge (see generate.py) unless check_all is true.
# If django-partial.po has a problem, then django.po will also, so don't report it.
if ext.lower() == '.po' and os.path.basename(filename) not in merged_files:
if ext.lower() == '.po' and (check_all or os.path.basename(filename) not in merged_files):

# First validate the format of this file
if msgfmt_check_po_file(locale_dir, filename):
Expand Down Expand Up @@ -222,6 +222,12 @@ def add_args(self):
help="Includes empty translation strings in .prob files."
)

self.parser.add_argument(
'-ca', '--check-all',
action='store_true',
help="Validate all po files, including those that are the product of a merge (see generate.py)."
)

def run(self, args):
"""
Main entry point for script
Expand All @@ -241,7 +247,7 @@ def run(self, args):

if not languages:
# validate all languages
if validate_po_files(self.configuration, locale_dir, report_empty=args.empty):
if validate_po_files(self.configuration, locale_dir, report_empty=args.empty, check_all=args.check_all):
exit_code = 1
else:
# languages will be a list of language codes; test each language.
Expand All @@ -252,7 +258,8 @@ def run(self, args):
log.error(" %s is not a valid directory.\nSkipping language '%s'", root_dir, language)
continue
# If we found the language code's directory, validate the files.
if validate_po_files(self.configuration, locale_dir, root_dir=root_dir, report_empty=args.empty):
if validate_po_files(self.configuration, locale_dir, root_dir=root_dir, report_empty=args.empty,
check_all=args.check_all):
exit_code = 1

return exit_code
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='edx-i18n-tools',
version='0.4.3',
version='0.4.4',
description='edX Internationalization Tools',
author='edX',
author_email='[email protected]',
Expand Down

0 comments on commit 73b9fbc

Please sign in to comment.