Beispiel #1
0
 def test_po_to_langfiles(self, langfiles_mock, append_mock):
     """Should get the correct messages for the correct langfile."""
     # This should exclude the supported device message from the pot file.
     langfiles_mock.return_value = ['some_lang_files',
                                    'firefox/fx']
     pot_to_langfiles()
     append_mock.assert_called_once_with(ANY, self.good_messages)
Beispiel #2
0
 def test_po_to_langfiles(self, langfiles_mock, append_mock):
     """Should get the correct messages for the correct langfile."""
     # This should exclude the supported device message from the pot file.
     langfiles_mock.return_value = ['some_lang_files',
                                    'firefox/fx']
     pot_to_langfiles('messages')
     append_mock.assert_called_with(ANY, self.good_messages)
Beispiel #3
0
    def handle(self, *args, **options):
        filenames = options['filenames']
        if filenames:
            # mimics puente.management.commands.extract for a list of files
            outputdir = os.path.join(settings.ROOT, 'locale', 'templates',
                                     'LC_MESSAGES')
            if not os.path.isdir(outputdir):
                os.makedirs(outputdir)

            catalog = Catalog(
                header_comment='',
                project=get_setting('PROJECT'),
                version=get_setting('VERSION'),
                msgid_bugs_address=get_setting('MSGID_BUGS_ADDRESS'),
                charset='utf-8',
            )

            for filename, lineno, msg, cmts, ctxt in extract_from_files(
                    filenames):
                catalog.add(msg,
                            None, [(filename, lineno)],
                            auto_comments=cmts,
                            context=ctxt)

            with open(os.path.join(outputdir, '%s.pot' % DOMAIN), 'wb') as fp:
                write_po(fp, catalog, width=80)
        else:
            # This is basically a wrapper around the puente extract
            # command, we might want to do some things around this in the
            # future
            gettext_extract()
        pot_to_langfiles(DOMAIN)
Beispiel #4
0
    def handle(self, *args, **options):
        if args:
            # mimics puente.management.commands.extract for a list of files
            outputdir = os.path.join(settings.ROOT, 'locale', 'templates',
                                     'LC_MESSAGES')
            if not os.path.isdir(outputdir):
                os.makedirs(outputdir)

            catalog = Catalog(
                header_comment='',
                project=get_setting('PROJECT'),
                version=get_setting('VERSION'),
                msgid_bugs_address=get_setting('MSGID_BUGS_ADDRESS'),
                charset='utf-8',
            )

            for filename, lineno, msg, cmts, ctxt in extract_from_files(args):
                catalog.add(msg, None, [(filename, lineno)], auto_comments=cmts,
                            context=ctxt)

            with open(os.path.join(outputdir, '%s.pot' % DOMAIN), 'wb') as fp:
                write_po(fp, catalog, width=80)
        else:
            # This is basically a wrapper around the puente extract
            # command, we might want to do some things around this in the
            # future
            gettext_extract()
        pot_to_langfiles(DOMAIN)
Beispiel #5
0
 def test_uses_default_lang_files(self, pl_mock):
     """Should use the default files from settings"""
     pl_mock.return_value = {}  # avoid side-effects
     pot_to_langfiles()
     calls = [(('{0}/locale/templates/{1}.lang'.format(ROOT, lf),),
               {'skip_untranslated': False})
              for lf in DOTLANG_FILES]
     pl_mock.assert_has_calls(calls)
Beispiel #6
0
 def test_uses_default_lang_files(self, pl_mock):
     """Should use the default files from settings"""
     pl_mock.return_value = {}  # avoid side-effects
     pot_to_langfiles()
     calls = [(('{0}/locale/templates/{1}.lang'.format(ROOT, lf),),
               {'skip_untranslated': False})
              for lf in DOTLANG_FILES]
     pl_mock.assert_has_calls(calls)
Beispiel #7
0
 def handle(self, *args, **options):
     if args:
         # mimics tower.management.commands.extract for a list of files
         outputdir = os.path.join(settings.ROOT, 'locale', 'templates',
                                  'LC_MESSAGES')
         if not os.path.isdir(outputdir):
             os.makedirs(outputdir)
         extracted = extract_from_files(args)
         catalog = extract.create_pofile_from_babel(extracted)
         catalog.savefile(os.path.join(outputdir, '%s.pot' % DOMAIN))
     else:
         # This is basically a wrapper around the tower extract
         # command, we might want to do some things around this in the
         # future
         gettext_extract()
     pot_to_langfiles()
Beispiel #8
0
 def handle(self, *args, **options):
     if args:
         # mimics tower.management.commands.extract for a list of files
         outputdir = os.path.join(settings.ROOT, 'locale', 'templates',
                                  'LC_MESSAGES')
         if not os.path.isdir(outputdir):
             os.makedirs(outputdir)
         extracted = extract_from_files(args)
         catalog = extract.create_pofile_from_babel(extracted)
         catalog.savefile(os.path.join(outputdir, '%s.pot' % DOMAIN))
     else:
         # This is basically a wrapper around the tower extract
         # command, we might want to do some things around this in the
         # future
         gettext_extract()
     pot_to_langfiles()