ckanext-fluent icon indicating copy to clipboard operation
ckanext-fluent copied to clipboard

Using Fluent with Organizations and Groups

Open ryangermann-gov-on-ca opened this issue 4 years ago • 7 comments

I've had success with configuring Fluent for Datasets, but for Organizations / Groups, I can configure Fluent to work so that the form fields are presented for the two languages, but the entered data doesn't seem to be stored and when viewing the list of Datasets, only the english is shown (but in the Dataset info, the changing the site language works as expected, for both the Dataset and Resource information)

I've attached some screenshots hoping there is a bit more info on configuring Fluent for use with Organizations / Groups (for the purposes of our system, we,ve just changed the strings to "Ministries" and "Categories" but only the text labels have changed, no code changes underneath)

1: text entered in “EN Titre” and “FR Titre” isn’t saved, isn’t shown when the “Edit” screen is visited again, and note that the text and Ministry name on the left is in English only (perhaps an artefact of the En and FR title text not being saved?

fluent1

2: The list of Datasets (which have relabeled “Form Profiles”) is also only shown in English, even though the bilingual text shows on the “Form Profile” (dataset) page just fine. See two screenshots below:

Datasets list: fluent2

Individual dataset ("Form Profile") screen in French, but showing Organization profile in English: fluent3

the "Info Additionelle" section of the screen shows fine in French fluent4

...and also the Dataset ("Form Profile") dataset and resource metadata shown in English, working as expected: fluent5

so if there are aspects to configuring Fluent to work with Organizations and Groups that I'm not aware of, I'd appreciate it if someone could point me in the right direction. I'm not really skilled in Python development, so if there is custom coding required, I'll have to consult my colleagues to see who might be able to help out... any help would be appreciated.

ryangermann-gov-on-ca avatar Aug 06 '20 21:08 ryangermann-gov-on-ca

Would you post a link to your theme extension and its group/organization schemas?

wardi avatar Aug 07 '20 14:08 wardi

Here is a basic PR that might help as an example of adding organizations in with scheming and fluent. It does a little extra modification to some templates but the PR message helps explain.

I agree, seeing your schema and extension would help troubleshoot what's causing the issue.

boykoc avatar Aug 07 '20 16:08 boykoc

Working with the PR mentioned

ryangermann-gov-on-ca avatar Apr 27 '21 18:04 ryangermann-gov-on-ca

I've dropped in my Scheming config files, if someone could take a look at them I'd appreciate it. I'm also seeing when I click on the "Datasets" button, the list of datasets shows only the English, but when I access the dataset page it shows the French: am I missing a snippet from the Scheming extension?

ryangermann-gov-on-ca avatar Nov 21 '21 18:11 ryangermann-gov-on-ca

Bump.

I am also able to use fluent and scheming extensions to get some translations for groups and organizations. They save in the database and have the correct output and validator snippets to display the data. However, the expected translated values still do not display in many places. E.g. group.read, breadcrumbs, dataset.read, etc.

It seems that CKAN uses the group and org definition of display_name throughout the code and templates. (https://github.com/ckan/ckan/blob/master/ckan/model/group.py#L165)

    @property
    def display_name(self) -> str:
        if self.title is not None and len(self.title):
            return self.title
        else:
            return self.name

I believe this is because the Group/Org title by default is not required. So CKAN uses display_name to fallback to the name/url of the group.

There are pluggable places to override this, but discussing with the ckan devs, translatable things should be accomplished at the template/view layer: https://docs.ckan.org/en/2.9/contributing/architecture.html

So we should not do this at the action level, we would be looking at the view level. Sadly, I cannot really find a place to do this easily in the view methods. Thus, you would have to have an extension that either extends the view functions, or (probably more accurately), just extends all of the templates to instead not access the display_name key on the group dicts.

JVickery-TBS avatar Mar 10 '23 19:03 JVickery-TBS

These should be fixed in core the same way they were for datasets: add calls to get_translated in the right templates

wardi avatar Mar 10 '23 21:03 wardi