ckan/lib/cli.py
def mangle_po(self):
        ''' This will mangle the zh_TW translations for translation coverage
        testing.

        NOTE: This will destroy the current translations fot zh_TW
        '''
        import polib
        pot_path = os.path.join(self.i18n_path, 'ckan.pot')
        po = polib.pofile(pot_path)
        # we don't want to mangle the following items in strings
        # %(...)s  %s %0.3f %1$s %2$0.3f [1:...] {...} etc

        # sprintf bit after %
        spf_reg_ex = "\+?(0|'.)?-?\d*(.\d*)?[\%bcdeufosxX]"

        extract_reg_ex = '(\%\([^\)]*\)' + spf_reg_ex + \
                         '|\[\d*\:[^\]]*\]' + \
                         '|\{[^\}]*\}' + \
                         '|<[^>}]*>' + \
                         '|\%((\d)*\$)?' + spf_reg_ex + ')'

        for entry in po:
            msg = entry.msgid.encode('utf-8')
            matches = re.finditer(extract_reg_ex, msg)
            length = len(msg)
            position = 0
            translation = u''
            for match in matches:
                translation += '-' * (match.start() - position)
                position = match.end()
                translation += match.group(0)
            translation += '-' * (length - position)
            entry.msgstr = translation
        out_dir = os.path.join(self.i18n_path, 'zh_TW', 'LC_MESSAGES')
        try:
            os.makedirs(out_dir)
        except OSError:
            pass
        po.metadata['Plural-Forms'] = "nplurals=1; plural=0\n"
        out_po = os.path.join(out_dir, 'ckan.po')
        out_mo = os.path.join(out_dir, 'ckan.mo')
        po.save(out_po)
        po.save_as_mofile(out_mo)
        print('zh_TW has been mangled')
 This will mangle the zh_TW translations for translation coverage
        testing.

        NOTE: This will destroy the current translations fot zh_TW
        
This will mangle the zh_TW translations for translation coverage
testing.

This will destroy the current translations fot zh_TW
This will mangle the zh_TW translations for translation coverage testing . This will destroy the current translations fot zh_TW
def mangle_po(self):
        import polib
        pot_path = os.path.join(self.i18n_path, 'ckan.pot')
        po = polib.pofile(pot_path)
        spf_reg_ex = "\+?(0|'.)?-?\d*(.\d*)?[\%bcdeufosxX]"
        extract_reg_ex = '(\%\([^\)]*\)' + spf_reg_ex + \
                         '|\[\d*\:[^\]]*\]' + \
                         '|\{[^\}]*\}' + \
                         '|<[^>}]*>' + \
                         '|\%((\d)*\$)?' + spf_reg_ex + ')'
        for entry in po:
            msg = entry.msgid.encode('utf-8')
            matches = re.finditer(extract_reg_ex, msg)
            length = len(msg)
            position = 0
            translation = u''
            for match in matches:
                translation += '-' * (match.start() - position)
                position = match.end()
                translation += match.group(0)
            translation += '-' * (length - position)
            entry.msgstr = translation
        out_dir = os.path.join(self.i18n_path, 'zh_TW', 'LC_MESSAGES')
        try:
            os.makedirs(out_dir)
        except OSError:
            pass
        po.metadata['Plural-Forms'] = "nplurals=1; plural=0\n"
        out_po = os.path.join(out_dir, 'ckan.po')
        out_mo = os.path.join(out_dir, 'ckan.mo')
        po.save(out_po)
        po.save_as_mofile(out_mo)
        print('zh_TW has been mangled')
def mangle_po ( self ) : import polib pot_path = os . path . join ( self . i18n_path , 'ckan.pot' ) po = polib . pofile ( pot_path ) spf_reg_ex = "\+?(0|'.)?-?\d*(.\d*)?[\%bcdeufosxX]" extract_reg_ex = '(\%\([^\)]*\)' + spf_reg_ex + '|\[\d*\:[^\]]*\]' + '|\{[^\}]*\}' + '|<[^>}]*>' + '|\%((\d)*\$)?' + spf_reg_ex + ')' for entry in po : msg = entry . msgid . encode ( 'utf-8' ) matches = re . finditer ( extract_reg_ex , msg ) length = len ( msg ) position = 0 translation = u'' for match in matches : translation += '-' * ( match . start ( ) - position ) position = match . end ( ) translation += match . group ( 0 ) translation += '-' * ( length - position ) entry . msgstr = translation out_dir = os . path . join ( self . i18n_path , 'zh_TW' , 'LC_MESSAGES' ) try : os . makedirs ( out_dir ) except OSError : pass po . metadata [ 'Plural-Forms' ] = "nplurals=1; plural=0\n" out_po = os . path . join ( out_dir , 'ckan.po' ) out_mo = os . path . join ( out_dir , 'ckan.mo' ) po . save ( out_po ) po . save_as_mofile ( out_mo ) print ( 'zh_TW has been mangled' )
This will mangle the zh_TW translations for translation coverage
testing.
This will mangle the zh_TW translations for translation coverage testing .
''' This will mangle the zh_TW translations for translation coverage
        testing.

        NOTE: This will destroy the current translations fot zh_TW
        ''' # we don't want to mangle the following items in strings # %(...)s  %s %0.3f %1$s %2$0.3f [1:...] {...} etc # sprintf bit after %
self