django-flatpages-i18n


Namedjango-flatpages-i18n JSON
Version 2.0.2 PyPI version JSON
download
home_pagehttps://github.com/PragmaticMates/django-flatpages-i18n
SummaryTranslatable flatpages
upload_time2024-10-04 21:09:42
maintainerPragmatic Mates
docs_urlNone
authorPragmatic Mates
requires_pythonNone
licenseBSD License
keywords django flatpages translation i18n
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            django-flatpages-i18n
=====================

Translatable version of django.contrib.flatpages with menu support.


Requirements
------------
- Django
- django_modeltrans
- django_mptt
- django-pragmatic

Tested with Django 1.8.


Installation
-------------

1. Install python library using pip: ``pip install django-flatpages-i18n``

2. Add ``mptt``, ``modeltrans`` and ``flatpages_i18n`` to ``INSTALLED_APPS`` in your Django settings file

3. Migrate your database

4. Specify desired languages in your Django settings file::

    from django.utils.translation import gettext

    LANGUAGE_CODE = 'en'
    LANGUAGES = (
        ('en', gettext('English')),
        ('de', gettext('German')),
    )



5. Addd ``'flatpages_i18n.urls'`` to your urls.py::

    if 'flatpages_i18n' in settings.INSTALLED_APPS:
        urlpatterns += i18n_patterns(
            path(pgettext_lazy('url', 'pages/'), include('flatpages_i18n.urls')),
        )


Usage
-----

