Skip to content

Commit

Permalink
fix: update exclusions function and tests to use locale vs localeKey
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkmcadoo committed Dec 15, 2021
1 parent 7eb2b21 commit 32191bf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('add-files-to-translation-queue tests', () => {

const setup = () => {
const EXCLUSIONS = {
excludePath: { jp: ['excluded/path'], kr: ['excluded/path'] },
excludeType: { jp: ['excludedType'], kr: ['excludedType'] },
excludePath: { 'ja-JP': ['excluded/path'], 'ko-KR': ['excluded/path'] },
excludeType: { 'ja-JP': ['excludedType'], 'ko-KR': ['excludedType'] },
};
const originalAdd = jest.requireActual('../utils/constants.js');

Expand Down
12 changes: 4 additions & 8 deletions scripts/actions/add-files-to-translation-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const translationDifference = (pendingFiles, prChanges) =>
)
);

const humanTranslatedProjectID = process.env.HUMAN_TRANSLATION_PROJECT_ID;
const machineTranslatedProjectID = process.env.MACHINE_TRANSLATION_PROJECT_ID;
const humanTranslatedProjectID = 'HT_ID';
const machineTranslatedProjectID = 'MT_ID';

/**
* Determines if a file should be included based on data from an exclusions file
Expand All @@ -54,14 +54,10 @@ const excludeFiles = (fileData) => {
const exclusions = getExclusions();

return fileData.filter(({ filename, locale, contentType }) => {
const localeKey = Object.keys(LOCALE_IDS).find(
(localeKey) => LOCALE_IDS[localeKey] === locale
);
return (
!exclusions.excludePath[localeKey]?.some((path) =>
!exclusions.excludePath[locale]?.some((path) =>
filename.startsWith(path)
) &&
!exclusions.excludeType[localeKey]?.some((type) => contentType === type)
) && !exclusions.excludeType[locale]?.some((type) => contentType === type)
);
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"username": "",
"password": "",
"host": "",
"database": ""
"username": "root",
"password": "root",
"host": "localhost",
"database": "translations"
}
4 changes: 3 additions & 1 deletion scripts/actions/utils/docs-content-tools/i18n-exclusions.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
excludePath:
ja-JP:
- /whats-new
- src/content/whats-new
- src/content/docs/release-notes
- src/content/docs/licenses
- src/content/docs/style-guide
- src/content/docs/agile-handbook
- src/data-dictionary
- src/i18n
- src/content/docs/security/security-privacy/data-privacy
excludeType:
ja-JP:
- landingPage

0 comments on commit 32191bf

Please sign in to comment.