def parse(self, resource):
        """
        Loads given resource into a dict using polib

        @type resource: str
        @param resource: resource

        @rtype: list
        """
        try:
            import polib
        except ImportError as e:
            self.rethrow(
                "You need to install polib to use PoFileLoader or MoFileLoader",
                ImportError)

        self.assert_valid_path(resource)

        messages = {}
        parsed = self._load_contents(polib, resource)

        for item in parsed:
            if item.msgid_plural:
                plurals = sorted(item.msgstr_plural.items())
                if item.msgid and len(plurals) > 1:
                    messages[item.msgid] = plurals[0][1]
                plurals = [msgstr for idx, msgstr in plurals]
                messages[item.msgid_plural] = "|".join(plurals)
            elif item.msgid:
                messages[item.msgid] = item.msgstr

        return messages
def parse ( self , resource ) : try : import polib except ImportError as e : self . rethrow ( "You need to install polib to use PoFileLoader or MoFileLoader" , ImportError ) self . assert_valid_path ( resource ) messages = { } parsed = self . _load_contents ( polib , resource ) for item in parsed : if item . msgid_plural : plurals = sorted ( item . msgstr_plural . items ( ) ) if item . msgid and len ( plurals ) > 1 : messages [ item . msgid ] = plurals [ 0 ] [ 1 ] plurals = [ msgstr for idx , msgstr in plurals ] messages [ item . msgid_plural ] = "|" . join ( plurals ) elif item . msgid : messages [ item . msgid ] = item . msgstr return messages
Loads given resource into a dict using polib

        @type resource: str
        @param resource: resource

        @rtype: list