https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38630
David Nind <da...@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #175238|0 |1 is obsolete| | --- Comment #4 from David Nind <da...@davidnind.com> --- Created attachment 176226 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=176226&action=edit 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 <da...@davidnind.com> -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list Koha-bugs@lists.koha-community.org https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/