glotfile 0.8.8 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3804,10 +3804,27 @@ function makeProvider(ai) {
3804
3804
  // src/server/ai/run.ts
3805
3805
  import { readFileSync as readFileSync7, existsSync as existsSync7 } from "fs";
3806
3806
  import { resolve as resolve5, extname as extname2 } from "path";
3807
+
3808
+ // src/server/cell-state.ts
3809
+ function cellState(entry, locale, sourceLocale) {
3810
+ const lv = entry.values[locale];
3811
+ if (locale === sourceLocale) {
3812
+ const has = entry.plural ? !!lv?.forms?.other?.trim() : !!lv?.value?.trim();
3813
+ return has ? "source" : "missing";
3814
+ }
3815
+ const present = entry.plural ? categoriesFor(locale).every((c) => (lv?.forms?.[c] ?? "") !== "") : !!lv?.value;
3816
+ if (!present) return "missing";
3817
+ const st = lv.state;
3818
+ return st === "reviewed" ? "reviewed" : st === "needs-review" ? "needs-review" : "machine";
3819
+ }
3820
+
3821
+ // src/server/ai/run.ts
3807
3822
  function selectRequests(state, opts) {
3808
3823
  const targets = (opts.locales ?? state.config.locales).filter((l) => l !== state.config.sourceLocale);
3809
3824
  const keyRe = opts.keyGlob ? globToRegExp(opts.keyGlob) : null;
3810
3825
  const keySet = opts.keys ? new Set(opts.keys) : null;
3826
+ const stateSet = opts.states ? new Set(opts.states) : null;
3827
+ const skip = (st) => stateSet ? !stateSet.has(st) : !!opts.onlyMissing && st !== "missing";
3811
3828
  const reqs = [];
3812
3829
  let id = 0;
3813
3830
  for (const key of Object.keys(state.keys).sort()) {
@@ -3821,9 +3838,7 @@ function selectRequests(state, opts) {
3821
3838
  const other = sourceForms?.other;
3822
3839
  if (!sourceForms || !other) continue;
3823
3840
  for (const locale of targets) {
3824
- const have = entry.values[locale]?.forms ?? {};
3825
- const complete = categoriesFor(locale).every((c) => (have[c] ?? "") !== "");
3826
- if (opts.onlyMissing && complete) continue;
3841
+ if (skip(cellState(entry, locale, state.config.sourceLocale))) continue;
3827
3842
  const glossary = relevantGlossary(other, locale, state.glossary);
3828
3843
  const literals = quotedLiterals(other);
3829
3844
  reqs.push({
@@ -3845,8 +3860,7 @@ function selectRequests(state, opts) {
3845
3860
  const source = sourceLv?.value;
3846
3861
  if (!source) continue;
3847
3862
  for (const locale of targets) {
3848
- const existing = entry.values[locale]?.value;
3849
- if (opts.onlyMissing && existing) continue;
3863
+ if (skip(cellState(entry, locale, state.config.sourceLocale))) continue;
3850
3864
  const glossary = relevantGlossary(source, locale, state.glossary);
3851
3865
  const literals = quotedLiterals(source);
3852
3866
  reqs.push({