To get all flatpages:
'''''''''''''''''''''

In your HTML template::

    {% load i18n flatpages_i18n %}
    {% get_flatpages_i18n as flatpages_i18n %}

    <ul>
        {% for flatpage in flatpages_i18n %}
            <li><a href="{{ flatpage.get_absolute_url }}">{{ flatpage }}</a></li>
        {% endfor %}
    </ul>


To get flatpage by its PK::

    {% get_flatpage_i18n 123 as my_flatpage %}
    {{ my_flatpage.content_i18n }}


or by its machine_name::

    {% get_flatpage_i18n 'my-flatpage' as my_flatpage %}


Menu system:
''''''''''''

To print all menu items::

    <div id="navigation">
        {% menu_i18n %}
    </div>

to get only children of menu item identified by its PK::

    <div id="navigation">
        {% menu_i18n 2 %}
    </div>

or by its machine_name::

    <div id="navigation">
        {% menu_i18n 'footer-menu' %}
    </div>

You can also assign menu items into variable::

    {% get_menu_i18n 'my-menu' as my_menu %}
    {% for item in my_menu %}
        <a href="{{ item.get_absolute_url }}" target="{{ item.target }}">{{ item }}</a>
    {% endfor %}

Authors
-------

Library is by `Erik Telepovsky` from `Pragmatic Mates`_. See `our other libraries`_.

.. _Pragmatic Mates: http://www.pragmaticmates.com/
.. _our other libraries: https://github.com/PragmaticMates

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PragmaticMates/django-flatpages-i18n",
    "name": "django-flatpages-i18n",
    "maintainer": "Pragmatic Mates",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "info@pragmaticmates.com",
    "keywords": "django flatpages translation i18n",
    "author": "Pragmatic Mates",
    "author_email": "info@pragmaticmates.com",
    "download_url": "https://files.pythonhosted.org/packages/8a/90/8b69b6838eecb232e161c5d15c0151327bebea9b9c372bfdeddd8ae17b3f/django_flatpages_i18n-2.0.2.tar.gz",
    "platform": null,
    "description": "django-flatpages-i18n\n=====================\n\nTranslatable version of django.contrib.flatpages with menu support.\n\n\nRequirements\n------------\n- Django\n- django_modeltrans\n- django_mptt\n- django-pragmatic\n\nTested with Django 1.8.\n\n\nInstallation\n-------------\n\n1. Install python library using pip: ``pip install django-flatpages-i18n``\n\n2. Add ``mptt``, ``modeltrans`` and ``flatpages_i18n`` to ``INSTALLED_APPS`` in your Django settings file\n\n3. Migrate your database\n\n4. Specify desired languages in your Django settings file::\n\n    from django.utils.translation import gettext\n\n    LANGUAGE_CODE = 'en'\n    LANGUAGES = (\n        ('en', gettext('English')),\n        ('de', gettext('German')),\n    )\n\n\n\n5. Addd ``'flatpages_i18n.urls'`` to your urls.py::\n\n    if 'flatpages_i18n' in settings.INSTALLED_APPS:\n        urlpatterns += i18n_patterns(\n            path(pgettext_lazy('url', 'pages/'), include('flatpages_i18n.urls')),\n        )\n\n\nUsage\n-----\n\nTo get all flatpages:\n'''''''''''''''''''''\n\nIn your HTML template::\n\n    {% load i18n flatpages_i18n %}\n    {% get_flatpages_i18n as flatpages_i18n %}\n\n    <ul>\n        {% for flatpage in flatpages_i18n %}\n            <li><a href=\"{{ flatpage.get_absolute_url }}\">{{ flatpage }}</a></li>\n        {% endfor %}\n    </ul>\n\n\nTo get flatpage by its PK::\n\n    {% get_flatpage_i18n 123 as my_flatpage %}\n    {{ my_flatpage.content_i18n }}\n\n\nor by its machine_name::\n\n    {% get_flatpage_i18n 'my-flatpage' as my_flatpage %}\n\n\nMenu system:\n''''''''''''\n\nTo print all menu items::\n\n    <div id=\"navigation\">\n        {% menu_i18n %}\n    </div>\n\nto get only children of menu item identified by its PK::\n\n    <div id=\"navigation\">\n        {% menu_i18n 2 %}\n    </div>\n\nor by its machine_name::\n\n    <div id=\"navigation\">\n        {% menu_i18n 'footer-menu' %}\n    </div>\n\nYou can also assign menu items into variable::\n\n    {% get_menu_i18n 'my-menu' as my_menu %}\n    {% for item in my_menu %}\n        <a href=\"{{ item.get_absolute_url }}\" target=\"{{ item.target }}\">{{ item }}</a>\n    {% endfor %}\n\nAuthors\n-------\n\nLibrary is by `Erik Telepovsky` from `Pragmatic Mates`_. See `our other libraries`_.\n\n.. _Pragmatic Mates: http://www.pragmaticmates.com/\n.. _our other libraries: https://github.com/PragmaticMates\n",
    "bugtrack_url": null,
    "license": "BSD License",
    "summary": "Translatable flatpages",
    "version": "2.0.2",
    "project_urls": {
        "Homepage": "https://github.com/PragmaticMates/django-flatpages-i18n"
    },
    "split_keywords": [
        "django",
        "flatpages",
        "translation",
        "i18n"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a908b69b6838eecb232e161c5d15c0151327bebea9b9c372bfdeddd8ae17b3f",
                "md5": "6128970014c762ed24b253fe1d6eca16",
                "sha256": "ebdaa078d103ddd0d9979664a5660d4dd1105185fc864da23c6e6649d3468b4d"
            },
            "downloads": -1,
            "filename": "django_flatpages_i18n-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "6128970014c762ed24b253fe1d6eca16",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10256,
            "upload_time": "2024-10-04T21:09:42",
            "upload_time_iso_8601": "2024-10-04T21:09:42.133800Z",
            "url": "https://files.pythonhosted.org/packages/8a/90/8b69b6838eecb232e161c5d15c0151327bebea9b9c372bfdeddd8ae17b3f/django_flatpages_i18n-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-04 21:09:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PragmaticMates",
    "github_project": "django-flatpages-i18n",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-flatpages-i18n"
}
        
Elapsed time: 0.32875s