Permalink
Browse files

[bug 902108] Add dennis v0.3.7 to vendor/

This updates polib and adds dennis to vendor/. Now we can do things
like:

    ./manage.py lint
    ./manage.py translate

Also, this nixes poxx.py and localelinter.py which aren't needed
anymore.
  • Loading branch information...
willkg committed Oct 16, 2013
1 parent a2d23e9 commit 34f54736ef06f4c55e408905175f0e2dc2e480b7
Showing with 10,748 additions and 546 deletions.
  1. +3 −0 .gitmodules
  2. +14 −8 docs/localization.rst
  3. +1 −0 kitsune/settings.py
  4. +0 −175 scripts/localelinter.py
  5. +0 −361 scripts/poxx.py
  6. +2 −2 scripts/test_locales.sh
  7. +2 −0 vendor/kitsune.pth
  8. +157 −0 vendor/packages/polib/CHANGELOG
  9. +19 −0 vendor/packages/polib/LICENSE
  10. +210 −0 vendor/packages/polib/PKG-INFO
  11. +22 −0 vendor/packages/polib/README.rst
  12. +130 −0 vendor/packages/polib/docs/Makefile
  13. +62 −0 vendor/packages/polib/docs/api.rst
  14. +218 −0 vendor/packages/polib/docs/conf.py
  15. +36 −0 vendor/packages/polib/docs/contributing.rst
  16. +38 −0 vendor/packages/polib/docs/index.rst
  17. +81 −0 vendor/packages/polib/docs/installation.rst
  18. +170 −0 vendor/packages/polib/docs/make.bat
  19. +18 −0 vendor/packages/polib/docs/projects.rst
  20. +206 −0 vendor/packages/polib/docs/quickstart.rst
  21. +210 −0 vendor/packages/polib/pip-egg-info/polib.egg-info/PKG-INFO
  22. +5 −0 vendor/packages/polib/pip-egg-info/polib.egg-info/SOURCES.txt
  23. +1 −0 vendor/packages/polib/pip-egg-info/polib.egg-info/dependency_links.txt
  24. +1 −0 vendor/packages/polib/pip-egg-info/polib.egg-info/top_level.txt
  25. +1,751 −0 vendor/packages/polib/polib.py
  26. +7 −0 vendor/packages/polib/runtests.sh
  27. +68 −0 vendor/packages/polib/setup.py
  28. +14 −0 vendor/packages/polib/tests/test_fuzzy_header.po
  29. +42 −0 vendor/packages/polib/tests/test_indented.po
  30. BIN vendor/packages/polib/tests/test_iso-8859-15.mo
  31. +45 −0 vendor/packages/polib/tests/test_iso-8859-15.po
  32. +39 −0 vendor/packages/polib/tests/test_merge.pot
  33. +48 −0 vendor/packages/polib/tests/test_merge_after.po
  34. +36 −0 vendor/packages/polib/tests/test_merge_before.po
  35. BIN vendor/packages/polib/tests/test_msgctxt.mo
  36. +14 −0 vendor/packages/polib/tests/test_msgctxt.po
  37. +55 −0 vendor/packages/polib/tests/test_noencoding.po
  38. +44 −0 vendor/packages/polib/tests/test_obsolete_previousmsgid.po
  39. +116 −0 vendor/packages/polib/tests/test_pofile_helpers.po
  40. +23 −0 vendor/packages/polib/tests/test_save_as_mofile.po
  41. +2,495 −0 vendor/packages/polib/tests/test_save_as_pofile.po
  42. +17 −0 vendor/packages/polib/tests/test_unusual_metadata_location.po
  43. BIN vendor/packages/polib/tests/test_utf8.mo
  44. +3,485 −0 vendor/packages/polib/tests/test_utf8.po
  45. +217 −0 vendor/packages/polib/tests/test_weird_occurrences.po
  46. +12 −0 vendor/packages/polib/tests/test_wrap.po
  47. +613 −0 vendor/packages/polib/tests/tests.py
  48. +1 −0 vendor/src/dennis
