Koha-clms/Koha/REST/V1
Julian Maurice ca5db9ffb7
Bug 38630: Make the REST API respect KohaOpacLanguage cookie
The REST API can return translated strings to the opac or staff
interface, so it should respect the KohaOpacLanguage cookie and return
translations in the same language than the interface.

Test plan:
1. Do not apply patch yet
2. Log in to koha staff interface
3. Use the browser's devtools to get the value of CGISESSID cookie
4. Make sure you have at least 2 languages installed ('en' + another
   one - I'll use 'fr-FR' as an example in this test plan)
5. Find an item and note its itemnumber and itemtype
6. Go translate this itemtype's description (admin » item types » edit
   item type » translate). Add a translation for 'en' and another one
   for your language.
7. Close your browser tab (do not logout) and restart Koha to flush the
   memory cache.
8. Execute the following commands (replace variables by the correct
   value):

    curl -sSL "$KOHA_URL/api/v1/items/$ITEMNUMBER" \
        -H 'x-koha-embed: +strings' \
        -H "Cookie: KohaOpacLanguage=en; CGISESSID=$CGISESSID" \
        | jq -r '._strings.item_type_id.str'

   If you do not have jq, it can be found in most distributions
   packages. Or you could inspect the JSON manually at the path
   /_strings/item_type_id/str

   Restart Koha again, and execute the same command but with your
   language set in KohaOpacLanguage cookie:

    curl -sSL "$KOHA_URL/api/v1/items/$ITEMNUMBER" \
        -H 'x-koha-embed: +strings' \
        -H "Cookie: KohaOpacLanguage=fr-FR; CGISESSID=$CGISESSID" \
        | jq -r '._strings.item_type_id.str'

   Depending on how Koha sort the languages (not sure how it's done),
   you should get either the 'en' one or the 'fr-FR' one, but the
   important thing is you should get the same translation, no matter
   what the value of KohaOpacLanguage is, which is the issue this patch
   is trying to fix.
9. Apply the patch and restart Koha
10. Repeat step 8. This time you should get the translation
    corresponding to the language set in KohaOpacLanguage cookie

Side note:
* The need to restart Koha before each request is due to a bug (see bug
  38454). If already pushed when you're testing this one, you don't have
  to restart.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-30 18:05:24 +01:00
..
Acquisitions Bug 38204: Tidy 2024-10-30 07:47:42 +01:00
Auth Bug 36937: Remove warning from unit tests 2024-06-13 14:14:08 +01:00
Biblios Bug 37791: Fix 'Biblio not found' messages on the API 2024-10-11 12:21:29 +02:00
CashRegisters Bug 37686: Fix render_resource_not_found() and render_resource_deleted() misses 2024-08-29 18:16:19 +02:00
Clubs Bug 38929: Make POST endpoints return the `Location` header 2025-01-24 16:14:27 +01:00
Config/SMTP Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00
ERM Bug 38466: Fix error messages in KBART import 2024-12-03 17:33:59 +01:00
ILL Bug 38929: Make POST endpoints return the `Location` header 2025-01-24 16:14:27 +01:00
OAuth Bug 36219: Re-add missing state param for Oauth/OIDC client 2024-03-04 14:50:41 +01:00
Patrons Bug 38932: Make adding a credit return the Location header 2025-01-24 16:14:30 +01:00
Preservation Bug 37686: Fix render_resource_not_found() and render_resource_deleted() misses 2024-08-29 18:16:19 +02:00
StockRotation Bug 37686: Fix render_resource_not_found() and render_resource_deleted() misses 2024-08-29 18:16:19 +02:00
AdvancedEditorMacro.pm Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00
ArticleRequests.pm Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00
Auth.pm Bug 38630: Make the REST API respect KohaOpacLanguage cookie 2025-01-30 18:05:24 +01:00
AuthorisedValueCategories.pm Bug 34920: Return sorted av_cats to be able to test 2024-07-01 18:55:47 +02:00
AuthorisedValues.pm Bug 36495: Use render_resource_not_found() helper everywhere 2024-04-26 18:06:13 +02:00
Authorities.pm Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00
BackgroundJobs.pm Revert "Bug 36217: Fix background jobs page's include_last_hour filter" 2024-10-18 14:26:01 +02:00
Biblios.pm Bug 38929: Make POST endpoints return the `Location` header 2025-01-24 16:14:27 +01:00
Bookings.pm Bug 38175: (QA follow-up) DRY out PATCH handling 2024-10-24 18:27:24 +02:00
Checkouts.pm Bug 37253: Enhance POST /checkouts endpoint to accept barcode or item_id 2024-10-25 11:09:48 +02:00
CirculationRules.pm Bug 36641: (follow-up) Ensure limited return works 2024-07-18 18:25:49 +02:00
Cities.pm Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00
DeletedBiblios.pm Bug 37791: Fix 'Biblio not found' messages on the API 2024-10-11 12:21:29 +02:00
ERM.pm Bug 33606: (QA follow-up) Cosmetic changes 2023-07-06 12:24:15 -03:00
ExtendedAttributeTypes.pm Bug 37577: Add additional fields for ERM packages 2024-11-08 16:09:19 +01:00
Holds.pm Bug 38929: Make POST endpoints return the `Location` header 2025-01-24 16:14:27 +01:00
ImportBatchProfiles.pm Bug 38929: Make POST endpoints return the `Location` header 2025-01-24 16:14:27 +01:00
ImportRecordMatches.pm Bug 36495: Use render_resource_not_found() helper everywhere 2024-04-26 18:06:13 +02:00
ItemTypes.pm Bug 34008: (QA follow-up) 'item_type_id' should be used 2023-11-01 17:23:15 -03:00
Items.pm Bug 37686: Fix render_resource_not_found() and render_resource_deleted() misses 2024-08-29 18:16:19 +02:00
Libraries.pm Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00
Lists.pm Bug 28965: (QA follow-up) Fix misc qa issues 2024-11-08 16:09:22 +01:00
OAuth.pm Bug 33556: Avoid relying on $c->validation 2023-07-21 17:14:37 -03:00
Patrons.pm Bug 36505: (follow-up) Consistent error codes in POST 2024-04-26 18:06:16 +02:00
Preservation.pm Bug 30708: Tidy perl files 2023-10-18 15:42:04 -03:00
Quotes.pm Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00
RecordSources.pm Bug 37513: Handle Koha::Exceptions::Object::FKConstraintDeletio in controller 2024-08-27 12:14:24 +02:00
ReturnClaims.pm Bug 33292: Add logic to handle refunding a lost fee 2024-10-24 13:38:15 +02:00
SearchFilter.pm Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00
Static.pm Bug 37686: Fix render_resource_not_found() and render_resource_deleted() misses 2024-08-29 18:16:19 +02:00
Suggestions.pm Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00
Tickets.pm Bug 35657: Add support for assignee_id to ticket_updates endpoint 2024-05-02 15:03:35 +02:00
TransferLimits.pm Bug 38929: Make POST endpoints return the `Location` header 2025-01-24 16:14:27 +01:00
TwoFactorAuth.pm Bug 36495: Use render_resource_deleted() helper everywhere 2024-04-26 18:06:14 +02:00