Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only translate name.default when translation is same source and source_id #1555

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

missinglink
Copy link
Member

@missinglink missinglink commented Aug 17, 2021

The middleware/changeLanguage.js code is a little too liberal when replacing the name.default with a translation.
Prior to this PR the code replaces name.default without first checking the source and source_id.

note: I struggled a bit to read and write this code, requires a second set of 👀

@orangejulius
Copy link
Member

I think we talked about this the other day, but can you provide some more details and background here regarding the issue at hand, maybe some test cases, etc? It will be good to have for reference in the future.

if (adminLayer !== doc.layer){ continue; }
if (adminSource !== doc.source){ continue; }
if (_.toString(adminID) !== _.toString(doc.source_id)){ continue; }
doc.name.default = translations[adminID].names[requestLanguage][0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we actually need this line now. Looking through the history of this file, the translateNameDefault method was added in 2019 in #1301, whereas the rest of the file is mostly much older.

It might be that the name translation is already handled well now? I'm not 100% sure, the intention behind this code is definitely hard to read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants