Skip to content

Commit

Permalink
feat: change default sort behaviour to "stableAppendNew", as this kee…
Browse files Browse the repository at this point in the history
…ps the order for units with implicit ID.

BREAKING CHANGE: To retain the previous sort behavior set option `sort: "idAsc"`.
  • Loading branch information
daniel-sc committed May 16, 2022
1 parent 14edd03 commit eff3cad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ In your `angular.json` you'll find a new target `extract-i18n-merge` that can be
| `collapseWhitespace` | `true` | Collapsing of multiple whitespaces/line breaks in translation sources and targets. |
| `includeContext` | `false` | Whether to include the context information (like notes) in the translation files. This is useful for sending the target translation files to translation agencies/services. |
| `newTranslationTargetsBlank` | `false` | When `false` (default) the "target" of new translation units is set to the "source" value. When `true`, an empty string is used. When `'omit'`, no target element is created. |
| `sort` | `"idAsc"` | Sorting of all translation units in source and target translation files. Supported: `"idAsc"` (sort by translation IDs), `"stableAppendNew"` (keep existing sorting, append new translations at the end) |
| `sort` | `"stableAppendNew"` | Sorting of all translation units in source and target translation files. Supported: `"idAsc"` (sort by translation IDs), `"stableAppendNew"` (keep existing sorting, append new translations at the end) |

## Contribute

Expand Down
4 changes: 2 additions & 2 deletions src/builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ describe('Builder', () => {
format: 'xlf',
targetFiles: ['messages.fr.xlf'],
outputPath: 'builder-test',
// default: sort: 'idAsc'
sort: 'idAsc'
});
await run.result;
const result = await run.result;
Expand Down Expand Up @@ -941,7 +941,7 @@ describe('Builder', () => {
format: 'xlf',
targetFiles: ['messages.fr.xlf'],
outputPath: 'builder-test',
sort: 'stableAppendNew'
// default: sort: 'stableAppendNew'
});
await run.result;
const result = await run.result;
Expand Down
2 changes: 1 addition & 1 deletion src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function copyFileBuilder(options: Options, context: BuilderContext): Promi
...(options.removeIdsWithPrefix ?? []).map(removePrefix => isXliffV2 ? `/xliff/file/unit[starts-with(@id,"${removePrefix}")]` : `/xliff/file/body/trans-unit[starts-with(@id,"${removePrefix}")]`)
];
const idPath = isXliffV2 ? '/xliff/file/unit/@id' : '/xliff/file/body/trans-unit/@id';
const sort: Options['sort'] = options.sort ?? 'idAsc';
const sort: Options['sort'] = options.sort ?? 'stableAppendNew';
const normalizedTranslationSourceFile = xmlNormalize({
in: translationSourceFile,
trim: false,
Expand Down
2 changes: 1 addition & 1 deletion src/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"idAsc",
"stableAppendNew"
],
"default": "idAsc",
"default": "stableAppendNew",
"description": "Sorting of all translation units in source and target translation files."
},
"collapseWhitespace": {
Expand Down

0 comments on commit eff3cad

Please sign in to comment.