Beispiel #1
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# ===========================================================================

'''Envelop with eXe translation function ("_") all tinymce english lang strings
   Depends on demjson python module to parse json. "apt-get install python-demjson"
'''


from exe.engine.path import Path
import demjson

if __name__ == '__main__':
    basedir = Path() / 'exe' / 'webui' / 'scripts' / 'tinymce_3.5.7' / 'jscripts' / 'tiny_mce'
    for path in basedir.walk('en*.js'):
        pathdir = path.dirname()
        f = path.bytes()
        s = '{' + f.partition('{')[2]
        s = s.rpartition('}')[0] + '}'
        json = demjson.decode(s)
        replacements = []

        def update_string(string):
            global f, replacements
            if type(string) == dict:
                for v in string.values():
                    update_string(v)
            else:
                if string:
                    string = string.replace('\n', '\\n')
Beispiel #2
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# ===========================================================================

''' Add to corresponding po file the tinymce lang strings
    Depends on demjson python module to parse json and polib. "apt-get install python-demjson python-polib"
'''
from exe.engine.path import Path
import demjson
import polib

if __name__ == '__main__':
    basedir = Path() / 'exe' / 'webui' / 'scripts' / 'tinymce_3.5.7' / 'jscripts' / 'tiny_mce'
    pos = {}
    for path in basedir.walk('en*.js'):
        pathdir = path.dirname()
        f = path.bytes()
        s = '{' + f.partition('{')[2]
        s = s.rpartition('}')[0] + '}'
        srcjson = demjson.decode(s)
        for pathfile in pathdir.files():
            if pathfile.basename() not in ['en.js', 'en_dlg.js'] and len(pathfile.basename()) == len(path.basename()):
                fl = pathfile.bytes()
                sl = '{' + fl.partition('{')[2]
                sl = sl.rpartition('}')[0] + '}'
                langjson = demjson.decode(sl)

                def append_string(string, key, json, srcstring):
                    if type(string) == dict:
                        for k, v in string.items():