peng3d/i18n.py
def discoverLangs(self,domain="*"):
        """
        Generates a list of languages based on files found on disk.
        
        The optional ``domain`` argument may specify a domain to use when checking
        for files. By default, all domains are checked.
        
        This internally uses the :py:mod:`glob` built-in module and the
        :confval:`i18n.lang.format` config option to find suitable filenames.
        It then applies the regex in :confval:`i18n.discover_regex` to extract the
        language code.
        """
        rsrc = self.peng.cfg["i18n.lang.format"].format(domain=domain,lang="*")
        pattern = self.peng.rsrcMgr.resourceNameToPath(rsrc,self.peng.cfg["i18n.lang.ext"])
        files = glob.iglob(pattern)
        
        langs = set()
        r = re.compile(self.peng.cfg["i18n.discover_regex"])
        
        for f in files:
            m = r.fullmatch(f)
            if m is not None:
                langs.add(m.group("lang"))
        
        return list(langs)
def discoverLangs(self,domain="*"):
        """
        Generates a list of languages based on files found on disk.
        
        The optional ``domain`` argument may specify a domain to use when checking
        for files. By default, all domains are checked.
        
        This internally uses the :py:mod:`glob` built-in module and the
        :confval:`i18n.lang.format` config option to find suitable filenames.
        It then applies the regex in :confval:`i18n.discover_regex` to extract the
        language code.
        """
        rsrc = self.peng.cfg["i18n.lang.format"].format(domain=domain,lang="*")
        pattern = self.peng.rsrcMgr.resourceNameToPath(rsrc,self.peng.cfg["i18n.lang.ext"])
        files = glob.iglob(pattern)
        
        langs = set()
        r = re.compile(self.peng.cfg["i18n.discover_regex"])
        
        for f in files:
            m = r.fullmatch(f)
            if m is not None:
                langs.add(m.group("lang"))
        
        return list(langs)
Generates a list of languages based on files found on disk.
        
        The optional ``domain`` argument may specify a domain to use when checking
        for files. By default, all domains are checked.
        
        This internally uses the :py:mod:`glob` built-in module and the
        :confval:`i18n.lang.format` config option to find suitable filenames.
        It then applies the regex in :confval:`i18n.discover_regex` to extract the
        language code.