Browse Source

Support wagtail-modeltranslation (#236)

Co-authored-by: Niccolò Mineo <niccolo.mineo@gmail.com>
Vince Salvino 5 năm trước cách đây
mục cha
commit
627fae758c

+ 2 - 1
coderedcms/models/page_models.py

@@ -52,6 +52,7 @@ from wagtail.contrib.forms.forms import WagtailAdminFormPageForm
 from wagtail.images.edit_handlers import ImageChooserPanel
 from wagtail.contrib.forms.models import FormSubmission
 from wagtail.search import index
+from wagtail.utils.decorators import cached_classmethod
 from wagtailcache.cache import WagtailCacheMixin
 
 from coderedcms import schema, utils
@@ -472,7 +473,7 @@ class CoderedPage(WagtailCacheMixin, Page, metaclass=CoderedPageMeta):
             self.index_order_by = self.index_order_by_default
             self.index_show_subpages = self.index_show_subpages_default
 
-    @classmethod
+    @cached_classmethod
     def get_edit_handler(cls):
         """
         Override to "lazy load" the panels overriden by subclasses.

+ 11 - 0
docs/how_to/index.rst

@@ -0,0 +1,11 @@
+How-To Guides
+=============
+
+Recipes and guides to solving common problems or features when creating a website
+with CodeRed CMS.
+
+
+.. toctree::
+    :maxdepth: 1
+
+    translation

+ 48 - 0
docs/how_to/translation.rst

@@ -0,0 +1,48 @@
+Translation & Multi-Language Support
+====================================
+
+
+Translate the UI
+----------------
+
+CodeRed CMS provides all text throughout the UI and templates as translatable
+strings using Django's internationalization system (often abbreviated "i18n").
+To learn more about how translation works, read Wagtail's official `documentation
+<http://docs.wagtail.io/en/latest/advanced_topics/i18n/>`_ on the topic.
+
+
+Translate Page Content
+----------------------
+
+Translation of model fields can be most efficiently and safely achieved via the
+well-known `Wagtail Model Translation <https://github.com/infoportugal/wagtail-modeltranslation>`_
+package.
+
+Please note that, due to CodeRed CMS architecture, some model fields are not exposed
+to the translation package by default, but you can expose these fields in your ``models.py``.
+
+See below how that would be done for the ``body`` field for a specific ``WebPage``
+model in ``website/models.py``:
+
+.. code-block:: python
+
+    class WebPage(CoderedWebPage):
+        body_content_panels = []
+        content_panels = CodredWebPage.content_panels + [
+            StreamFieldPanel('body'),
+        ]
+
+
+Changing Language of the Admin Dashboard
+----------------------------------------
+
+See Wagtail's `translation documentation <http://docs.wagtail.io/en/latest/advanced_topics/i18n/>`_,
+to enable a default language in the administration panel.
+
+
+Supported Languages
+-------------------
+
+CodeRed CMS is currently provided in English (US). However, it supports translation.
+If you use CodeRed CMS in a different language, please consider contributing
+your translations!

+ 1 - 0
docs/index.rst

@@ -27,5 +27,6 @@ Contents
 
    getting_started/index
    features/index
+   how_to/index
    contributing/index
    releases/index

+ 2 - 0
docs/releases/v0.16.0.rst

@@ -10,6 +10,8 @@ New features
 * NEW support for Sass via a new starter template. See :doc:`/getting_started/install`.
 * Upgraded Wagtail to version 2.6. Now supports Django versions 2.0, 2.1, and 2.2;
   Python versions 3.5, 3.6, and 3.7.
+* Now supports page translation via `wagtail-modeltranslation <https://github.com/infoportugal/wagtail-modeltranslation>`_.
+  See new how-to guide: :doc:`/how_to/translation`.
 
 
 Bug fixes