Skip to main content

springheel.gentrans module

Get translation strings.

springheel.gentrans.generateTranslations(lang: str, strings_path: str)dict

Get language strings from the translation file.

You may ask why I don’t use the existing i18n methods, like gettext. Putting strings in a user-editable JSON file makes it far easier for fluent speakers to correct mistakes or oddities in my translations. Based on experience with other static site generators, I resolved that it should be possible to fix the TL of a Springheel site with a simple text editor and little or no technical knowledge. No re-installing Springheel, editing system settings, entering your root password, figuring out how to build pot files, or joining mailing lists. Just change one file and you’re done. This method also allows one to build a site in a different language than the “system” language, which is more valuable than it sounds.

Parameters
langstr

The site language.

strings_pathstr

The path to the strings.json translation file.

Returns
dict

All sorts of UI strings in the site language. Sub-dict “language_names” has language code-name mappings.