From 002213aa871eef1707cfdd7fecb8d8d8c1c57d66 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Sun, 12 Apr 2020 17:08:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B0=D0=B6=D0=BD=D0=BE=D0=B5=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=20?= =?UTF-8?q?=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B0=D1=85=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 4 ++-- pelicanconf-web.py | 37 ++++++------------------------------- pelicanconf.py | 37 ++++++------------------------------- 3 files changed, 14 insertions(+), 64 deletions(-) diff --git a/Makefile b/Makefile index 6c9ee15..f1a2721 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ build: - pelican --ignore-cache -s pelicanconf.py + pelican -s pelicanconf.py web: - pelican --ignore-cache -s pelicanconf-web.py + pelican -s pelicanconf-web.py clean: rm -rf cache __pycache__ diff --git a/pelicanconf-web.py b/pelicanconf-web.py index e620618..c4c9c26 100644 --- a/pelicanconf-web.py +++ b/pelicanconf-web.py @@ -2,33 +2,6 @@ # -*- coding: utf-8 -*- # import os -class i18n(object): - # looks for translations in - # {LOCALE_DIR}/{LANGUAGE}/LC_MESSAGES/{DOMAIN}.mo - # if not present, falls back to default - - DOMAIN = 'messages' - LOCALE_DIR = '{THEME}/translations' - LANGUAGES = ['ru'] - NEWSTYLE = True - - __name__ = 'i18n' - - def register(self): - from pelican.signals import generator_init - generator_init.connect(self.install_translator) - - def install_translator(self, generator): - import gettext - try: - translator = gettext.translation( - self.DOMAIN, - self.LOCALE_DIR.format(THEME=THEME), - self.LANGUAGES) - except (OSError, IOError): - translator = gettext.NullTranslations() - generator.env.install_gettext_translations(translator, self.NEWSTYLE) - # ABOUT_ME = ' ' AUTHOR = 'Андрей Астафьев' SITENAME = 'ДСП' @@ -67,14 +40,16 @@ DISPLAY_TAGS_ON_SIDEBAR = True THEME = 'themes/bootstrap4' BOOTSTRAP_THEME = 'litera' -I18N_TEMPLATES_LANG = 'ru' +# I18N_GETTEXT_LOCALEDIR = 'translations' +# I18N_GETTEXT_DOMAIN = 'messages' + +# Обязательно в виде массива +I18N_TEMPLATES_LANG = ['ru'] I18N_GETTEXT_NEWSTYLE = True -I18N_GETTEXT_LOCALEDIR = 'themes/bootstrap4/translations' -I18N_GETTEXT_DOMAIN = 'messages' JINJA_ENVIRONMENT = {'extensions': ['jinja2.ext.i18n']} PLUGIN_PATHS = ["plugins/official", "plugins/thirdparty"] -PLUGINS = [i18n(), "pelican-css", "series", "subcategory", "tag_cloud", "tipue_search", "replacer", "asciidoctor"] +PLUGINS = ["i18n_subsites", "pelican-css", "series", "subcategory", "tag_cloud", "tipue_search", "replacer", "asciidoctor"] ASCIIDOCTOR_CMD = "asciidoctor" diff --git a/pelicanconf.py b/pelicanconf.py index 200f98b..443e538 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -2,33 +2,6 @@ # -*- coding: utf-8 -*- # import os -class i18n(object): - # looks for translations in - # {LOCALE_DIR}/{LANGUAGE}/LC_MESSAGES/{DOMAIN}.mo - # if not present, falls back to default - - DOMAIN = 'messages' - LOCALE_DIR = '{THEME}/translations' - LANGUAGES = ['ru'] - NEWSTYLE = True - - __name__ = 'pelicanconf.i18n' - - def register(self): - from pelican.signals import generator_init - generator_init.connect(self.install_translator) - - def install_translator(self, generator): - import gettext - try: - translator = gettext.translation( - self.DOMAIN, - self.LOCALE_DIR.format(THEME=THEME), - self.LANGUAGES) - except (OSError, IOError): - translator = gettext.NullTranslations() - generator.env.install_gettext_translations(translator, self.NEWSTYLE) - # ABOUT_ME = ' ' AUTHOR = 'Андрей Астафьев' SITENAME = 'ДСП' @@ -67,14 +40,16 @@ DISPLAY_TAGS_ON_SIDEBAR = True THEME = 'themes/bootstrap4' BOOTSTRAP_THEME = 'litera' -I18N_TEMPLATES_LANG = 'ru' +# I18N_GETTEXT_LOCALEDIR = 'translations' +# I18N_GETTEXT_DOMAIN = 'messages' + +# Обязательно в виде массива +I18N_TEMPLATES_LANG = ['ru'] I18N_GETTEXT_NEWSTYLE = True -I18N_GETTEXT_LOCALEDIR = 'themes/bootstrap4/translations' -I18N_GETTEXT_DOMAIN = 'messages' JINJA_ENVIRONMENT = {'extensions': ['jinja2.ext.i18n']} PLUGIN_PATHS = ["plugins/official", "plugins/thirdparty"] -PLUGINS = [i18n(), "pelican-css", "series", "subcategory", "tag_cloud", "tipue_search", "replacer", "asciidoctor"] +PLUGINS = ["i18n_subsites", "pelican-css", "series", "subcategory", "tag_cloud", "tipue_search", "replacer", "asciidoctor"] ASCIIDOCTOR_CMD = "asciidoctor"