Skip to content

Commit

Permalink
Merge pull request #55 from rvanbekkum/feature/53-fix-basefile-setting
Browse files Browse the repository at this point in the history
Do not add xliffSync.baseFile setting if there is only a single matching file
  • Loading branch information
rvanbekkum authored Sep 3, 2020
2 parents 5444d08 + c7488b4 commit c0c879f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [0.5.1] 03-09-2020

* Fix: Do not add `xliffSync.baseFile` setting if there is only a single matching file.
* Account for whitespace in missing translation decoration

## [0.5.0] 08-08-2020

* Better XLIFF 2.0 support:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

A VSCode extension to keep XLIFF translation files in sync with a specified, automatically generated base-XLIFF file.

**Update**: There is now also an ["XLIFF Sync" PowerShell module](https://github.com/rvanbekkum/ps-xliff-sync)!

This project originated from the need for a tool to automatically merge/synchronize XLIFF translation files that are in the OASIS specification.
This extension is based on the [Angular Localization Helper](https://github.com/manux54/vsc-angular-localization-helper) developed by [manux54](https://github.com/manux54), which has been extended so that it can also be used to synchronize files from other XLIFF generators.
It is specifically targeted at synchronizing trans-units from an `<ApplicationName>.g.xlf` file automatically generated by the [AL Language](https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al) extension that can be used to develop extensions for Microsoft Dynamics 365 Business Central.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "xliff-sync",
"displayName": "XLIFF Sync",
"description": "A tool to keep XLIFF translation files in sync.",
"version": "0.5.0",
"version": "0.5.1",
"publisher": "rvanbekkum",
"repository": {
"type": "git",
Expand Down
7 changes: 6 additions & 1 deletion src/features/tools/files-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ export class FilesHelper {

const sourceUris: Uri[] | undefined = baseFile ? xliffUris.filter((uri) => uri.fsPath.indexOf(baseFile) >= 0) : undefined;
if (sourceUris) {
sourceUri = await this.selectBaseFile(sourceUris, resourceUri);
if (sourceUris.length === 1) {
sourceUri = sourceUris[0];
}
else {
sourceUri = await this.selectBaseFile(sourceUris, resourceUri);
}
}

if (!sourceUri) {
Expand Down
6 changes: 3 additions & 3 deletions src/features/trans-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ export class XliffTranslationChecker {
'missingTranslation'
];
if (missingTranslationKeyword === '%EMPTY%') {
missingTranslationKeyword = '<target( state="needs-translation")?/>|<target( state="needs-translation")?></target>';
missingTranslationKeyword = '<target.*( state="needs-translation")?.*/>|<target.*( state="needs-translation")?.*></target>';
}
else if (decorationTargetTextOnly) {
missingTranslationKeyword = `(?<=<target( state="needs-translation")?>)${missingTranslationKeyword}(?=</target>)`;
missingTranslationKeyword = `(?<=<target.*( state="needs-translation")?.*>)${missingTranslationKeyword}(?=</target>)`;
}
else {
missingTranslationKeyword = `<target( state="needs-translation")?>${missingTranslationKeyword}</target>`;
missingTranslationKeyword = `<target.*( state="needs-translation")?.*>${missingTranslationKeyword}</target>`;
}
return missingTranslationKeyword;
}
Expand Down

0 comments on commit c0c879f

Please sign in to comment.