1. Download & install Lektor
Run the command:
$ curl -sf https://www.getlektor.com/install.sh | sh
- If you get the error
curl command not found, then you need to install curl first. You can do this by using the command:
sudo apt install curl
- You may get
Error: None of the items in $PATH are writable. Run with sudo or add a $PATH item. You can fix this by instead running
curl -sf https://www.getlektor.com/install.sh | sudo sh
2. Clone the repo from torgit (this is a read only repository)
Run the command
git clone https://git.torproject.org/project/web/tpo.git
You can do this by running the following commands:
$ sudo apt-get install gettext python3-babel $ pip install babel
4. Clone the translations repository
Translations for the website are imported by Jenkins when building the page, but if you want to test them, download the correct branch of the translations repo to the ./i18n/ folder:
$ git clone https://git.torproject.org/translation.git i18n $ cd i18n $ git checkout tpo-web
5. Initialize the building blocks submodule
$ cd tpo/lego && git submodule update --init
6. Install and use Lektor i18n plugin
$ lektor plugins add lektor-i18n
The translation mechanism is hooked into the build system. So translating a website just means building the website.
$ lektor build
Tip: To save some time while you build in local, you can edit the configs/i18n.ini file and take some languages out of the 'translations' option.
You can make changes to the pages. Most of the content is on the
If you encounter the error:
from urllib import requestImportError: cannot import name request, you can fix it by going to
~tpo/lego/packages/xml-to-html/lektor_xml_to_html.pyand changing the line
from urllib import requestto
from urllib3 import request. You may also have to do the same change for the
A possible error is
UnicodeEncodeError: 'ascii' codec can't encode character u'\xae'stemming from
~tpo/lego/packages/i18n/lektor_i18n.py. This can be fixed by adding the following code snippet to the top of the page after the
$ lektor server to run a local continuous builder.
You should be able to access your local lektor instance at http://127.0.0.1:5000/ from your computer.
Most common lektor errors
file = builtins.open(filename, mode, buffering) FileNotFoundError: [Errno 2] No such file or directory: '/content/**some filename**/contents.lr'
This happens when a source file
contents.lr has been deleted in the repository, but their associated language files are still there. So, when trying to update the language files, lektor fails because the source file is not there. Delete the folder with the translations and build again.
/training/code-of-conduct/index.html (jinja2.exceptions.UndefinedError: 'render_text' is undefined)
git submodule update --init --recursive