[Koha-bugs] [Bug 24975] Refactor database translations

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Mar 25 14:24:53 CET 2020


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

--- Comment #1 from Julian Maurice <julian.maurice at biblibre.com> ---
Created attachment 101703
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=101703&action=edit
Bug 24975: Refactor database translations

This is an attempt to make the process of translating database strings
(like itemtype descriptions) easier for developers and translators.

For developers by reducing the amount of code needed to enable
translations for a new kind of object (authorised values, letters, news,
...).
For translators by providing a single entry point for all translatable
strings

Table `localization` is replaced by two new tables `l10n_source` and
`l10n_target`. `l10n_source` contains the original text while
`l10n_target` contains the corresponding translations

`l10n_source` is automatically updated whenever an itemtype is
inserted, updated, or deleted, so it is always up to date (this is done
in Koha::Schema::Result::ItemType).
It means that if you delete an itemtype, translations get deleted too.
It also means that if you change an itemtype's description, translations
are lost (not sure if this should be fixed, since if description
changes, translations should probably be changed too)

It adds a new subroutine in Koha::I18N, `db_t`, which returns the
translation for a given context and string, according to the current
language. Translations are stored in memcached (if enabled).

So instead of having to declare a new subroutine
Koha::ItemType::translated_description, you can write
    db_t('itemtype', $itemtype->description)

In templates you can write
    [% ItemTypes.t(itemtype.description) %]

There's also a new page, accessible from the administration main page,
"Localization". It displays all translatable strings and allow to
translate them for all enabled languages.

Test plan:
1. Before applying the patch, make sure you have translated some
   itemtypes. Translations should be kept by the updatedatabase script.
   Before applying the updatedatabase you may want to comment the
   'DROP TABLE localization' statement if you want to keep this table
2. Apply patch, run updatedatabase.pl, run update_dbix_class_files.pl
   and reload starman
3. Go to Admin ยป Localization, verify that you have your itemtypes and
   their translations.
4. Verify that the filter is working (it filters on the source column
   only).
5. Translate some strings by clicking on one of the 'Translate' link,
   entering some text and clicking on the 'Save' button. You can remove
   a translation by emptying the text box.
6. Add a new item type. Verify that it appears in the Localization page
7. Change the description of this item type. Verify that the new
   description appears in Localization page and that the old description
   is gone
8. Delete this item type and verify that its description no longer
   appears in Localization page
9. Navigate through Koha (intranet and opac) in multiple languages and
   verify that item types are translated (if not, please verify in
   master too, not all occurrences were translated)

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list