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

XLIFF Sync - New Build with Translations command #122

Merged
merged 14 commits into from
Aug 16, 2024
Merged
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## [1.5.3] 24-07-2024

* Changed default setting for `xliffSync.defaultLanguages` to empty
* Fixed extension not asking for languages when generating translations with `xliffSync.defaultLanguages` being empty
* Changed settings order
* Renamed `README-CUSTOM` to `README-NEW-FEATURES`

## [1.5.2] 19-07-2024

* Fixed saving Translation file issue when no Auto Save and using the `xliffSync.buildWithTranslations` command
* Updated `README` with new Features
* Created `README-CUSTOM` for new Features

## [1.5.1] 18-07-2024

* New setting `xliffSync.defaultLanguages` that specifies the languages to automatically use when generating translations
* New setting `xliffSync.buildCommandToExecute` that specifies the build command to execute for the `xliffSync.buildWithTranslations` command
* Fixed `xliffSync.buildWithTranslations` command syncing translations twice

## [1.5.0] 17-07-2024

* New command `xliffSync.buildWithTranslations` that combines multiple commands into one

## [1.4.0] 30-12-2022

* New setting `xliffSync.useSelfClosingTags` that can be used to specify whether to use self-closing tags in the XLIFF target translation files. (GitHub issue [#97](https://github.com/rvanbekkum/vsc-xliff-sync/issues/97))
Expand Down
37 changes: 37 additions & 0 deletions README-NEW-FEATURES.md
rvanbekkum marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# XLIFF Sync - New Features

## Installation
![Install Guide](resources/custom_xliffSync_installSteps.png)

Then choose the `xliff-sync.vsix` file found in [Latest Release](https://github.com/FlorianNoeverGOB/vsc-xliff-sync/releases/latest)

## Added Settings & Features

### Default Languages
Xliff file generation now uses the languages defined in this Setting
![Default Languages Setting](resources/custom_xliffSync_defaultLanguages.png)

### Build Command To Execute
When using the new Command `Build with Translations` the command specified in this Setting will be used for building the App
![Build Command To Execute Setting](resources/custom_xliffSync_buildCommandToExecute.png)

### Build with Translations
This new command (Shortcut: Ctrl+Shift+T) combines all actions into one command:
> 1. Delete current translation files
> 2. Build App using the build command defined in new Setting `Build Command To Execute`
> 3. Create new Target files for Languages defined in new Setting `Default Languages`
> 4. Syncs Translations files to show if translations are missing

To use this, a file from the App for which you want to update the Translations has to be opened. Then execute the command.

## Recommended Settings

### Files: Associations
Recommended setting this to

| Item | Value |
| ---- | ----- |
| *.xlf | plaintext |

This improves the general performance of the Xliff file generation at the Cost of not having a color applied to the content of the Xliff files
![Files Associations *.xlf to plaintext](resources/custom_xliffSync_recommendedSettings.png)
77 changes: 59 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XLIFF Sync

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Version](https://vsmarketplacebadges.dev/version-short/rvanbekkum.xliff-sync.svg?color=blue)](https://marketplace.visualstudio.com/items?itemName=rvanbekkum.xliff-sync) [![Installs](https://vsmarketplacebadges.dev/installs/rvanbekkum.xliff-sync.svg?color=blue)](https://marketplace.visualstudio.com/items?itemName=rvanbekkum.xliff-sync)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.png)](https://opensource.org/licenses/MIT)
rvanbekkum marked this conversation as resolved.
Show resolved Hide resolved

<a href="https://www.buymeacoffee.com/robvanbekkum" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

Expand All @@ -20,21 +20,39 @@ View the demo in the [Areopa](https://areopa.academy/) webinar recording: [VS Co

More information: [XLIFF Sync: Time for a complete overview](https://robvanbekkum.nl/xliff-sync-overview/)

* [Features](#features)
* [Contributions](#contributions)
* [Commands](#commands)
* [Settings](#settings)
* [Usage](#usage)
* [Create New Target File(s)](#create-new-target-files)
* [Synchronize to Single File](#synchronize-to-single-file)
* [Synchronize Translation Units](#synchronize-translation-units)
* [Check for Missing Translations](#check-for-missing-translations)
* [Check for Need Work Translations](#check-for-need-work-translations)
* [Find Next Missing Translation in XLIFF File](#find-next-missing-translation-in-xliff-file)
* [Find Next Needs Work Translation in XLIFF File](#find-next-needs-work-translation-in-xliff-file)
* [Import Translations from File(s)](#import-translations-from-files)
* [Known Issues](#known-issues)
* [Contributors](#contributors)
- [XLIFF Sync](#xliff-sync)
- [Summary](#summary)
- [Features](#features)
- [Contributions](#contributions)
- [Commands](#commands)
- [Settings](#settings)
- [Usage](#usage)
- [Create New Target File(s)](#create-new-target-files)
- [Using the Command Palette](#using-the-command-palette)
- [Synchronize to Single File](#synchronize-to-single-file)
- [Using the Command Palette](#using-the-command-palette-1)
- [Using keyboard shortcut](#using-keyboard-shortcut)
- [Synchronize Translation Units](#synchronize-translation-units)
- [Using the Command Palette](#using-the-command-palette-2)
- [Using keyboard shortcut](#using-keyboard-shortcut-1)
- [From the Explorer](#from-the-explorer)
- [Check for Missing Translations](#check-for-missing-translations)
- [Using the Command Palette](#using-the-command-palette-3)
- [Check for Need Work Translations](#check-for-need-work-translations)
- [Using the Command Palette](#using-the-command-palette-4)
- [Find Next Missing Translation in XLIFF File](#find-next-missing-translation-in-xliff-file)
- [Using the Command Palette](#using-the-command-palette-5)
- [Using keyboard shortcut](#using-keyboard-shortcut-2)
- [Find Next Needs Work Translation in XLIFF File](#find-next-needs-work-translation-in-xliff-file)
- [Using the Command Palette](#using-the-command-palette-6)
- [Using keyboard shortcut](#using-keyboard-shortcut-3)
- [Import Translations from File(s)](#import-translations-from-files)
- [Using the Command Palette](#using-the-command-palette-7)
- [Build with Translations](#build-with-translations)
- [Using the Command Palette](#using-the-command-palette-8)
- [Using keyboard shortcut](#using-keyboard-shortcut-4)
- [Known Issues](#known-issues)
- [Contributors](#contributors)

## Features

Expand All @@ -61,6 +79,7 @@ More information: [XLIFF Sync: Time for a complete overview](https://robvanbekku
| **XLIFF: Next Missing Translation** | In an XLIFF file that is currently opened in the active editor, search for the next missing translation. |
| **XLIFF: Next Needs Work Translation** | In an XLIFF file that is currently opened in the active editor, search for the next translation tagged as `needs-adaptation`. |
| **XLIFF: Import Translations from File(s)** | Import/Copy translations from external XLIFF files to trans-units with matching sources of target XLIFF files with the same target-language. |
| **XLIFF: Build with Translations** | Deletes, Builds and generates Translations all in one for the current opened files App |

![XLIFF Sync Command Palette Commands](resources/xliffSync_commandPaletteCommands.png)

Expand Down Expand Up @@ -94,7 +113,7 @@ More information: [XLIFF Sync: Time for a complete overview](https://robvanbekku
| xliffSync.clearTranslationAfterSourceTextChange | `false` | Specifies whether translations should be cleared when the source text of a trans-unit changed. |
| xliffSync.addNeedsWorkTranslationNote | `true` | Specifies whether an XLIFF Sync note should be added to explain why a trans-unit was marked as needs-work. |
| xliffSync.useSelfClosingTags | `true` | Specifies whether the XML tags in the XLIFF target files should be self-closing tags. (i.e., `<note></note>` vs. `<note/>`). |
| xliffSync.keepEditorOpenAfterSync | `true` | Specifies whether XLIFF files should be opened in the editor after syncing. |
| xliffSync.keepEditorOpenAfterSync | `false` | Specifies whether XLIFF files should be opened in the editor after syncing. |
rvanbekkum marked this conversation as resolved.
Show resolved Hide resolved
| xliffSync.openExternallyAfterEvent | `[]` | Specifies after which event translation files should be opened automatically with the default XLIFF editor. Options: "Check", "ProblemDetected", "Sync" |
| xliffSync.developerNoteDesignation | `Developer` | Specifies the name that is used to designate a developer note. |
| xliffSync.xliffGeneratorNoteDesignation | `Xliff Generator` | Specifies the name that is used to designate a XLIFF generator note. |
Expand All @@ -111,6 +130,8 @@ More information: [XLIFF Sync: Time for a complete overview](https://robvanbekku
| xliffSync.decorationTargetTextOnly | `false` | Specifies whether decorations for missing translations and translations that need work should only be applied to the target text. |
| xliffSync.enableSnippetsForLanguages | `[]` | Specifies the programming languages for which the XLIFF Sync snippets should be enabled. Currently supported: `al`. |
| xliffSync.snippetTargetLanguage | `TargetLanguageCode` | Specifies which target language to use by default in the XLIFF Sync snippets (e.g., `nl-NL`). |
| xliffSync.defaultLanguages | `[ en-US, de-DE ]` | Specifies the languages that should automatically be used for the translation file generation.|
rvanbekkum marked this conversation as resolved.
Show resolved Hide resolved
| xliffSync.buildCommandToExecute | `al.package` | Specifies the build command to execute when building with translations. |

## Usage

Expand Down Expand Up @@ -138,7 +159,7 @@ If no trans-unit or translation is found, the unit is added and its target node
> 1. F1 or Ctrl/Cmd + Shift + P to open the command palette
> 2. **XLIFF: Create New Target File(s)**

This command will let you create one or more new target files, letting you choose from a set of RFC 4646 or RFC 5646 language tags depending on the XLIFF file type (i.e., `xlf` or `xlf2`).
This command will let you create one or more new target files, using the languages specified in the `xliffSync.defaultLanguages` setting or when empty letting you choose from a set of RFC 4646 or RFC 5646 language tags depending on the XLIFF file type (i.e., `xlf` or `xlf2`).
The new file is automatically synced with the base file; if it is not known you will be prompted to specify the file to use as the base file first.

![XLIFF Sync Create New Target Files Options](resources/xliffSync_createNewTargetFilesOptions.png)
Expand Down Expand Up @@ -283,6 +304,25 @@ That way you could utilize the Developer note to have the import perform a more

More detailed instruction: [Import Translations from Files](https://robvanbekkum.nl/xliff-sync-overview/#import-translations-from-files)

### Build with Translations

#### Using the Command Palette

> 1. F1 or CMD + Shift + P to open the command palette
> 2. **XLIFF: Build with Translations**

#### Using keyboard shortcut

> 1. Ctrl + Shift + T (default shortcut)

This command combines multiple actions into one command:
> 1. Delete current translation files
> 2. Build App using the build command defined in new Setting `xliffSync.buildCommandToExecute`
> 3. Create new Target files for Languages defined in new Setting `xliffSync.defaultLanguages`
> 4. Syncs Translations files to show if translations are missing

To use this, a file from the App for which you want to update the Translations has to be opened. Then execute the command.

## Known Issues

* Automatically inserting _new_ groups into target files is not implemented.
Expand All @@ -295,6 +335,7 @@ More detailed instruction: [Import Translations from Files](https://robvanbekkum
* [manux54](https://github.com/manux54)
* [rvanbekkum](https://github.com/rvanbekkum)
* [warlof](https://github.com/warlof)
* [der_floh](https://github.com/Der-Floh)

You can find the contributions in the [Changelog](https://marketplace.visualstudio.com/items/rvanbekkum.xliff-sync/changelog).
Thank you all! 🤍
39 changes: 36 additions & 3 deletions 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": "1.4.0",
"version": "1.5.3",
"publisher": "rvanbekkum",
"repository": {
"type": "git",
Expand Down Expand Up @@ -220,8 +220,9 @@
},
"xliffSync.keepEditorOpenAfterSync": {
"type": "boolean",
"default": true,
"default": false,
rvanbekkum marked this conversation as resolved.
Show resolved Hide resolved
"description": "Specifies whether XLIFF files should be opened in the editor after syncing.",
"order": 2,
rvanbekkum marked this conversation as resolved.
Show resolved Hide resolved
"scope": "resource"
},
"xliffSync.openExternallyAfterEvent": {
Expand Down Expand Up @@ -383,6 +384,28 @@
"default": "TargetLanguageCode",
"description": "Specifies which target language to use by default in the XLIFF Sync snippets.",
"scope": "resource"
},
"xliffSync.defaultLanguages": {
rvanbekkum marked this conversation as resolved.
Show resolved Hide resolved
"type": "array",
"items": {
"type": "string",
"pattern": "^[a-z]{2}-[A-Z]{2}$"
Copy link
Owner

Choose a reason for hiding this comment

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

There are also some language tags that don't follow this pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a pattern that works for all? Or is it the best to just remove the pattern entirely?

Copy link
Owner

Choose a reason for hiding this comment

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

They are RFC 4646 or RFC 5646 language tags, but I think it might be better to just remove the pattern as I otherwise a RegEx that is a bit too complex. I think it's good enough if people can type in anything they want and think for themselves whether it is a valid tag. ;)

},
"examples": [
"en-US",
"de-DE"
],
"uniqueItems": true,
"description": "Specifies the languages that should automatically be used for the translation file generation. \nExamples: \"en-US\", \"de-DE\".",
"order": 0,
"scope": "resource"
},
"xliffSync.buildCommandToExecute": {
"type": "string",
"default": "al.package",
"description": "Specifies the build command to execute when building with translations.",
"order": 1,
"scope": "resource"
}
}
},
Expand Down Expand Up @@ -426,6 +449,11 @@
"command": "xliffSync.importTranslationsFromFiles",
"title": "Import Translations from File(s)",
"category": "XLIFF"
},
{
"command": "xliffSync.buildWithTranslations",
"title": "Build with Translations",
"category": "XLIFF"
}
],
"keybindings": [
Expand All @@ -446,6 +474,11 @@
"command": "xliffSync.findNextNeedsWorkTarget",
"key": "alt+x w",
"when": "resourceExtname == .xlf"
},
{
"command": "xliffSync.buildWithTranslations",
"key": "ctrl+shift+t",
"when": "workspaceFolderCount > 0"
}
],
"menus": {
Expand Down Expand Up @@ -514,4 +547,4 @@
"xml2js": "^0.4.19",
"xmlbuilder": "^9.0.7"
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

Rename (remove the custom_).
Also for the other new files.

Copy link
Owner

Choose a reason for hiding this comment

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

Now that I think of it, these files are probably not referenced anymore now that the 'custom README' was removed.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/custom_xliffSync_defaultLanguages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/custom_xliffSync_installSteps.png
Copy link
Owner

Choose a reason for hiding this comment

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

This one can be removed.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/xliffSync_commandPaletteCommands.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from 'vscode';

import { registerSnippets } from './features/snippets';
import { synchronizeFiles, synchronizeWithSelectedFile, createNewTargetFiles } from './features/trans-sync';
import { synchronizeFiles, synchronizeWithSelectedFile, createNewTargetFiles, buildWithTranslations } from './features/trans-sync';
import { XliffTranslationChecker } from './features/trans-check';
import { XliffTranslationImport } from './features/trans-import';

Expand All @@ -13,7 +13,7 @@ export function activate(context: ExtensionContext) {
new XliffTranslationImport(context);

context.subscriptions.push(
commands.registerCommand('xliffSync.createNewTargetFiles', async() => {
commands.registerCommand('xliffSync.createNewTargetFiles', async () => {
createNewTargetFiles();
})
);
Expand All @@ -35,6 +35,12 @@ export function activate(context: ExtensionContext) {
})
);

context.subscriptions.push(
commands.registerCommand('xliffSync.buildWithTranslations', async () => {
buildWithTranslations();
})
);

registerSnippets();
}

Expand Down
Loading