docs: def merge_command(create, backup, base_dir, domain_methods, languages):
      """
      :arg create: whether or not to create directories if they don't
          exist
      :arg backup: whether or not to create backup .po files
      :arg base_dir: BASE_DIR setting
      :arg domain_methods: DOMAIN_METHODS setting
      :arg languages: LANGUAGES setting
  
      """
      locale_dir = os.path.join(base_dir, 'locale')
  
      # Verify existence of msginit and msgmerge
      if not call(['which', 'msginit'], stdout=PIPE) == 0:
          raise CommandError('You do not have gettext installed.')
  
      if not call(['which', 'msgmerge'], stdout=PIPE) == 0:
          raise CommandError('You do not have gettext installed.')
  
      if languages and isinstance(languages[0], (tuple, list)):
          # Django's LANGUAGES setting takes a value like:
          #
          # LANGUAGES = (
          #    ('de', _('German')),
          #    ('en', _('English')),
          # )
          #
          # but we only want the language codes, so we pull the first
          # part from all the tuples.
          languages = [lang[0] for lang in languages]
  
      if create:
          for lang in languages:
              d = os.path.join(locale_dir, lang.replace('-', '_'),
                               'LC_MESSAGES')
              if not os.path.exists(d):
                  os.makedirs(d)
  
      domains = domain_methods.keys()
      for domain in domains:
          print('Merging %s strings to each locale...' % domain)
          domain_pot = os.path.join(locale_dir, 'templates', 'LC_MESSAGES',
                                    '%s.pot' % domain)
          if not os.path.isfile(domain_pot):
              raise CommandError('Can not find %s.pot' % domain)
  
          for locale in os.listdir(locale_dir):
              if ((not os.path.isdir(os.path.join(locale_dir, locale)) or
                   locale.startswith('.') or
                   locale == 'templates')):
                  continue
  
              domain_po = os.path.join(locale_dir, locale, 'LC_MESSAGES',
                                       '%s.po' % domain)
  
              if not os.path.isfile(domain_po):
                  print(' Can not find (%s).  Creating...' % domain_po)
                  p1 = Popen([
                      'msginit',
                      '--no-translator',
                      '--locale=%s' % locale,
                      '--input=%s' % domain_pot,
                      '--output-file=%s' % domain_po,
                      '--width=200'
                  ])
                  p1.communicate()
  
              print('Merging %s.po for %s' % (domain, locale))
              with open(domain_pot) as domain_pot_file:
                  if locale == 'en_US':
                      # Create an English translation catalog, then merge
                      with TemporaryFile('w+t') as enmerged:
                          p2 = Popen(['msgen', '-'], stdin=domain_pot_file,
                                     stdout=enmerged)
                          p2.communicate()
                          _msgmerge(domain_po, enmerged, backup)
                  else:
                      _msgmerge(domain_po, domain_pot_file, backup)
  
          print('Domain %s finished' % domain)
  
      print('All finished')