[SOLVED] Custom language in admin panel

NodeBB Development
  • Hello, recently I finished the translation of the admin control panel files at transifex to my language (pt-BR). Is it possible to currently put that translation to work on my nodebb so I can fine tune/improve it?

  • The javascript programmers (rofl) think people doesn't deserve a reply. Open $ource. 🙂 🙂 🙂 (really hard to find github link in nodebb.org)

  • This is an active forum. Posts can get buried. It also takes time to reply to everyone.

    And yes the Github link should be clearly on the site but Google is your friend.

    I'm not very acquainted with Transifex, and I don't know if it's possible to test the translations out ahead of time. But if it is possible to download the translations, then you can copy them into the correct directory in /public/src/language and then start NodeBB with the new translations.

    Thanks for your translations.

  • @priapo said in Custom language in admin panel:

    The javascript programmers (rofl) think people doesn't deserve a reply. Open $ource. 🙂 🙂 🙂 (really hard to find github link in nodebb.org)

    Kind of a jerk post. You do realize you posted your original question right before a holiday weekend right?

  • Well, I have no time for discuting bs with js;

    The admin language files are inside [nodebb]/public/language/YOURFORUMLANGUAGE/admin/

    I have made a python3 script to make an organized admin/ directory from the files downloaded from transifex. (You should download all files one by one, should be 30 or 40, takes 7~10 minutes)

    1. Make a new directory
    2. Dowload all translated .json files to that directory
    3. They have names like for_use_nodebb_admin-advanced-events_pt_BR.json.
    4. Save this script in a file called freak.python3 in the directory you created.
    #!/usr/bin/env python3
    
    import os
    import glob
    # use os.system("") to do it lil boy
    import subprocess
    
    # Files downloaded from transifex has this string in filename.
    # This should be removed from them; change with yours.
    language_str = "_pt_BR"
    
    json_files = glob.glob('*.json', recursive=False)
    
    dirs_created = list()
    
    for file in json_files:
        ripped = file.split('-', 2) # 2 here is a hack to avoid splitting ip-blacklist.json and web-crawler.json
    
        json_filename = ripped[-1].replace(language_str,'')
        print(ripped)
    
        if len(ripped) == 3:
            directory = "admin/{0}/".format(ripped[1])
        elif len(ripped) == 2:
            directory = "admin/"
        else:
            directory = "ERROR/" # if this directory appears something went wrong
    
        if not directory in dirs_created:
            dirs_created.append(directory)
            print(directory)
            os.system("mkdir -p {0}".format(directory))
    
        print(json_filename)
        os.system("cp {0} {1}{2}".format(file, directory, json_filename))
    
    1. CHANGE THE LINE language_str = "_pt_BR" WITH YOUR LANGUAGE KEEPING THE _ before..
    2. Make it executable: chmod +x freak.python3
    3. Execute it: ./freak.python3
    4. This will create an admin/ directory inside the directory, tar it and send to server: tar zcvf admin.tgz admin/
    5. scp admin.tgz SSHUSER@SSHSERVER: or whetever you use.
  • @priapo hey that's pretty neat. Thanks for sharing.

  • Transifex has CLI client - so you don't need to manually download all translation files.
    https://docs.transifex.com/client/introduction

  • Yep, we use the tx client to pull translations from Transifex.


Suggested Topics