Skip to content

Commit

Permalink
Sync. to Single File -> Auto-run checks for single file
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanbekkum committed Sep 15, 2019
1 parent f190d2e commit b7f42a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/features/trans-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,15 @@ export async function runTranslationChecks(shouldCheckForMissingTranslations: bo
}
}

export async function runTranslationChecksForWorkspaceFolder(checkWorkspaceFolder: WorkspaceFolder, shouldCheckForMissingTranslations: boolean, shouldCheckForNeedWorkTranslations: boolean) {
export async function runTranslationChecksForWorkspaceFolder(checkWorkspaceFolder: WorkspaceFolder, shouldCheckForMissingTranslations: boolean, shouldCheckForNeedWorkTranslations: boolean, singleTargetUri?: Uri) {
try {
let uris: Uri[] = await getXliffFileUrisInWorkSpace(checkWorkspaceFolder);

let sourceUri: Uri = await getXliffSourceFile(checkWorkspaceFolder, uris);
let targetUris = uris.filter((uri) => uri !== sourceUri);
if (singleTargetUri) {
targetUris = [singleTargetUri];
}

let missingTranslationText: string = workspace.getConfiguration('xliffSync', checkWorkspaceFolder.uri)[
'missingTranslation'
Expand Down
6 changes: 3 additions & 3 deletions src/features/trans-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ async function synchronizeTargetFile(workspaceFolder: WorkspaceFolder, sourceUri

await FilesHelper.createNewTargetFile(targetUri, newFileContents, sourceUri, targetLanguage);
if (targetUri) {
await autoRunTranslationChecks(workspaceFolder);
await autoRunTranslationChecks(workspaceFolder, targetUri);
}
}

Expand All @@ -285,13 +285,13 @@ async function synchronizeAllFiles(workspaceFolder: WorkspaceFolder, sourceUri:
await autoRunTranslationChecks(workspaceFolder);
}

async function autoRunTranslationChecks(workspaceFolder: WorkspaceFolder) {
async function autoRunTranslationChecks(workspaceFolder: WorkspaceFolder, targetUri?: Uri) {
const autoCheckMissingTranslations: boolean = workspace.getConfiguration('xliffSync', workspaceFolder.uri)[
'autoCheckMissingTranslations'
];
const autoCheckNeedWorkTranslations: boolean = workspace.getConfiguration('xliffSync', workspaceFolder.uri)[
'autoCheckNeedWorkTranslations'
];

runTranslationChecksForWorkspaceFolder(workspaceFolder, autoCheckMissingTranslations, autoCheckNeedWorkTranslations);
runTranslationChecksForWorkspaceFolder(workspaceFolder, autoCheckMissingTranslations, autoCheckNeedWorkTranslations, targetUri);
}

0 comments on commit b7f42a4

Please sign in to comment.