Skip to content

Commit a3029c5

Browse files
committed
fix: keepFulfilled triggering, close #581
1 parent 0c5828d commit a3029c5

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

examples/by-features/100-locales/.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"i18n-ally.keystyle": "nested",
77
"i18n-ally.translate.engines": ["google-cn"],
88
"i18n-ally.translate.parallels": 5,
9-
"i18n-ally.editor.preferEditor": true,
9+
// "i18n-ally.editor.preferEditor": true,
1010
"i18n-ally.review.removeCommentOnResolved": true,
1111
"i18n-ally.readonly": false,
12-
"i18n-ally.enabledFrameworks": "vue"
12+
"i18n-ally.enabledFrameworks": ["vue"],
13+
"i18n-ally.keepFulfilled": true,
1314
}

examples/by-frameworks/ui5/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "ui5CliTest",
2+
"name": "ui5-cli-test",
33
"description": "",
44
"devDependencies": {
55
"@ui5/cli": "^2.10.4"

src/commands/manipulations/fulfillKeys.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function FulfillMissingKeysForProgress(item: ProgressSubmenuItem) {
2929
return pendings
3030
}
3131

32-
export async function FulfillAllMissingKeys(prompt = true) {
32+
export async function FulfillAllMissingKeys(prompt = true, extraKeys?: string[]) {
3333
if (prompt) {
3434
const Yes = i18n.t('prompt.button_yes')
3535
const result = await window.showWarningMessage(
@@ -44,7 +44,15 @@ export async function FulfillAllMissingKeys(prompt = true) {
4444
let pendings: PendingWrite[] = []
4545
const loader = CurrentFile.loader
4646
for (const locale of Global.visibleLocales) {
47-
const cov = loader.getCoverage(locale)
47+
const keys = loader.keys
48+
if (extraKeys?.length) {
49+
extraKeys.forEach((i) => {
50+
if (!keys.includes(i))
51+
keys.push(i)
52+
})
53+
}
54+
55+
const cov = loader.getCoverage(locale, keys)
4856
if (!cov)
4957
continue
5058

src/core/loaders/ComposedLoader.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Disposable } from 'vscode'
22
import _ from 'lodash'
3+
import { uniq } from '@antfu/utils'
34
import { PendingWrite } from '../types'
45
import { Translator } from '../Translator'
56
import { Config } from '../Config'
@@ -115,8 +116,12 @@ export class ComposedLoader extends Loader {
115116
if (!Array.isArray(pendings))
116117
pendings = [pendings]
117118

118-
if (Config.keepFulfilled && triggerFullfilled)
119-
pendings = [...await FulfillAllMissingKeys(false) || [], ...pendings]
119+
if (Config.keepFulfilled && triggerFullfilled) {
120+
pendings = [
121+
...await FulfillAllMissingKeys(false, uniq(pendings.map(i => i.keypath))) || [],
122+
...pendings,
123+
]
124+
}
120125

121126
pendings = pendings.filter(i => i)
122127

src/utils/flat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function flatten(data: any) {
3636
export function unflatten(data: any) {
3737
const output: any = {}
3838

39-
Object.keys(data)
39+
Object.keys(data || {})
4040
.sort((a, b) => b.length - a.length)
4141
.forEach((key) => {
4242
const original = key

0 commit comments

Comments
 (0)