Permalink
Browse files

Add xx locale for testing

This adds:

1. xx locale which is Pirate
2. scripts/poxx.py which translates a .po file into Pirate
3. scripts/test_locale.sh which extracts strings and runs poxx.py

The xx locale is set up so that it doesn't show up in the language
chooser lists, but you can explicitly specify it in the url:

    http://localhost:8000/xx/home

The locale is only available translated locally--it will show up
as English on -dev, -stage, and -prod. It'll show up as English
if you don't run scripts/test_locale.sh.
  • Loading branch information...
1 parent 5745e21 commit 9d7bda844e8fbf4363d4af3887597e331b98b9b8 @willkg willkg committed Jan 25, 2013
Showing with 400 additions and 7 deletions.
  1. +5 −5 apps/sumo/tests/test_locale_middleware.py
  2. +45 −1 docs/localization.rst
  3. +5 −0 lib/languages.json
  4. +306 −0 scripts/poxx.py
  5. +31 −0 scripts/test_locales.sh
  6. +5 −1 settings.py
  7. +3 −0 templates/base.html
@@ -19,9 +19,9 @@ def test_default_redirect(self):
HTTP_ACCEPT_LANGUAGE='fr-fr')
self.assertRedirects(response, '/fr/search', status_code=302)
- # User wants xx, we send en-US
+ # User wants xy (which doesn't exist), we send en-US
response = self.client.get('/search', follow=True,
- HTTP_ACCEPT_LANGUAGE='xx')
+ HTTP_ACCEPT_LANGUAGE='xy')
self.assertRedirects(response, '/en-US/search', status_code=302)
# User doesn't know what they want, we send en-US
@@ -77,7 +77,7 @@ def test_fr_FR(self):
eq_('fr', best)
def test_non_existent(self):
- best = get_best_language('xx-YY, xx;q=0.8')
+ best = get_best_language('xy-YY, xy;q=0.8')
eq_(False, best)
def test_prefix_matching(self):
@@ -100,13 +100,13 @@ def test_get_non_supported(self):
eq_(None, get_non_supported('yy'))
@mock.patch.object(settings._wrapped, 'NON_SUPPORTED_LOCALES',
- {'nn-NO': 'no', 'xx': None})
+ {'nn-NO': 'no', 'xy': None})
def test_middleware(self):
response = self.client.get('/nn-NO/home', follow=True)
self.assertRedirects(response, '/no/home', status_code=302)
response = self.client.get('/nn-no/home', follow=True)
self.assertRedirects(response, '/no/home', status_code=302)
- response = self.client.get('/xx/home', follow=True)
+ response = self.client.get('/xy/home', follow=True)
self.assertRedirects(response, '/en-US/home', status_code=302)
View
@@ -301,10 +301,54 @@ By default, this will write all the strings to `apps/sumo/db_strings.py`
and they will get picked up during the normal string extraction (see below).
+Testing localized strings
+=========================
+
+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.
+
+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::
+
+ $ ./scripts/test_locales.sh
+
+It'll extract all the strings, create a ``.pot`` file, then create a
+Pirate translation of all strings. The Pirate strings are available in
+the xx locale. After running the ``test_locales.sh`` script, you can
+access the xx locale with:
+
+ http://localhost:8000/xx/
+
+Strings in the Pirate translation have the following properties:
+
+1. they are longer than the English string: helps us find layout and
+ wrapping issues
+2. they have at least one unicode character: helps us find unicode
+ issues
+3. they are easily discernable from the English versions: helps us
+ find strings that aren't translated
+
+
+.. Note::
+
+ The xx locale is only available on your local machine. It is not
+ available on -dev, -stage, or -prod.
+
+
+.. _getting-localizations:
+
Getting the Localizations
=========================
-Localizations are not stored in this repository, but are in Mozilla's SVN::
+Localizations are not stored in this repository, but are in Mozilla's SVN:
http://svn.mozilla.org/projects/sumo/locales
View
@@ -548,5 +548,10 @@
"iso639_1": null,
"english": "Songhay",
"native": "So\u014Bay"
+ },
+ "xx": {
+ "iso639_1": "xx",
+ "english": "Pirate",
+ "native": "Pirate ARrr!"
}
}
Oops, something went wrong.

0 comments on commit 9d7bda8

Please sign in to comment.