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

Fix (i18n): Return the Correct Locale from Filenames - fixes #5909 #5922

Merged
merged 1 commit into from
Oct 25, 2021
Merged

Fix (i18n): Return the Correct Locale from Filenames - fixes #5909 #5922

merged 1 commit into from
Oct 25, 2021

Conversation

andipabst
Copy link
Contributor

@andipabst andipabst commented Oct 23, 2021

Summary
When determining the locale from the filename in a i18n.structure: multiple_files-setup, the code returned g for the file index.gd.md. This was due to the use of the lodash-method trimEnd for removing the file extension.

As per the lodash docs the trimEnd method does not remove the specified string from the end, but instead removes all characters from the end. So in this case when calling

trimEnd('index.gd.md', '.md')

it did not just remove the '.md' at the end, as intended, but instead all occurrences of the characters ., m and d from the end. Thus the result was index.g instead of index.gd.

I changed the implementation to use the String.prototype.slice() method to remove the number of characters of file extension from the end of the string.

This closes #5909.

Test plan
I added jest tests.

Checklist

Please add a x inside each checkbox:

  • I have read the contribution guidelines.
  • Code is formatted via running yarn format.
  • Tests are passing via running yarn test.
  • The status checks are successful (continuous integration). Those can be seen below.

@andipabst andipabst requested a review from a team October 23, 2021 09:27
@erezrokah erezrokah added the type: bug code to address defects in shipped code label Oct 24, 2021
Copy link
Contributor

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

@andipabst, this is 🚀

And also 🤦 since I'm the one who missed on this

@erezrokah erezrokah merged commit 6a42f98 into decaporg:master Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collection list contains broken entries when a Scots Gaelic (GD) translation is added
2 participants