Chris Beaven avatar Chris Beaven committed f4a070a

Fix "McDonald" title case

Comments (0)

Files changed (2)

django_countries/bin/regenerate.py

 OFFICIAL_COUNTRIES_LINE = u'    %(code)r: %(name)r,'
 COUNTRIES_LINE = u'    (%(code)r, _(%(name)r)),'
 RE_VALID_LINE = re.compile(r'\s*(?P<name>.+);(?P<code>[A-Z]{2})\s*$')
-RE_ACRONYM = re.compile('\b[A-Z](\.[A-Z])+\b')
-
+RE_ACRONYM = re.compile(r'\b[A-Z](\.[A-Z])+\b')
+RE_MC = re.compile(r'\b(Mc)(\w)')
 
 def _cmp_value(value):
     """
             # Temporarily add on a space so titlecase doesn't think that ending
             # shortwords should be titled.
             rest = titlecase('%s ' % rest)[:-1]
-            countries_plus.append(('%s %s' % (rest, important), code))
+            plus_name = '%s %s' % (rest, important)
+            plus_name = RE_MC.sub(lambda match: '%s%s' %
+                                     (match.group(1), match.group(2).upper()),
+                                  plus_name)
+            countries_plus.append((plus_name, code))
             name = '%s, %s' % (important, rest)
         else:
             name = titlecase(name)
+        name = RE_MC.sub(lambda match: '%s%s' % (match.group(1),
+                                                 match.group(2).upper()), name)
         country_data['name'] = name
         countries_lines.append(COUNTRIES_LINE % country_data)
         countries_plus.append((name, code))

django_countries/countries.py

     ('GW', _(u'Guinea-bissau')),
     ('GY', _(u'Guyana')),
     ('HT', _(u'Haiti')),
-    ('HM', _(u'Heard Island and Mcdonald Islands')),
+    ('HM', _(u'Heard Island and McDonald Islands')),
     ('VA', _(u'Holy See (Vatican City State)')),
     ('HN', _(u'Honduras')),
     ('HK', _(u'Hong Kong')),
     ('GW', _(u'Guinea-bissau')),
     ('GY', _(u'Guyana')),
     ('HT', _(u'Haiti')),
-    ('HM', _(u'Heard Island and Mcdonald Islands')),
+    ('HM', _(u'Heard Island and McDonald Islands')),
     ('VA', _(u'Holy See (Vatican City State)')),
     ('HN', _(u'Honduras')),
     ('HK', _(u'Hong Kong')),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.