https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39118

--- Comment #5 from Frédéric Demians <[email protected]> ---
Created attachment 207980
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207980&action=edit
Bug 39118: Make facet labels translatable

The labels of the Elasticsearch facets come from search_field.label. Only
the labels of the default facets are translatable, because they are
hardcoded in the facets templates. The label of a facet added or
modified by the user is always displayed as it is.

This patch uses the database translations of bug 38136 for the search
field labels:

- The search fields are deleted and recreated each time the
  Elasticsearch mappings are saved, so their id changes. The
  translations are attached to the search field name instead. The
  localization component now stores the column passed to
  localization_add_relationships and uses it instead of the primary
  key.
- The localization cache of an entity was built with the translations
  of all entities. It is now built with the translations of this entity
  only.
- The translation page and service required manage_itemtypes for any
  entity. Each localizable result class now declares the permission
  needed with localization_permission: manage_search_engine_config for
  the search fields. An unknown source gives a 404 (page) or an error
  (service).
- The facet order table of the Elasticsearch configuration page has a
  "Translate into other languages" link for the facets with a custom
  label.
- The facets of the staff interface and of the OPAC show the translated
  label for these facets.

The "Return to item type" button of the translation page was never
displayed (it tested an undefined variable): it is fixed, and a
"Return to search engine configuration" button is added for the search
fields.

Test plan:
1. Start KTD with Elasticsearch (ktd --es8 up) and install a second
   language:
     ktd --shell --root
     koha-translate --install fr-CA --dev kohadev
   Enable it in OPACLanguages and StaffInterfaceLanguages.
2. Go to Administration > Search engine configuration (Elasticsearch):
   - Search fields tab: change the label of index-term-genre to
     'Genre/Form'
   - Bibliographic records tab: add index-term-genre to the facet order
     table, set it facetable, and save.
3. Reindex: misc/search_tools/rebuild_elasticsearch.pl -b -v -d
4. Search for "comedy" in the staff interface and the OPAC, in English
   and in French: the facet is labeled 'Genre/Form' in both languages.
5. Apply the patch, restart_all.
6. On the Bibliographic records tab, click "Translate into other
   languages" under 'Genre/Form' in the facet order table. Add the
   fr-CA translation 'Genre/Forme'.
7. Repeat 4: the facet is labeled 'Genre/Forme' in French, and still
   'Genre/Form' in English.
8. Save the Elasticsearch mappings again, and repeat 7: the translation
   is kept.
9. Check that the translations of item types still work (Administration
   > Item types > Edit > Translate into other languages).
10. With a staff user having manage_search_engine_config but not
    manage_itemtypes, check that the search field labels can be
    translated, but not the item type descriptions.
11. prove t/db_dependent/Koha/SearchField.t \
          t/db_dependent/Koha/ItemTypes.t \
          t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to