ckan / ckanext-pages

A simple builtin CMS for CKAN sites
GNU General Public License v3.0
51 stars 99 forks source link

Multi linugal pages #41

Closed tino097 closed 7 years ago

tino097 commented 7 years ago

Translation to German language for ckanext-pages.

amercader commented 7 years ago

@tino097 In these general use extensions it's worth keeping compatibility for as many versions as possible. Certainly 2.3 would be worth it as it still widely used. In this cases what we do is selectively import stuff from core depending on the CKAN version that is running, like @metaodi suggests here: https://github.com/ckan/ckanext-pages/pull/32#issuecomment-220005372.

To make sure everything works fine let's add the missings versions to .travis.yml as part of this PR as well

tino097 commented 7 years ago

@amercader For 2.3 and 2.4 versions still have the same issue: ImportError: cannot import name DefaultTranslation

amercader commented 7 years ago

Extensions translations were added on 2.5, and you also need to check the CKAN version before importing DefaultTranslation. Try something like this (untested):


if p.toolkit.check_ckan_version(min_version='2.5'):
    from ckan.lib.plugins import DefaultTranslation

    class PagesPluginBase(p.SingletonPlugin, DefaultTranslation):
        p.implements(p.ITranslation, inherit=True)

else:

    class PagesPluginBase(p.SingletonPlugin):
        pass

class PagesPlugin(PagesPluginBase):

     p.implements(p.IConfigurer, inherit=True)
     p.implements(p.ITemplateHelpers, inherit=True)
     # ...
tino097 commented 7 years ago

@amercader Thanks for the guidance

amercader commented 7 years ago

Looks good @tino097! Congrats on your first CKAN extension contribution, hopefully the first of many to come :)