Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Festival: translation of contributions and some other improvements #341

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

matthijskooijman
Copy link
Contributor

I did some rough work to make contributions translatable. We discussed doing this along with #131 (external event datatype), but for simplicity and speed, I've just done the translations, still storing them inside the festival page XML, cutting some corners to make this usable for Expo Keerpunt first.

This PR also has code for other things that are currently in use on expokeerpunt.nl, but not merged here yet: An about page, customizable headers above the timetable and lineup and showing some command buttons to non-logged in users. Also, the first three commits here come from #340, so can be ignored here.

Some caveats I found while implementing this:

  1. Translatable contributions and a customizable contribution form are a bit tricky to combine. A customized contribution form needs to describe the complete form, hardcoding pretty much everything with no room for dynamic content. This means that to translate a contribution, there are now just two different language versions of the "add/edit contribution" form, that you can switch between just like with translated pages. This works, but might not be ideal UI. Some way to include multiple translations in a single for (maybe with a tabbed UI or so) might be nice, but that's hard to combine with the hardcoded form customization we use now.
  2. Categories are also tricky. I now chose to translate these, that is, each language stores its own category, in the local language. This makes displaying the category easy, since each language has a display-ready, translated version of the category. It does mean that the category between multiple languages might become inconsistent, and it is hard to programmatically do something with the category (since the same category will be named differently in each language). It also means that different languages might offer different category selections, which could maybe be a feature (though likely just adds confusion). One way to fix this would be to store categories as separate objects, link each contribution to one category object and give each category object a separate title for each language (but a single name or id, to allow referencing it in code or CSS).
  3. Any fields that are not set for a translation, default to the value from another translation (looked at per-field, so you can translate one field and leave another empty). This seemed like a good idea, but in practice this just means that any time you edit a translation, all (empty) fields will be prefilled with a value from another translation (which is convenient for the first translation), but are then explicitly set to that value when saving (i.e. duplicating a value if unchanged). This is not a big deal, but might mean that I can simplify the implementation again to just use values from only the current translation (not looking per field if it is non-empty and doing a fallback to another language if it is), unless the current language has no translation at all, then it still needs to fall back to another language.
  4. Fallback currently means: Use the selected language, or the first one in the XML file otherwise. This probably needs to use a bit of a smarter priority order, similar to the order used for interface language.
  5. The interface language is currently not always determined by the content language, the user language and browser-requested language have more priority. This can mean that a visitor or user selects tot see a specific language, but still sees interface elements / language strings in another language. This is particularly weird when non-customized forms are used, because then the user can select a different language for the form, but nothing changes. This is something to reconsider, but changing this affects all of Hypha, not just this part.
  6. When a custom form is provided in any language, the default autogenerated form will not be used anymore, even when no custom form is available in the selected language (i.e. it prefers a custom form in the wrong language over a non-custom form in the right language). This is probably ok, but maybe should be reflected in the language selection UI.
  7. A lot of the translation-related code should really be made more generic and reusable (e.g. getTranslatedAttribute and friends).

@matthijskooijman matthijskooijman force-pushed the festival-translation branch 2 times, most recently from aa7af48 to a8cd575 Compare September 1, 2020 16:14
@matthijskooijman matthijskooijman marked this pull request as draft September 1, 2020 16:29
This returns a list of all the languages for which this page is defined
(i.e. has an entry in hypha.xml).
This just adds code to render the page, editing must be done manually.
This just adds code to render the headers, editing must be done
manually.
This allows passing a language parameter to the getConfigElement helper,
to retrieve a translated value.
This no longer reads the forms from the config elements directly, but
looks for a language subtag with the right id.

Note that this does not allow the contributions themselves to be
translated yet, just the displayed form.

Also note that this breaks compatibility, without some form of
migration, any custom forms will become unused.
This moves most attributes on the contribution tag to new language
subtags, allowing to specify most things for multiple languages. The
contribution form can now be displayed in different languages, which
then also edits the selected language.

The timetable and lineup views now also have a language selector,
causing all contributions to be displayed in the selected language (if
available, falling back to another language otherwise).

This introduces a new FestivalContribution class that simply wraps the
contribution XML node, adding some methods to access translated
attributes and subtags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant