Skip to content

Commit 72a5aea

Browse files
Ducicatmorrell
authored andcommitted
fix: using app locale for citations
* app was using navigator.language which is always * browser setting. The change enables using localization * based on app settings and using translated strigns that exist in * citeproc library
1 parent b6b878e commit 72a5aea

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordCitationField.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ export class RecordCitationField extends Component {
5858

5959
fetchCitation = async (recordLinks, style, includeDeleted) => {
6060
const includeDeletedParam = includeDeleted === true ? "&include_deleted=1" : "";
61-
const url = `${recordLinks.self}?locale=${navigator.language}&style=${style}${includeDeletedParam}`;
61+
const navLang = (navigator.language || "").toLowerCase();
62+
const uiLang = (i18next.language || "").toLowerCase();
63+
const citationLocale =
64+
uiLang && navLang.startsWith(uiLang)
65+
? navigator.language
66+
: i18next.language || navigator.language;
67+
const url = `${recordLinks.self}?locale=${citationLocale}&style=${style}${includeDeletedParam}`;
6268
return await http.get(url, {
6369
headers: {
6470
Accept: "text/x-bibliography",

0 commit comments

Comments
 (0)