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: missing fallback translation when no locale available #11

Merged
merged 1 commit into from
Feb 24, 2021

Conversation

Fabio286
Copy link
Contributor

Hi dev,
today i discovered the existence of this translation package for conventional-commit-types with an exception from my Vistual Studio Code installation.

This PR should fix this bug by providing english as fallback localization when a there is no specific localization.

Comment on lines +6 to +7
const fileName =
locale && localizationFiles.includes(`${locale}.json`) ? `${locale}.json` : 'en.json';
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
const fileName =
locale && localizationFiles.includes(`${locale}.json`) ? `${locale}.json` : 'en.json';
const fileName = localizationFiles.includes(`${locale}.json`) ? `${locale}.json` : 'en.json';

It can deal with the undefined and empty string input.

@@ -5,6 +5,7 @@ import { conventionalCommitsTypes } from '../src/index';
describe('conventionalCommitsTypes() function test', () => {
it.each([
['en.json', undefined],
['en.json', 'unknown-locale'],
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
['en.json', 'unknown-locale'],
['en.json', ''],
['en.json', 'unknown-locale'],

Add test for the empty string input.

@yi-Xu-0100
Copy link
Owner

@Fabio286 I will do the change by myself and publish it quickly. Thanks for your contribution. 👍

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.

None yet

2 participants