diff --git a/models/classes/Translation/Service/ResourceTranslationRetriever.php b/models/classes/Translation/Service/ResourceTranslationRetriever.php index 28420698f1..dbc609d48a 100644 --- a/models/classes/Translation/Service/ResourceTranslationRetriever.php +++ b/models/classes/Translation/Service/ResourceTranslationRetriever.php @@ -47,6 +47,9 @@ public function getByRequest(ServerRequestInterface $request): ResourceCollectio throw new ResourceTranslationException('Resource id is required'); } - return $this->resourceTranslationRepository->find(new ResourceTranslationQuery([$id], $languageUri)); + if (!is_array($id)) { + $id = explode(',', $id); + } + return $this->resourceTranslationRepository->find(new ResourceTranslationQuery($id, $languageUri)); } } diff --git a/views/js/services/translation.js b/views/js/services/translation.js index 5473bf6194..77d8ce7eae 100644 --- a/views/js/services/translation.js +++ b/views/js/services/translation.js @@ -286,13 +286,25 @@ define(['i18n', 'core/request', 'util/url'], function (__, request, urlUtil) { /** * Queries the list of translations for a resource. - * @param {string} id - The URI of the resource. - * @param {function} [filter] - A filter function for the translations. + * @param {string|string[]} id - The URI of the resource. It may also be a list of URIs, but in this case the languageUri must also be provided. + * @param {string|function} [languageUri] - The URI of the language to filter the translations. It may also be a filter function. + * @param {function} [filter] - A filter function for the translations. When not provided through the languageUri parameter. * @returns {Promise} */ - getTranslations(id, filter) { + getTranslations(id, languageUri, filter) { + if (Array.isArray(id)) { + id = id.join(','); + } + const params = { id }; + if (languageUri) { + if ('function' === typeof languageUri) { + filter = languageUri; + } else { + params.languageUri = languageUri; + } + } return request({ - url: urlUtil.route('translations', 'Translation', 'tao', { id }), + url: urlUtil.route('translations', 'Translation', 'tao', params), method: 'GET', noToken: true })