View
@@ -163,3 +163,6 @@
[submodule "vendor/src/django-badger"]
path = vendor/src/django-badger
url = https://github.com/mozilla/django-badger
+[submodule "vendor/src/dennis"]
+ path = vendor/src/dennis
+ url = https://github.com/willkg/dennis.git
View
@@ -364,15 +364,9 @@ When we add strings that need to be localized, it can take a couple of
weeks for us to get translations of those localized strings. This
makes it difficult to find localization issues.
-Enter poxx.
+Enter `dennis <https://github.com/willkg/dennis/>`_.
-Requirements:
-
-1. Install polib - ``pip install polib``
-2. Get ``compile-mo.sh``. You can do this by getting the
- localizations. See :ref:`getting-localizations`.
-
-After getting requirements::
+Run::
$ ./scripts/test_locales.sh
@@ -399,6 +393,18 @@ Strings in the Pirate translation have the following properties:
available on -dev, -stage, or -prod.
+Linting localized strings
+=========================
+
+You can lint localized strings for warnings and errors::
+
+ $ ./manage.py lint locales/
+
+You can see help text::
+
+ $ ./manage.py lint
+
+
.. _getting-localizations:
Getting the Localizations
View
@@ -466,6 +466,7 @@
'django.contrib.admin',
'django_browserid',
'kitsune.users',
+ 'dennis.django_dennis',
'tower',
'jingo_minify',
'authority',
View
@@ -1,175 +0,0 @@
-#!/usr/bin/env python
-
-import itertools
-import optparse
-import os
-import re
-import sys
-
-try:
- import polib # from http://bitbucket.org/izi/polib
-except ImportError:
- print 'You need to install polib. Do:'
- print ''
- print ' pip install polib'
- sys.exit()
-
-
-USAGE = 'usage: %prog [FILE|DIR]'
-
-
-INTERP_RE = re.compile(
- r'('
- r'(?:%(?:[(]\S+?[)])?[#0+-]?[\.\d\*]*[hlL]?[diouxXeEfFgGcrs%])'
- r'|'
- r'(?:\{\S+?\})'
- r')')
-
-
-def asciify(thing):
- if isinstance(thing, basestring):
- return thing.encode('ascii', 'replace')
- elif isinstance(thing, (list, tuple)):
- return [asciify(s) for s in thing]
- return repr(thing)
-
-
-def extract_tokens(msg):
- try:
- tokens = [token for token in INTERP_RE.findall(msg)]
- tokens.sort()
- return tuple(tokens)
- except TypeError:
- print 'TYPEERROR', repr(msg)
-
-
-def equal(id_tokens, str_tokens):
- if str_tokens is None:
- # This means they haven't translated the msgid, so there's
- # no entry. I'm pretty sure this only applies to plurals.
- return True
-
- id_tokens = list(id_tokens)
- str_tokens = list(str_tokens)
-
- for id_token, str_token in itertools.izip_longest(
- id_tokens, str_tokens, fillvalue=None):
- if id_token is None or str_token is None:
- return False
- if id_token != str_token:
- return False
- return True
-
-
-def verify(msgid, id_text, id_tokens, str_text, str_tokens, index):
- # If the token lists aren't equal and there's a msgstr, then
- # that's a problem. If there's no msgstr, it means it hasn't been
- # translated.
- if not equal(id_tokens, str_tokens) and str_text.strip():
- print ('\nError for msgid: {msgid}\n'
- 'tokens: {id_tokens} VS. {str_tokens}\n'
- '{key}: {id_text}\n'
- 'msgstr{index}: {str_text}'.format(
- index='[{index}]'.format(index=index) if index is not None else '',
- key='id' if index in (None, '0') else 'plural',
- msgid=asciify(msgid),
- id_text=asciify(id_text),
- id_tokens=', '.join(asciify(id_tokens)),
- str_text=asciify(str_text),
- str_tokens=', '.join(asciify(str_tokens))))
- return False
-
- return True
-
-
-def verify_file(fname):
- """Verifies file fname
-
- This prints to stdout errors it found in fname. It returns the
- number of errors.
-
- """
- if not fname.endswith('.po'):
- print '{fname} is not a .po file.'.format(fname=fname)
- return 1
-
- print 'Working on {fname}'.format(fname=fname)
-
- po = polib.pofile(fname)
-
- count = 0
- bad_count = 0
-
- for entry in po:
- if not entry.msgid_plural:
- if not entry.msgid and entry.msgstr:
- continue
- id_tokens = extract_tokens(entry.msgid)
- str_tokens = extract_tokens(entry.msgstr)
-
- if not verify(entry.msgid, entry.msgid, id_tokens, entry.msgstr,
- str_tokens, None):
- bad_count += 1
-
- else:
- for key in sorted(entry.msgstr_plural.keys()):
- if key == '0':
- # This is the 1 case.
- text = entry.msgid
- else:
- text = entry.msgid_plural
- id_tokens = extract_tokens(text)
-
- str_tokens = extract_tokens(entry.msgstr_plural[key])
- if not verify(entry.msgid, text, id_tokens,
- entry.msgstr_plural[key], str_tokens, key):
- bad_count += 1
-
- count += 1
-
- print ('\nVerified {count} messages in {fname}. '
- '{badcount} possible errors.'.format(
- count=count, fname=fname, badcount=bad_count))
-
- return bad_count
-
-
-def verify_directory(dir):
- po_files = {}
- for root, dirs, files in os.walk(dir):
- for fn in files:
- if not fn.endswith('.po'):
- continue
-
- fn = os.path.join(root, fn)
-
- po_files[fn] = verify_file(fn)
- print '---'
-
- total_errors = sum(val for key, val in po_files.items())
- if total_errors == 0:
- return 0
-
- print 'Problem locale files:'
- po_files = sorted([(val, key) for key, val in po_files.items()],
- reverse=True)
- for val, key in po_files:
- if val:
- print '{val:>5} {key}'.format(key=key, val=val)
-
- return 1
-
-
-if __name__ == '__main__':
- parser = optparse.OptionParser(usage=USAGE)
- (options, args) = parser.parse_args()
-
- if not args:
- parser.print_help()
- sys.exit(1)
-
- if os.path.isdir(args[0]):
- sys.exit(verify_directory(args[0]))
-
- # Return 0 if everything was fine or 1 if there were errors.
- sys.exit(verify_file(args[0]) != 0)
Oops, something went wrong.

0 comments on commit 34f5473

Please sign in to comment.