diff --git a/README.rst b/README.rst index 43b3175..4c16ff4 100644 --- a/README.rst +++ b/README.rst @@ -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. diff --git a/i18n/__init__.py b/i18n/__init__.py index 2c8db11..ee66fdd 100644 --- a/i18n/__init__.py +++ b/i18n/__init__.py @@ -6,7 +6,7 @@ from . import config -__version__ = '0.4.3' +__version__ = '0.4.4' class Runner: diff --git a/i18n/validate.py b/i18n/validate.py index 9ecde4f..f92faa6 100644 --- a/i18n/validate.py +++ b/i18n/validate.py @@ -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. @@ -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): @@ -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 @@ -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. @@ -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 diff --git a/setup.py b/setup.py index 1af1c84..60fd68f 100755 --- a/setup.py +++ b/setup.py @@ -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='oscm@edx.org',