示例#1
0
    def setUp(self):
        TestGettext.setUp(self)

        self.count = 5
        # use our "fake" ngettext so it gets picked up
        self.ableone = ngettext("I can translate %d thing",
            "I can translate %d things", 1)
        # use the "real" ngettext, from the module, also gets picked up
        self.edone = gettext.ngettext("I translated %d thing",
            "I translated %d things", 1)
        self.ablecount = ngettext("I can translate %d thing",
            "I can translate %d things", self.count)
        self.edcount = gettext.ngettext("I translated %d thing",
            "I translated %d things", self.count)
示例#2
0
    def requireElements(self, workerName, *elementNames):
        """Require that the given list of GStreamer elements exists on the
        given worker. If the elements do not exist, an error message is
        posted and the next button remains blocked.
        @param workerName: name of the worker to check on
        @type workerName: string
        @param elementNames: names of the elements to check
        @type elementNames: list of strings
        @returns: element name
        @rtype: deferred -> list of strings
        """
        if not self._adminModel:
            self.debug('No admin connected, not checking presence of elements')
            return

        self.debug('requiring elements %r' % (elementNames, ))
        f = ngettext(
            "Checking the existence of GStreamer element '%s' "
            "on %s worker.",
            "Checking the existence of GStreamer elements '%s' "
            "on %s worker.", len(elementNames))
        msg = messages.Info(T_(f, "', '".join(elementNames), workerName),
                            mid='require-elements')

        self.add_msg(msg)

        def gotMissingElements(elements, workerName):
            self.clear_msg('require-elements')

            if elements:
                self.warning('elements %r do not exist' % (elements, ))
                f = ngettext(
                    "Worker '%s' is missing GStreamer element '%s'.",
                    "Worker '%s' is missing GStreamer elements '%s'.",
                    len(elements))
                message = messages.Error(
                    T_(f, workerName, "', '".join(elements)))
                message.add(
                    T_(
                        N_("\n"
                           "Please install the necessary GStreamer plug-ins that "
                           "provide these elements and restart the worker.")))
                message.add(
                    T_(
                        N_("\n\n"
                           "You will not be able to go forward using this worker."
                           )))
                message.id = 'element' + '-'.join(elementNames)
                documentation.messageAddGStreamerInstall(message)
                self.add_msg(message)
            self.taskFinished(bool(elements))
            return elements

        self.waitForTask('require elements %r' % (elementNames, ))
        d = self.checkElements(workerName, *elementNames)
        d.addCallback(gotMissingElements, workerName)

        return d
    def requireElements(self, workerName, *elementNames):
        """Require that the given list of GStreamer elements exists on the
        given worker. If the elements do not exist, an error message is
        posted and the next button remains blocked.
        @param workerName: name of the worker to check on
        @type workerName: string
        @param elementNames: names of the elements to check
        @type elementNames: list of strings
        @returns: element name
        @rtype: deferred -> list of strings
        """
        if not self._adminModel:
            self.debug('No admin connected, not checking presence of elements')
            return

        self.debug('requiring elements %r' % (elementNames, ))
        f = ngettext("Checking the existence of GStreamer element '%s' "
                     "on %s worker.",
                     "Checking the existence of GStreamer elements '%s' "
                     "on %s worker.",
                     len(elementNames))
        msg = messages.Info(T_(f, "', '".join(elementNames), workerName),
                            mid='require-elements')

        self.add_msg(msg)

        def gotMissingElements(elements, workerName):
            self.clear_msg('require-elements')

            if elements:
                self.warning('elements %r do not exist' % (elements, ))
                f = ngettext("Worker '%s' is missing GStreamer element '%s'.",
                    "Worker '%s' is missing GStreamer elements '%s'.",
                    len(elements))
                message = messages.Error(T_(f, workerName,
                    "', '".join(elements)))
                message.add(T_(N_("\n"
                    "Please install the necessary GStreamer plug-ins that "
                    "provide these elements and restart the worker.")))
                message.add(T_(N_("\n\n"
                    "You will not be able to go forward using this worker.")))
                message.id = 'element' + '-'.join(elementNames)
                documentation.messageAddGStreamerInstall(message)
                self.add_msg(message)
            self.taskFinished(bool(elements))
            return elements

        self.waitForTask('require elements %r' % (elementNames, ))
        d = self.checkElements(workerName, *elementNames)
        d.addCallback(gotMissingElements, workerName)

        return d
示例#4
0
    def testTranslatablePlural(self):
        # Andy 3 is a droid in the Andy series and doesn't need translating
        t = T_(ngettext("%s %d has %d thing", "%s %d has %d things", 5),
            "Andy", 3, 5)
        self.assertEquals(t.domain, configure.PACKAGE)
        self.assertEquals(t.singular, "%s %d has %d thing")
        self.assertEquals(t.plural, "%s %d has %d things")
        self.assertEquals(t.count, 5)
        self.assertEquals(t.args, ("Andy", 3, 5))
        self.assertEquals(t.plural % t.args, "Andy 3 has 5 things")

        # now translate to nl_NL
        localedir = os.path.join(configure.localedatadir, 'locale')
        self.nl = gettext.translation(configure.PACKAGE, localedir, ["nl_NL"])
        self.failUnless(self.nl)
        text = self.nl.ngettext(t.singular, t.plural, t.count) % t.args
        self.assertEquals(text, "Andy 3 heeft 5 dingen")
示例#5
0
    def testTranslatablePlural(self):
        # Andy 3 is a droid in the Andy series and doesn't need translating
        t = T_(ngettext("%s %d has %d thing", "%s %d has %d things", 5),
            "Andy", 3, 5)
        self.assertEquals(t.domain, configure.PACKAGE)
        self.assertEquals(t.singular, "%s %d has %d thing")
        self.assertEquals(t.plural, "%s %d has %d things")
        self.assertEquals(t.count, 5)
        self.assertEquals(t.args, ("Andy", 3, 5))
        self.assertEquals(t.plural % t.args, "Andy 3 has 5 things")

        # now translate to nl_NL
        localedir = os.path.join(configure.localedatadir, 'locale')
        self.nl = gettext.translation(configure.PACKAGE, localedir, ["nl_NL"])
        self.failUnless(self.nl)
        text = self.nl.ngettext(t.singular, t.plural, t.count) % t.args
        self.assertEquals(text, "Andy 3 heeft 5 dingen")
示例#6
0
        def gotMissingElements(elements, workerName):
            self.clear_msg('require-elements')

            if elements:
                self.warning('elements %r do not exist' % (elements, ))
                f = ngettext("Worker '%s' is missing GStreamer element '%s'.",
                    "Worker '%s' is missing GStreamer elements '%s'.",
                    len(elements))
                message = messages.Error(T_(f, workerName,
                    "', '".join(elements)))
                message.add(T_(N_("\n"
                    "Please install the necessary GStreamer plug-ins that "
                    "provide these elements and restart the worker.")))
                message.add(T_(N_("\n\n"
                    "You will not be able to go forward using this worker.")))
                message.id = 'element' + '-'.join(elementNames)
                self.add_msg(message)
            self.taskFinished(bool(elements))
            return elements
示例#7
0
        def checkElements(elements):
            if elements:
                f = ngettext(
                    "Worker '%s' is missing GStreamer element '%s'.",
                    "Worker '%s' is missing GStreamer elements '%s'.",
                    len(elements),
                )
                message = messages.Warning(T_(f, self.worker, "', '".join(elements)), mid="overlay")
                message.add(T_(N_('\n\nClick "Forward" to proceed without overlay.')))
                self.wizard.add_msg(message)
                self.wizard.taskFinished()
                self._setSensitive(False)
                return
            else:
                self.wizard.clear_msg("overlay")

            # now check import
            d = self.wizard.checkImport(self.worker, "PIL")
            d.addCallback(checkImport)
            d.addErrback(importError)
示例#8
0
        def checkElements(elements):
            if elements:
                f = ngettext("Worker '%s' is missing GStreamer element '%s'.",
                    "Worker '%s' is missing GStreamer elements '%s'.",
                    len(elements))
                message = messages.Warning(
                    T_(f, self.worker, "', '".join(elements)), mid='overlay')
                message.add(
                    T_(
                    N_("\n\nClick \"Forward\" to proceed without overlay.")))
                self.wizard.add_msg(message)
                self.wizard.taskFinished()
                self._setSensitive(False)
                return
            else:
                self.wizard.clear_msg('overlay')

            # now check import
            d = self.wizard.checkImport(self.worker, 'cairo')
            d.addCallback(checkImport)
            d.addErrback(importError)