@let-value/translate-extract 1.0.23 → 1.0.26

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.
@@ -312,7 +312,10 @@ const extractPluralForms = (name) => (match) => {
312
312
 
313
313
  //#endregion
314
314
  //#region src/plugins/core/queries/context.ts
315
- const ctxCall = callPattern("context", `(arguments (string (string_fragment) @msgctxt))`).replace(/@call/g, "@ctx").replace(/@func/g, "@ctxfn");
315
+ const ctxCall = callPattern("context", `[
316
+ (arguments (string (string_fragment) @msgctxt))
317
+ (template_string) @msgctxt
318
+ ]`).replace(/@call/g, "@ctx").replace(/@func/g, "@ctxfn");
316
319
  const contextMsgQuery = withComment({
317
320
  pattern: `(
318
321
  (call_expression
@@ -328,11 +331,20 @@ const contextMsgQuery = withComment({
328
331
  const result = extractMessage("context.message")(match);
329
332
  const contextNode = match.captures.find((c) => c.name === "msgctxt")?.node;
330
333
  if (!result || !result.translation || !contextNode) return result;
334
+ if (contextNode.type === "template_string") for (const child of contextNode.children) {
335
+ if (child.type !== "template_substitution") continue;
336
+ const expr = child.namedChildren[0];
337
+ if (!expr || expr.type !== "identifier") return {
338
+ node: contextNode,
339
+ error: "context() template expressions must be simple identifiers"
340
+ };
341
+ }
342
+ const contextText = contextNode.type === "template_string" ? contextNode.text.slice(1, -1) : contextNode.text;
331
343
  return {
332
344
  node: result.node,
333
345
  translation: {
334
346
  ...result.translation,
335
- context: contextNode.text
347
+ context: contextText
336
348
  }
337
349
  };
338
350
  }
@@ -451,6 +463,9 @@ const pluralQuery$1 = withComment({
451
463
  //#endregion
452
464
  //#region src/plugins/core/queries/index.ts
453
465
  const queries$1 = [
466
+ contextMsgQuery,
467
+ contextPluralQuery,
468
+ contextInvalidQuery,
454
469
  messageQuery$1,
455
470
  messageInvalidQuery,
456
471
  gettextQuery,
@@ -458,10 +473,7 @@ const queries$1 = [
458
473
  pluralQuery$1,
459
474
  ngettextQuery,
460
475
  pgettextQuery,
461
- npgettextQuery,
462
- contextMsgQuery,
463
- contextPluralQuery,
464
- contextInvalidQuery
476
+ npgettextQuery
465
477
  ];
466
478
 
467
479
  //#endregion
@@ -752,9 +764,9 @@ function merge(sources, existing, obsolete, locale, generatedAt) {
752
764
  let obsoleteTranslations = {};
753
765
  const nplurals = (0, plural_forms.getNPlurals)(locale);
754
766
  if (existing) {
755
- headers = existing.headers || {};
756
- translations = existing.translations || { "": {} };
757
- obsoleteTranslations = existing.obsolete || {};
767
+ headers = existing.headers ? structuredClone(existing.headers) : {};
768
+ translations = existing.translations ? structuredClone(existing.translations) : { "": {} };
769
+ obsoleteTranslations = existing.obsolete ? structuredClone(existing.obsolete) : {};
758
770
  for (const ctx of Object.keys(translations)) for (const id of Object.keys(translations[ctx])) {
759
771
  if (ctx === "" && id === "") continue;
760
772
  translations[ctx][id].obsolete = true;
package/dist/src/index.js CHANGED
@@ -302,7 +302,10 @@ const extractPluralForms = (name) => (match) => {
302
302
 
303
303
  //#endregion
304
304
  //#region src/plugins/core/queries/context.ts
305
- const ctxCall = callPattern("context", `(arguments (string (string_fragment) @msgctxt))`).replace(/@call/g, "@ctx").replace(/@func/g, "@ctxfn");
305
+ const ctxCall = callPattern("context", `[
306
+ (arguments (string (string_fragment) @msgctxt))
307
+ (template_string) @msgctxt
308
+ ]`).replace(/@call/g, "@ctx").replace(/@func/g, "@ctxfn");
306
309
  const contextMsgQuery = withComment({
307
310
  pattern: `(
308
311
  (call_expression
@@ -318,11 +321,20 @@ const contextMsgQuery = withComment({
318
321
  const result = extractMessage("context.message")(match);
319
322
  const contextNode = match.captures.find((c) => c.name === "msgctxt")?.node;
320
323
  if (!result || !result.translation || !contextNode) return result;
324
+ if (contextNode.type === "template_string") for (const child of contextNode.children) {
325
+ if (child.type !== "template_substitution") continue;
326
+ const expr = child.namedChildren[0];
327
+ if (!expr || expr.type !== "identifier") return {
328
+ node: contextNode,
329
+ error: "context() template expressions must be simple identifiers"
330
+ };
331
+ }
332
+ const contextText = contextNode.type === "template_string" ? contextNode.text.slice(1, -1) : contextNode.text;
321
333
  return {
322
334
  node: result.node,
323
335
  translation: {
324
336
  ...result.translation,
325
- context: contextNode.text
337
+ context: contextText
326
338
  }
327
339
  };
328
340
  }
@@ -441,6 +453,9 @@ const pluralQuery$1 = withComment({
441
453
  //#endregion
442
454
  //#region src/plugins/core/queries/index.ts
443
455
  const queries$1 = [
456
+ contextMsgQuery,
457
+ contextPluralQuery,
458
+ contextInvalidQuery,
444
459
  messageQuery$1,
445
460
  messageInvalidQuery,
446
461
  gettextQuery,
@@ -448,10 +463,7 @@ const queries$1 = [
448
463
  pluralQuery$1,
449
464
  ngettextQuery,
450
465
  pgettextQuery,
451
- npgettextQuery,
452
- contextMsgQuery,
453
- contextPluralQuery,
454
- contextInvalidQuery
466
+ npgettextQuery
455
467
  ];
456
468
 
457
469
  //#endregion
@@ -742,9 +754,9 @@ function merge(sources, existing, obsolete, locale, generatedAt) {
742
754
  let obsoleteTranslations = {};
743
755
  const nplurals = getNPlurals(locale);
744
756
  if (existing) {
745
- headers = existing.headers || {};
746
- translations = existing.translations || { "": {} };
747
- obsoleteTranslations = existing.obsolete || {};
757
+ headers = existing.headers ? structuredClone(existing.headers) : {};
758
+ translations = existing.translations ? structuredClone(existing.translations) : { "": {} };
759
+ obsoleteTranslations = existing.obsolete ? structuredClone(existing.obsolete) : {};
748
760
  for (const ctx of Object.keys(translations)) for (const id of Object.keys(translations[ctx])) {
749
761
  if (ctx === "" && id === "") continue;
750
762
  translations[ctx][id].obsolete = true;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["namespace","path","path","importQuery: ImportQuerySpec","current: Parser.SyntaxNode | null","messageQuery: QuerySpec","allowed","messageInvalidQuery: QuerySpec","ids: string[]","strs: string[]","subMatch: Parser.QueryMatch","translation: Translation","contextMsgQuery: QuerySpec","msgCall","contextPluralQuery: QuerySpec","contextInvalidQuery: QuerySpec","gettextQuery: QuerySpec","gettextInvalidQuery: QuerySpec","msgCall","plainMsg","msgArg","ngettextQuery: QuerySpec","msgCall","npgettextQuery: QuerySpec","pgettextQuery: QuerySpec","pluralQuery: QuerySpec","queries: QuerySpec[]","messageQuery","pluralQuery","path","parseSource","context: Context","translations: Translation[]","warnings: Warning[]","imports: string[]","queries","fs","resolved: string[]","filter","namespace","path","parseSource","translations: GetTextTranslationRecord","value","normalizedHeaders: Record<string, string>","headers: Record<string, string>","translations: GetTextTranslationRecord","obsoleteTranslations: GetTextTranslationRecord","collected: GetTextTranslationRecord","translations","existing","path","defaultDestination: DestinationFn","defaultExclude: Exclude[]","parts: Part[]","text","strings: string[]","values: string[]","messageQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","childValue: Parser.SyntaxNode | undefined","error: string | undefined","translation: Translation","forms: string[]","pluralQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","formsNode: Parser.SyntaxNode | null | undefined","translation: Translation","queries: QuerySpec[]","context: Context","path","translations: Translation[]","warnings: Warning[]","path"],"sources":["../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/comment.ts","../../src/plugins/core/queries/import.ts","../../src/plugins/core/queries/utils.ts","../../src/plugins/core/queries/message.ts","../../src/plugins/core/queries/plural-utils.ts","../../src/plugins/core/queries/context.ts","../../src/plugins/core/queries/gettext.ts","../../src/plugins/core/queries/ngettext.ts","../../src/plugins/core/queries/npgettext.ts","../../src/plugins/core/queries/pgettext.ts","../../src/plugins/core/queries/plural.ts","../../src/plugins/core/queries/index.ts","../../src/plugins/core/parse.ts","../../src/plugins/core/resolve.ts","../../src/plugins/core/core.ts","../../src/plugins/po/collect.ts","../../src/plugins/po/hasChanges.ts","../../src/plugins/po/merge.ts","../../src/plugins/po/po.ts","../../src/configuration.ts","../../src/plugins/react/queries/utils.ts","../../src/plugins/react/queries/message.ts","../../src/plugins/react/queries/plural.ts","../../src/plugins/react/queries/index.ts","../../src/plugins/react/parse.ts","../../src/plugins/react/react.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\n\nconst namespace = \"cleanup\";\n\nexport function cleanup(): Plugin {\n return {\n name: \"cleanup\",\n setup(build) {\n build.context.logger?.debug(\"cleanup plugin initialized\");\n const processed = new Set<string>();\n const generated = new Set<string>();\n const dirs = new Set<string>();\n let dispatched = false;\n\n build.onResolve({ namespace, filter: /.*/ }, ({ path }) => {\n generated.add(path);\n dirs.add(dirname(path));\n\n Promise.all([build.defer(\"source\"), build.defer(\"translate\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of dirs.values()) {\n build.process({ entrypoint: path, path, namespace, data: undefined });\n }\n });\n\n return undefined;\n });\n\n build.onProcess({ namespace, filter: /.*/ }, async ({ path }) => {\n if (processed.has(path)) {\n return undefined;\n }\n processed.add(path);\n const files = await fs.readdir(path).catch(() => []);\n for (const f of files.filter((p) => p.endsWith(\".po\"))) {\n const full = join(path, f);\n const contents = await fs.readFile(full).catch(() => undefined);\n if (!contents) {\n continue;\n }\n const parsed = gettextParser.po.parse(contents);\n const hasTranslations = Object.entries(parsed.translations || {}).some(([ctx, msgs]) =>\n Object.keys(msgs).some((id) => !(ctx === \"\" && id === \"\")),\n );\n if (!hasTranslations && generated.has(full)) {\n await fs.unlink(full);\n }\n if (hasTranslations && !generated.has(full)) {\n build.context.logger?.warn({ path: full }, \"stray translation file\");\n }\n }\n return undefined;\n });\n },\n };\n}\n","import { relative } from \"node:path\";\nimport type Parser from \"tree-sitter\";\n\nimport type { Context, QuerySpec } from \"./types.ts\";\n\nexport function getReference(node: Parser.SyntaxNode, { path }: Context) {\n const line = node.startPosition.row + 1;\n const rel = relative(process.cwd(), path).replace(/\\\\+/g, \"/\");\n return `${rel}:${line}`;\n}\n\nfunction getComment(node: Parser.SyntaxNode): string {\n const text = node.text;\n if (text.startsWith(\"/*\")) {\n return text\n .slice(2, -2)\n .replace(/^\\s*\\*?\\s*/gm, \"\")\n .trim();\n }\n return text.replace(/^\\/\\/\\s?/, \"\").trim();\n}\n\nexport const withComment = (query: QuerySpec): QuerySpec => ({\n pattern: `(\n\t((comment) @comment)?\n .\n\t(_ ${query.pattern})\n)`,\n extract(match) {\n const result = query.extract(match);\n if (!result?.translation) {\n return result;\n }\n\n const comment = match.captures.find((c) => c.name === \"comment\")?.node;\n if (!comment) {\n return result;\n }\n\n if (comment) {\n result.translation.comments = {\n ...result.translation.comments,\n extracted: getComment(comment),\n };\n }\n\n return result;\n },\n});\n","import type Parser from \"tree-sitter\";\nimport type { ImportQuerySpec } from \"./types.ts\";\n\nexport const importQuery: ImportQuerySpec = {\n pattern: `\n [\n (import_statement\n source: (string (string_fragment) @import))\n (export_statement\n source: (string (string_fragment) @import))\n (call_expression\n function: (identifier) @func\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @func \"require\"))\n (call_expression\n function: (member_expression\n object: (identifier) @obj\n property: (property_identifier) @method)\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @obj \"require\")\n (#eq? @method \"resolve\"))\n (call_expression\n function: (import)\n arguments: (arguments (string (string_fragment) @import)))\n ]\n `,\n extract(match: Parser.QueryMatch): string | undefined {\n const node = match.captures.find((c) => c.name === \"import\")?.node;\n return node?.text;\n },\n};\n","import type Parser from \"tree-sitter\";\n\nexport const callPattern = (fnName: string, args: string, allowMember = true): string => `(\n (call_expression\n function: ${\n allowMember\n ? `[\n (identifier) @func\n (member_expression property: (property_identifier) @func)\n ]`\n : `(identifier) @func`\n }\n arguments: ${args}\n ) @call\n (#eq? @func \"${fnName}\")\n)`;\n\nexport function isDescendant(node: Parser.SyntaxNode, ancestor: Parser.SyntaxNode): boolean {\n let current: Parser.SyntaxNode | null = node;\n while (current) {\n if (current.id === ancestor.id) return true;\n current = current.parent;\n }\n return false;\n}\n","import type Parser from \"tree-sitter\";\nimport { withComment } from \"./comment.ts\";\nimport type { MessageMatch, QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst notInPlural = (query: QuerySpec): QuerySpec => ({\n pattern: query.pattern,\n extract(match) {\n const result = query.extract(match);\n if (!result?.node) {\n return result;\n }\n\n let parent = result.node.parent;\n\n if (parent && parent.type === \"arguments\") {\n parent = parent.parent;\n }\n\n if (parent && parent.type === \"call_expression\") {\n const fn = parent.childForFieldName(\"function\");\n if (fn) {\n if (\n (fn.type === \"identifier\" &&\n (fn.text === \"plural\" ||\n fn.text === \"ngettext\" ||\n fn.text === \"pgettext\" ||\n fn.text === \"npgettext\")) ||\n (fn.type === \"member_expression\" &&\n [\"plural\", \"ngettext\", \"pgettext\", \"npgettext\"].includes(\n fn.childForFieldName(\"property\")?.text ?? \"\",\n ))\n ) {\n return undefined;\n }\n }\n }\n\n return result;\n },\n});\n\nexport const messageArg = `[\n (string (string_fragment) @msgid)\n (object\n (_)*\n (pair\n key: (property_identifier) @id_key\n value: (string (string_fragment) @id)\n (#eq? @id_key \"id\")\n )?\n (_)*\n (pair\n key: (property_identifier) @msg_key\n value: (string (string_fragment) @message)\n (#eq? @msg_key \"message\")\n )?\n (_)*\n )\n (template_string) @tpl\n]`;\n\nexport const messageArgs = `[ (arguments ${messageArg}) (template_string) @tpl ]`;\n\nexport const extractMessage =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) {\n return undefined;\n }\n\n const msgid = match.captures.find((c) => c.name === \"msgid\")?.node.text;\n if (msgid) {\n return {\n node,\n translation: {\n id: msgid,\n message: [msgid],\n },\n };\n }\n\n const tpl = match.captures.find((c) => c.name === \"tpl\")?.node;\n if (tpl) {\n for (const child of tpl.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node,\n error: `${name}() template expressions must be simple identifiers`,\n };\n }\n }\n\n const text = tpl.text.slice(1, -1);\n\n return {\n node,\n translation: { id: text, message: [text] },\n };\n }\n\n const id = match.captures.find((c) => c.name === \"id\")?.node.text;\n const message = match.captures.find((c) => c.name === \"message\")?.node.text;\n const msgId = id ?? message;\n if (!msgId) {\n return undefined;\n }\n\n const msgstr = message ?? id ?? \"\";\n\n return {\n node,\n translation: {\n id: msgId,\n message: [msgstr],\n },\n };\n };\n\nexport const messageQuery: QuerySpec = notInPlural(\n withComment({\n pattern: callPattern(\"message\", messageArgs),\n extract: extractMessage(\"message\"),\n }),\n);\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\"]);\n\nexport const messageInvalidQuery: QuerySpec = notInPlural({\n pattern: callPattern(\"message\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"message() argument must be a string literal, object literal, or template literal\",\n };\n },\n});\n","import type Parser from \"tree-sitter\";\nimport { extractMessage } from \"./message.ts\";\nimport type { MessageMatch, Translation } from \"./types.ts\";\nimport { isDescendant } from \"./utils.ts\";\n\nexport const extractPluralForms =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const n = match.captures.find((c) => c.name === \"n\")?.node;\n if (!call || !n || n.nextNamedSibling) {\n return undefined;\n }\n\n const msgctxt = match.captures.find((c) => c.name === \"msgctxt\")?.node?.text;\n const msgNodes = match.captures.filter((c) => c.name === \"msg\").map((c) => c.node);\n\n const ids: string[] = [];\n const strs: string[] = [];\n\n for (const node of msgNodes) {\n const relevant = match.captures.filter(\n (c) => [\"msgid\", \"id\", \"message\", \"tpl\"].includes(c.name) && isDescendant(c.node, node),\n );\n\n const subMatch: Parser.QueryMatch = {\n pattern: 0,\n captures: [{ name: \"call\", node }, ...relevant],\n };\n\n const result = extractMessage(name)(subMatch);\n if (!result) continue;\n if (result.error) {\n return { node: call, error: result.error };\n }\n if (result.translation) {\n ids.push(result.translation.id);\n strs.push(result.translation.message[0] ?? \"\");\n }\n }\n\n if (ids.length === 0) {\n return undefined;\n }\n\n const translation: Translation = {\n id: ids[0],\n plural: ids[1],\n message: strs,\n };\n if (msgctxt) translation.context = msgctxt;\n\n return { node: call, translation };\n };\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst ctxCall = callPattern(\"context\", `(arguments (string (string_fragment) @msgctxt))`)\n .replace(/@call/g, \"@ctx\")\n .replace(/@func/g, \"@ctxfn\");\n\nexport const contextMsgQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: ${messageArgs}\n ) @call\n (#eq? @func \"message\")\n)`,\n extract(match) {\n const result = extractMessage(\"context.message\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !result.translation || !contextNode) {\n return result;\n }\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextNode.text,\n },\n };\n },\n});\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const contextPluralQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: (arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))\n ) @call\n (#eq? @func \"plural\")\n)`,\n extract: extractPluralForms(\"context.plural\"),\n});\n\nexport const contextInvalidQuery: QuerySpec = withComment({\n pattern: ctxCall,\n extract(match) {\n const call = match.captures.find((c) => c.name === \"ctx\")?.node;\n if (!call) {\n return undefined;\n }\n\n const parent = call.parent;\n if (parent && parent.type === \"member_expression\" && parent.childForFieldName(\"object\")?.id === call.id) {\n const property = parent.childForFieldName(\"property\")?.text;\n const grandparent = parent.parent;\n if (\n grandparent &&\n grandparent.type === \"call_expression\" &&\n grandparent.childForFieldName(\"function\")?.id === parent.id &&\n (property === \"message\" || property === \"plural\")\n ) {\n return undefined;\n }\n }\n\n return {\n node: call,\n error: \"context() must be used with message() or plural() in the same expression\",\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const gettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"gettext\", messageArgs),\n extract: extractMessage(\"gettext\"),\n});\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\", \"identifier\", \"call_expression\"]);\n\nexport const gettextInvalidQuery: QuerySpec = {\n pattern: callPattern(\"gettext\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"gettext() argument must be a string literal, object literal, or template literal\",\n };\n },\n};\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const ngettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"ngettext\", `(arguments ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`),\n extract: extractPluralForms(\"ngettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const npgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"npgettext\",\n `(arguments (string (string_fragment) @msgctxt) \",\" ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`,\n ),\n extract: extractPluralForms(\"npgettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArg } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const pgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"pgettext\", `(arguments (string (string_fragment) @msgctxt) \",\" ${messageArg})`),\n extract(match) {\n const result = extractMessage(\"pgettext\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !contextNode || !result.translation) {\n return result;\n }\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextNode.text,\n },\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"plural\",\n `(arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))`,\n false,\n ),\n extract: extractPluralForms(\"plural\"),\n});\n","import { contextInvalidQuery, contextMsgQuery, contextPluralQuery } from \"./context.ts\";\nimport { gettextInvalidQuery, gettextQuery } from \"./gettext.ts\";\nimport { messageInvalidQuery, messageQuery } from \"./message.ts\";\nimport { ngettextQuery } from \"./ngettext.ts\";\nimport { npgettextQuery } from \"./npgettext.ts\";\nimport { pgettextQuery } from \"./pgettext.ts\";\nimport { pluralQuery } from \"./plural.ts\";\nimport type { QuerySpec } from \"./types.ts\";\n\nexport type { MessageMatch, QuerySpec } from \"./types.ts\";\n\nexport const queries: QuerySpec[] = [\n messageQuery,\n messageInvalidQuery,\n gettextQuery,\n gettextInvalidQuery,\n pluralQuery,\n ngettextQuery,\n pgettextQuery,\n npgettextQuery,\n contextMsgQuery,\n contextPluralQuery,\n contextInvalidQuery,\n];\n","import fs from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\n\nimport Parser from \"tree-sitter\";\nimport JavaScript from \"tree-sitter-javascript\";\nimport TS from \"tree-sitter-typescript\";\n\nimport { getReference } from \"./queries/comment.ts\";\nimport { importQuery } from \"./queries/import.ts\";\nimport { queries } from \"./queries/index.ts\";\nimport type { Context, Translation, Warning } from \"./queries/types.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n imports: string[];\n warnings: Warning[];\n}\n\nfunction getLanguage(ext: string) {\n switch (ext) {\n case \".ts\":\n return TS.typescript;\n case \".tsx\":\n return TS.tsx;\n default:\n return JavaScript;\n }\n}\n\nconst parserCache = new Map<string, { parser: Parser; language: Parser.Language }>();\nconst queryCache = new WeakMap<Parser.Language, Map<string, Parser.Query>>();\n\nfunction getCachedParser(ext: string) {\n let cached = parserCache.get(ext);\n if (!cached) {\n const parser = new Parser();\n const language = getLanguage(ext) as Parser.Language;\n parser.setLanguage(language);\n cached = { parser, language };\n parserCache.set(ext, cached);\n }\n return cached;\n}\n\nfunction getCachedQuery(language: Parser.Language, pattern: string) {\n let cache = queryCache.get(language);\n if (!cache) {\n cache = new Map();\n queryCache.set(language, cache);\n }\n\n let query = cache.get(pattern);\n if (!query) {\n query = new Parser.Query(language, pattern);\n cache.set(pattern, query);\n }\n\n return query;\n}\n\nexport function getParser(path: string) {\n const ext = extname(path);\n return getCachedParser(ext);\n}\n\nexport function getQuery(language: Parser.Language, pattern: string) {\n return getCachedQuery(language, pattern);\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = {\n path,\n };\n\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const imports: string[] = [];\n\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getCachedQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) {\n continue;\n }\n\n const { node, translation, error } = message;\n if (seen.has(node.id)) {\n continue;\n }\n seen.add(node.id);\n const reference = getReference(node, context);\n\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n const importTreeQuery = getCachedQuery(language, importQuery.pattern);\n for (const match of importTreeQuery.matches(tree.rootNode)) {\n const imp = importQuery.extract(match);\n if (imp) {\n imports.push(imp);\n }\n }\n\n return { translations, imports, warnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ResolverFactory } from \"oxc-resolver\";\n\nfunction findTsconfig(dir: string): string | undefined {\n let current = dir;\n while (true) {\n const config = path.join(current, \"tsconfig.json\");\n if (fs.existsSync(config)) {\n return config;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n current = parent;\n }\n}\n\nconst resolverCache = new Map<string, ResolverFactory>();\n\nfunction getResolver(dir: string) {\n const tsconfig = findTsconfig(dir);\n const key = tsconfig ?? \"__default__\";\n let resolver = resolverCache.get(key);\n if (!resolver) {\n resolver = new ResolverFactory({\n extensions: [\".ts\", \".tsx\", \".js\", \".jsx\", \".mjs\", \".cjs\", \".json\"],\n conditionNames: [\"import\", \"require\", \"node\"],\n ...(tsconfig ? { tsconfig: { configFile: tsconfig } } : {}),\n });\n resolverCache.set(key, resolver);\n }\n return resolver;\n}\n\nfunction resolveFromDir(dir: string, spec: string): string | undefined {\n const resolver = getResolver(dir);\n const res = resolver.sync(dir, spec) as { path?: string };\n return res.path;\n}\n\nexport function resolveImport(file: string, spec: string): string | undefined {\n const dir = path.dirname(path.resolve(file));\n return resolveFromDir(dir, spec);\n}\n\nexport function resolveImports(file: string, imports: string[]): string[] {\n const dir = path.dirname(path.resolve(file));\n const resolver = getResolver(dir);\n const resolved: string[] = [];\n for (const spec of imports) {\n const res = resolver.sync(dir, spec) as { path?: string };\n if (res.path) {\n resolved.push(res.path);\n }\n }\n return resolved;\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport { parseSource } from \"./parse.ts\";\nimport type { Translation } from \"./queries/types.ts\";\nimport { resolveImports } from \"./resolve.ts\";\n\nconst filter = /\\.([cm]?tsx?|jsx?)$/;\nconst namespace = \"source\";\n\nexport function core(): Plugin<string, Translation[]> {\n return {\n name: \"core\",\n setup(build) {\n build.context.logger?.debug(\"core plugin initialized\");\n build.onResolve({ filter, namespace }, ({ entrypoint, path }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n\n build.onLoad({ filter, namespace }, async ({ entrypoint, path }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter, namespace }, ({ entrypoint, path, data }) => {\n const { translations, imports, warnings } = parseSource(data, path);\n\n if (build.context.config.walk) {\n const paths = resolveImports(path, imports);\n for (const path of paths) {\n build.resolve({ entrypoint, path, namespace });\n }\n }\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n\n return undefined;\n });\n },\n };\n}\n","import type { GetTextTranslationRecord } from \"gettext-parser\";\nimport { getNPlurals } from \"plural-forms\";\n\nimport type { Translation } from \"../core/queries/types.ts\";\n\nexport function collect(source: Translation[], locale?: string): GetTextTranslationRecord {\n const translations: GetTextTranslationRecord = { \"\": {} };\n const nplurals = locale ? getNPlurals(locale) : undefined;\n\n for (const { context, id, message, comments, obsolete, plural } of source) {\n const ctx = context || \"\";\n if (!translations[ctx]) {\n translations[ctx] = {};\n }\n\n const length = plural ? (nplurals ?? message.length) : 1;\n\n const existing = translations[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (comments?.reference) {\n comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n\n const msgstr = existing?.msgstr ? existing.msgstr.slice(0, length) : Array.from({ length }, () => \"\");\n while (msgstr.length < length) msgstr.push(\"\");\n\n translations[ctx][id] = {\n msgctxt: context || undefined,\n msgid: id,\n msgid_plural: plural,\n msgstr,\n comments: {\n ...existing?.comments,\n ...comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n obsolete: existing?.obsolete ?? obsolete,\n };\n }\n\n return translations;\n}\n","import { isDeepStrictEqual } from \"node:util\";\nimport type { GetTextTranslations } from \"gettext-parser\";\nimport * as gettextParser from \"gettext-parser\";\n\nconst IGNORED_HEADER_KEYS = new Set([\"pot-creation-date\", \"po-revision-date\"]);\nconst IGNORED_HEADER_LINE_PREFIXES = [\"pot-creation-date:\", \"po-revision-date:\"];\n\nfunction normalizeHeaderString(value: string): string {\n const lines = value.split(\"\\n\");\n const hadTrailingNewline = value.endsWith(\"\\n\");\n\n const filtered = lines\n .filter((line) => {\n const trimmed = line.trimStart().toLowerCase();\n return !IGNORED_HEADER_LINE_PREFIXES.some((prefix) => trimmed.startsWith(prefix));\n })\n .map((line) => {\n const separatorIndex = line.indexOf(\":\");\n if (separatorIndex === -1) {\n return line;\n }\n\n const key = line.slice(0, separatorIndex).trim().toLowerCase();\n const value = line.slice(separatorIndex + 1);\n return `${key}:${value}`;\n });\n\n if (hadTrailingNewline && filtered[filtered.length - 1] !== \"\") {\n filtered.push(\"\");\n }\n\n return filtered.join(\"\\n\");\n}\n\nfunction normalize(translations: GetTextTranslations): GetTextTranslations {\n const compiled = gettextParser.po.compile(translations);\n const parsed = gettextParser.po.parse(compiled);\n\n if (parsed.headers) {\n const normalizedHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(parsed.headers)) {\n if (!IGNORED_HEADER_KEYS.has(key.toLowerCase())) {\n normalizedHeaders[key.toLowerCase()] = value as string;\n }\n }\n parsed.headers = normalizedHeaders;\n }\n\n const headerMessage = parsed.translations?.[\"\"]?.[\"\"];\n if (headerMessage?.msgstr) {\n headerMessage.msgstr = headerMessage.msgstr.map((item) => normalizeHeaderString(item));\n }\n\n return parsed;\n}\n\nexport function hasChanges(left: GetTextTranslations, right?: GetTextTranslations): boolean {\n if (!right) {\n return true;\n }\n\n const normalizedLeft = normalize(left);\n const normalizedRight = normalize(right);\n\n return !isDeepStrictEqual(normalizedLeft, normalizedRight);\n}\n","import type { GetTextTranslationRecord, GetTextTranslations } from \"gettext-parser\";\nimport { getFormula, getNPlurals } from \"plural-forms\";\n\nimport type { ObsoleteStrategy } from \"../../configuration.ts\";\n\nexport interface Collected {\n translations: GetTextTranslationRecord;\n}\n\nexport function formatDate(date: Date): string {\n const pad = (n: number) => n.toString().padStart(2, \"0\");\n const year = date.getFullYear();\n const month = pad(date.getMonth() + 1);\n const day = pad(date.getDate());\n const hours = pad(date.getHours());\n const minutes = pad(date.getMinutes());\n const tzo = -date.getTimezoneOffset();\n const sign = tzo >= 0 ? \"+\" : \"-\";\n const offsetHours = pad(Math.floor(Math.abs(tzo) / 60));\n const offsetMinutes = pad(Math.abs(tzo) % 60);\n return `${year}-${month}-${day} ${hours}:${minutes}${sign}${offsetHours}${offsetMinutes}`;\n}\n\nexport function merge(\n sources: Collected[],\n existing: GetTextTranslations | undefined,\n obsolete: ObsoleteStrategy,\n locale: string,\n generatedAt: Date,\n): GetTextTranslations {\n let headers: Record<string, string> = {};\n let translations: GetTextTranslationRecord = { \"\": {} };\n let obsoleteTranslations: GetTextTranslationRecord = {};\n const nplurals = getNPlurals(locale);\n\n if (existing) {\n headers = existing.headers || {};\n translations = existing.translations || { \"\": {} };\n obsoleteTranslations = existing.obsolete || {};\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") continue;\n translations[ctx][id].obsolete = true;\n }\n }\n }\n\n const collected: GetTextTranslationRecord = { \"\": {} };\n for (const { translations } of sources) {\n for (const [ctx, msgs] of Object.entries(translations)) {\n if (!collected[ctx]) collected[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existing = collected[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (entry.comments?.reference) {\n entry.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n collected[ctx][id] = {\n ...existing,\n ...entry,\n comments: {\n ...existing?.comments,\n ...entry.comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n };\n }\n }\n }\n\n for (const [ctx, msgs] of Object.entries(collected)) {\n if (!translations[ctx]) translations[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existingEntry = translations[ctx][id] ?? obsoleteTranslations[ctx]?.[id];\n if (existingEntry) {\n entry.msgstr = existingEntry.msgstr;\n entry.comments = {\n ...entry.comments,\n translator: existingEntry.comments?.translator,\n };\n }\n delete entry.obsolete;\n entry.msgstr = entry.msgstr.slice(0, nplurals);\n while (entry.msgstr.length < nplurals) {\n entry.msgstr.push(\"\");\n }\n translations[ctx][id] = entry;\n if (obsoleteTranslations[ctx]) {\n delete obsoleteTranslations[ctx][id];\n }\n }\n }\n\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") {\n continue;\n }\n const entry = translations[ctx][id];\n if (entry.obsolete) {\n if (!obsoleteTranslations[ctx]) {\n obsoleteTranslations[ctx] = {};\n }\n obsoleteTranslations[ctx][id] = entry;\n delete translations[ctx][id];\n }\n }\n }\n\n headers = {\n ...headers,\n \"Content-Type\": headers[\"Content-Type\"] || \"text/plain; charset=UTF-8\",\n \"Plural-Forms\": `nplurals=${nplurals}; plural=${getFormula(locale)};`,\n language: locale,\n \"MIME-Version\": \"1.0\",\n \"Content-Transfer-Encoding\": \"8bit\",\n \"POT-Creation-Date\": formatDate(generatedAt),\n \"x-generator\": \"@let-value/translate-extract\",\n };\n\n return {\n charset: \"utf-8\",\n headers,\n translations,\n ...(obsolete === \"mark\" && Object.keys(obsoleteTranslations).length ? { obsolete: obsoleteTranslations } : {}),\n };\n}\n","import fs from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { collect } from \"./collect.ts\";\nimport { hasChanges } from \"./hasChanges.ts\";\nimport { merge } from \"./merge.ts\";\n\nconst namespace = \"translate\";\n\nexport function po(): Plugin {\n return {\n name: \"po\",\n setup(build) {\n build.context.logger?.debug(\"po plugin initialized\");\n const collections = new Map<\n string,\n {\n locale: string;\n translations: Translation[];\n }\n >();\n let dispatched = false;\n\n build.onResolve({ filter: /.*/, namespace }, async ({ entrypoint, path, data }) => {\n if (!data || !Array.isArray(data)) {\n return undefined;\n }\n\n for (const locale of build.context.config.locales) {\n const destination = build.context.config.destination({ entrypoint, locale, path });\n if (!collections.has(destination)) {\n collections.set(destination, { locale, translations: [] });\n }\n\n collections.get(destination)?.translations.push(...data);\n }\n\n Promise.all([build.defer(\"source\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of collections.keys()) {\n build.load({ entrypoint, path, namespace });\n }\n });\n\n return undefined;\n });\n\n build.onLoad({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path }) => {\n const contents = await fs.readFile(path).catch(() => undefined);\n const data = contents ? gettextParser.po.parse(contents) : undefined;\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path, data }) => {\n const collected = collections.get(path);\n if (!collected) {\n build.context.logger?.warn({ path }, \"no translations collected for this path\");\n return undefined;\n }\n\n const { locale, translations } = collected;\n\n const record = collect(translations, locale);\n\n const out = merge(\n [{ translations: record }],\n data as never,\n build.context.config.obsolete,\n locale,\n build.context.generatedAt,\n );\n\n if (hasChanges(out, data as never)) {\n await fs.mkdir(dirname(path), { recursive: true });\n await fs.writeFile(path, gettextParser.po.compile(out));\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"cleanup\",\n data: translations,\n });\n });\n },\n };\n}\n","import { basename, dirname, extname, join } from \"node:path\";\nimport type { PluralFormsLocale } from \"@let-value/translate\";\nimport type { LogLevel } from \"./logger.ts\";\n\nimport type { Plugin } from \"./plugin.ts\";\nimport { cleanup } from \"./plugins/cleanup/cleanup.ts\";\nimport { core } from \"./plugins/core/core.ts\";\nimport { po } from \"./plugins/po/po.ts\";\n\nexport type DestinationFn = (args: { locale: string; entrypoint: string; path: string }) => string;\nexport type ExcludeFn = (args: { entrypoint: string; path: string }) => boolean;\nexport type Exclude = RegExp | ExcludeFn;\n\nconst defaultPlugins = { core, po, cleanup };\ntype DefaultPlugins = typeof defaultPlugins;\n\n/**\n * Strategy to handle obsolete translations in existing locale files:\n * - \"mark\": keep obsolete entries in the locale file but mark them as obsolete\n * - \"remove\": remove obsolete entries from the locale file\n */\nexport type ObsoleteStrategy = \"mark\" | \"remove\";\n\nexport interface EntrypointConfig {\n entrypoint: string;\n destination?: DestinationFn;\n obsolete?: ObsoleteStrategy;\n walk?: boolean;\n exclude?: Exclude | Exclude[];\n}\n\nexport interface UserConfig {\n /**\n * Default locale to use as the base for extraction\n * @default \"en\"\n * @see {@link PluralFormsLocale} for available locales\n */\n defaultLocale?: PluralFormsLocale;\n /**\n * Array of locales to extract translations for\n * @default [defaultLocale]\n * @see {@link PluralFormsLocale} for available locales\n */\n locales?: PluralFormsLocale[];\n /**\n * Array of plugins to use or a function to override the default plugins\n * @default DefaultPlugins\n * @see {@link DefaultPlugins} for available plugins\n */\n plugins?: Plugin[] | ((defaultPlugins: DefaultPlugins) => Plugin[]);\n /**\n * One or more entrypoints to extract translations from, could be:\n * - file path, will be treated as a single file entrypoint\n * - glob pattern will be expanded to match files, each treated as a separate entrypoint\n * - configuration object with options for the entrypoint\n * @see {@link EntrypointConfig} for configuration options\n */\n entrypoints: string | EntrypointConfig | Array<string | EntrypointConfig>;\n /**\n * Function to determine the destination path for each extracted locale file\n * @default `./translations/entrypoint.locale.po`\n * @see {@link DestinationFn}\n * @see Can be overridden per entrypoint via `destination` in {@link EntrypointConfig\n */\n destination?: DestinationFn;\n /**\n * Strategy to handle obsolete translations in existing locale files\n * @default \"mark\"\n * @see {@link ObsoleteStrategy} for available strategies\n * @see Can be overridden per entrypoint via `obsolete` in {@link EntrypointConfig\n */\n obsolete?: ObsoleteStrategy;\n /**\n * Whether to recursively walk dependencies of the entrypoints\n * @default true\n * @see Can be overridden per entrypoint via `walk` in {@link EntrypointConfig}.\n */\n walk?: boolean;\n /**\n * Paths or patterns to exclude from extraction, applied to all entrypoints\n * @default [/node_modules/, /dist/, /build/]\n * @see Can be overridden per entrypoint via `exclude` in {@link EntrypointConfig}.\n */\n exclude?: Exclude | Exclude[];\n /**\n * Log level for the extraction process\n * @default \"info\"\n */\n logLevel?: LogLevel;\n}\n\nexport interface ResolvedEntrypoint extends Omit<EntrypointConfig, \"exclude\"> {\n exclude?: Exclude[];\n}\n\nexport interface ResolvedConfig {\n plugins: Plugin[];\n entrypoints: ResolvedEntrypoint[];\n defaultLocale: string;\n locales: string[];\n destination: DestinationFn;\n obsolete: ObsoleteStrategy;\n walk: boolean;\n logLevel: LogLevel;\n exclude: Exclude[];\n}\n\nconst defaultDestination: DestinationFn = ({ entrypoint, locale }) =>\n join(dirname(entrypoint), \"translations\", `${basename(entrypoint, extname(entrypoint))}.${locale}.po`);\n\nconst defaultExclude: Exclude[] = [\n /(?:^|[\\\\/])node_modules(?:[\\\\/]|$)/,\n /(?:^|[\\\\/])dist(?:[\\\\/]|$)/,\n /(?:^|[\\\\/])build(?:[\\\\/]|$)/,\n];\n\nfunction normalizeExclude(exclude?: Exclude | Exclude[]): Exclude[] {\n if (!exclude) return [];\n return Array.isArray(exclude) ? exclude : [exclude];\n}\n\nfunction resolveEntrypoint(ep: string | EntrypointConfig): ResolvedEntrypoint {\n if (typeof ep === \"string\") {\n return { entrypoint: ep };\n }\n const { entrypoint, destination, obsolete, walk, exclude } = ep;\n return { entrypoint, destination, obsolete, walk, exclude: exclude ? normalizeExclude(exclude) : undefined };\n}\n\nfunction resolvePlugins(user?: UserConfig[\"plugins\"]): Plugin[] {\n if (typeof user === \"function\") {\n return user(defaultPlugins);\n }\n if (Array.isArray(user)) {\n return [...Object.values(defaultPlugins).map((plugin) => plugin()), ...user];\n }\n return Object.values(defaultPlugins).map((plugin) => plugin());\n}\n\n/**\n * Type helper to make it easier to use translate.config.ts\n * @param config - {@link UserConfig}.\n */\nexport function defineConfig(config: UserConfig): ResolvedConfig {\n const defaultLocale = config.defaultLocale ?? \"en\";\n\n const plugins = resolvePlugins(config.plugins);\n\n const raw = Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints];\n const entrypoints = raw.map(resolveEntrypoint);\n\n return {\n plugins,\n entrypoints,\n defaultLocale,\n locales: config.locales ?? [defaultLocale],\n destination: config.destination ?? defaultDestination,\n obsolete: config.obsolete ?? \"mark\",\n walk: config.walk ?? true,\n logLevel: config.logLevel ?? \"info\",\n exclude: config.exclude ? normalizeExclude(config.exclude) : defaultExclude,\n };\n}\n","import type Parser from \"tree-sitter\";\n\nexport function buildTemplate(node: Parser.SyntaxNode): { text: string; error?: string } {\n const source = node.tree.rootNode.text;\n const open = node.childForFieldName(\"open_tag\");\n const close = node.childForFieldName(\"close_tag\");\n const contentStart = open?.endIndex ?? node.startIndex;\n const contentEnd = close?.startIndex ?? node.endIndex;\n\n type Part = { kind: \"text\"; text: string; raw: boolean } | { kind: \"expr\"; value: string };\n\n const parts: Part[] = [];\n let segmentStart = contentStart;\n\n const pushRawText = (endIndex: number) => {\n if (endIndex <= segmentStart) {\n segmentStart = Math.max(segmentStart, endIndex);\n return;\n }\n const text = source.slice(segmentStart, endIndex);\n if (text) {\n parts.push({ kind: \"text\", text, raw: true });\n }\n segmentStart = endIndex;\n };\n\n const children = node.namedChildren.slice(1, -1);\n for (const child of children) {\n if (child.type === \"jsx_expression\") {\n pushRawText(child.startIndex);\n const expr = child.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n parts.push({ kind: \"expr\", value: expr.text });\n } else if (expr.type === \"string\") {\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else if (expr.type === \"template_string\") {\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n segmentStart = child.endIndex;\n } else if (child.type === \"string\") {\n pushRawText(child.startIndex);\n parts.push({ kind: \"text\", text: child.text.slice(1, -1), raw: false });\n segmentStart = child.endIndex;\n } else if (child.type === \"jsx_text\" || child.type === \"html_character_reference\" || child.isError) {\n } else {\n return { text: \"\", error: \"Unsupported JSX child\" };\n }\n }\n\n pushRawText(contentEnd);\n\n const firstRawIndex = parts.findIndex((part) => part.kind === \"text\" && part.raw);\n if (firstRawIndex === 0) {\n const part = parts[firstRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/^\\s+/, \"\");\n }\n\n let lastRawIndex = -1;\n for (let i = parts.length - 1; i >= 0; i--) {\n const part = parts[i];\n if (part.kind === \"text\" && part.raw) {\n lastRawIndex = i;\n break;\n }\n }\n if (lastRawIndex !== -1 && lastRawIndex === parts.length - 1) {\n const part = parts[lastRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/\\s+$/, \"\");\n }\n\n const strings: string[] = [\"\"];\n const values: string[] = [];\n for (const part of parts) {\n if (part.kind === \"text\") {\n if (part.text) {\n strings[strings.length - 1] += part.text;\n }\n } else {\n values.push(part.value);\n strings.push(\"\");\n }\n }\n\n let text = \"\";\n for (let i = 0; i < strings.length; i++) {\n text += strings[i];\n if (values[i]) {\n text += `\\${${values[i]}}`;\n }\n }\n return { text };\n}\n\nexport function buildAttrValue(node: Parser.SyntaxNode): { text: string; error?: string } {\n if (node.type === \"string\") {\n return { text: node.text.slice(1, -1) };\n }\n if (node.type === \"jsx_expression\") {\n const expr = node.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n return { text: `\\${${expr.text}}` };\n } else if (expr.type === \"string\") {\n return { text: expr.text.slice(1, -1) };\n } else if (expr.type === \"template_string\") {\n // Check if it's a simple template string with no substitutions\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n // Extract the text content from the template string\n const content = expr.text.slice(1, -1); // Remove backticks\n return { text: content };\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n }\n return { text: \"\", error: \"Unsupported JSX child\" };\n}\n","import type Parser from \"tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildAttrValue, buildTemplate } from \"./utils.ts\";\n\nexport const messageQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n (lexical_declaration \n (variable_declarator \n value: [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n ]\n )\n )\n ]\n (#eq? @name \"Message\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let childValue: Parser.SyntaxNode | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"children\" && value) {\n childValue = value;\n }\n }\n let text = \"\";\n let error: string | undefined;\n if (node.type === \"jsx_element\") {\n ({ text, error } = buildTemplate(node));\n } else if (childValue) {\n ({ text, error } = buildAttrValue(childValue));\n }\n if (error) {\n return { node, error };\n }\n if (!text) return undefined;\n const translation: Translation = {\n id: text,\n message: [text],\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type Parser from \"tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildTemplate } from \"./utils.ts\";\n\nfunction parseForms(node: Parser.SyntaxNode): { forms: string[]; error?: string } {\n const forms: string[] = [];\n if (node.type === \"jsx_expression\") {\n const arr = node.namedChildren[0];\n if (!arr || arr.type !== \"array\") {\n return { forms: [], error: \"Plural forms must be an array\" };\n }\n for (const el of arr.namedChildren) {\n if (el.type === \"jsx_element\" || el.type === \"jsx_fragment\") {\n const { text, error } = buildTemplate(el);\n if (error) return { forms: [], error };\n forms.push(text);\n } else if (el.type === \"string\") {\n forms.push(el.text.slice(1, -1));\n } else {\n return { forms: [], error: \"Unsupported plural form\" };\n }\n }\n }\n return { forms };\n}\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name))\n (jsx_self_closing_element name: (identifier) @name)\n ] @call\n (#eq? @name \"Plural\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let formsNode: Parser.SyntaxNode | null | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"forms\" && value) {\n formsNode = value;\n }\n }\n if (!formsNode) return undefined;\n const { forms, error } = parseForms(formsNode);\n if (error) {\n return { node, error };\n }\n if (forms.length === 0) return undefined;\n const translation: Translation = {\n id: forms[0],\n plural: forms[1],\n message: forms,\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type { QuerySpec } from \"../../core/queries/types.ts\";\nimport { messageQuery } from \"./message.ts\";\nimport { pluralQuery } from \"./plural.ts\";\n\nexport const queries: QuerySpec[] = [messageQuery, pluralQuery];\n","import fs from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getParser, getQuery } from \"../core/parse.ts\";\nimport { getReference } from \"../core/queries/comment.ts\";\n\nimport type { Context, Translation, Warning } from \"../core/queries/types.ts\";\nimport { queries } from \"./queries/index.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n warnings: Warning[];\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = { path };\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) continue;\n const { node, translation, error } = message;\n if (seen.has(node.id)) continue;\n seen.add(node.id);\n const reference = getReference(node, context);\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n return { translations, warnings };\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { parseSource } from \"./parse.ts\";\n\nconst filter = /\\.[cm]?[jt]sx$/;\n\nexport function react(): Plugin<string, Translation[]> {\n return {\n name: \"react\",\n setup(build) {\n build.context.logger?.debug(\"react plugin initialized\");\n build.onResolve({ filter: /.*/, namespace: \"source\" }, ({ entrypoint, path, namespace }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n build.onLoad({ filter, namespace: \"source\" }, async ({ entrypoint, path, namespace }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n build.onProcess({ filter, namespace: \"source\" }, ({ entrypoint, path, data }) => {\n const { translations, warnings } = parseSource(data, path);\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate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AQ,MAAM,2BAA2B;AACvD,SAAM,UAAU;IAAE,QAAQ;IAAM,WAAW;IAAU,GAAG,EAAE,YAAY,cAAM,6BAAgB;AACxF,WAAO;KACH;KACA;KACA,MAAM,QAAQC,OAAK;KACtB;KACH;AACF,SAAM,OAAO;IAAE;IAAQ,WAAW;IAAU,EAAE,OAAO,EAAE,YAAY,cAAM,6BAAgB;IACrF,MAAM,OAAO,MAAM,SAASA,QAAM,OAAO;AACzC,WAAO;KACH;KACA;KACA;KACA;KACH;KACH;AACF,SAAM,UAAU;IAAE;IAAQ,WAAW;IAAU,GAAG,EAAE,YAAY,cAAM,WAAW;IAC7E,MAAM,EAAE,cAAc,aAAa,YAAY,MAAMA,OAAK;AAE1D,SAAK,MAAM,WAAW,SAClB,OAAM,QAAQ,QAAQ,KAAK,GAAG,QAAQ,MAAM,MAAM,QAAQ,YAAY;AAG1E,UAAM,QAAQ;KACV;KACA;KACA,WAAW;KACX,MAAM;KACT,CAAC;KAGJ;;EAET"}
1
+ {"version":3,"file":"index.js","names":["namespace","path","path","importQuery: ImportQuerySpec","current: Parser.SyntaxNode | null","messageQuery: QuerySpec","allowed","messageInvalidQuery: QuerySpec","ids: string[]","strs: string[]","subMatch: Parser.QueryMatch","translation: Translation","contextMsgQuery: QuerySpec","msgCall","contextPluralQuery: QuerySpec","contextInvalidQuery: QuerySpec","gettextQuery: QuerySpec","gettextInvalidQuery: QuerySpec","msgCall","plainMsg","msgArg","ngettextQuery: QuerySpec","msgCall","npgettextQuery: QuerySpec","pgettextQuery: QuerySpec","pluralQuery: QuerySpec","queries: QuerySpec[]","messageQuery","pluralQuery","path","parseSource","context: Context","translations: Translation[]","warnings: Warning[]","imports: string[]","queries","fs","resolved: string[]","filter","namespace","path","parseSource","translations: GetTextTranslationRecord","value","normalizedHeaders: Record<string, string>","headers: Record<string, string>","translations: GetTextTranslationRecord","obsoleteTranslations: GetTextTranslationRecord","collected: GetTextTranslationRecord","translations","existing","path","defaultDestination: DestinationFn","defaultExclude: Exclude[]","parts: Part[]","text","strings: string[]","values: string[]","messageQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","childValue: Parser.SyntaxNode | undefined","error: string | undefined","translation: Translation","forms: string[]","pluralQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","formsNode: Parser.SyntaxNode | null | undefined","translation: Translation","queries: QuerySpec[]","context: Context","path","translations: Translation[]","warnings: Warning[]","path"],"sources":["../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/comment.ts","../../src/plugins/core/queries/import.ts","../../src/plugins/core/queries/utils.ts","../../src/plugins/core/queries/message.ts","../../src/plugins/core/queries/plural-utils.ts","../../src/plugins/core/queries/context.ts","../../src/plugins/core/queries/gettext.ts","../../src/plugins/core/queries/ngettext.ts","../../src/plugins/core/queries/npgettext.ts","../../src/plugins/core/queries/pgettext.ts","../../src/plugins/core/queries/plural.ts","../../src/plugins/core/queries/index.ts","../../src/plugins/core/parse.ts","../../src/plugins/core/resolve.ts","../../src/plugins/core/core.ts","../../src/plugins/po/collect.ts","../../src/plugins/po/hasChanges.ts","../../src/plugins/po/merge.ts","../../src/plugins/po/po.ts","../../src/configuration.ts","../../src/plugins/react/queries/utils.ts","../../src/plugins/react/queries/message.ts","../../src/plugins/react/queries/plural.ts","../../src/plugins/react/queries/index.ts","../../src/plugins/react/parse.ts","../../src/plugins/react/react.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\n\nconst namespace = \"cleanup\";\n\nexport function cleanup(): Plugin {\n return {\n name: \"cleanup\",\n setup(build) {\n build.context.logger?.debug(\"cleanup plugin initialized\");\n const processed = new Set<string>();\n const generated = new Set<string>();\n const dirs = new Set<string>();\n let dispatched = false;\n\n build.onResolve({ namespace, filter: /.*/ }, ({ path }) => {\n generated.add(path);\n dirs.add(dirname(path));\n\n Promise.all([build.defer(\"source\"), build.defer(\"translate\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of dirs.values()) {\n build.process({ entrypoint: path, path, namespace, data: undefined });\n }\n });\n\n return undefined;\n });\n\n build.onProcess({ namespace, filter: /.*/ }, async ({ path }) => {\n if (processed.has(path)) {\n return undefined;\n }\n processed.add(path);\n const files = await fs.readdir(path).catch(() => []);\n for (const f of files.filter((p) => p.endsWith(\".po\"))) {\n const full = join(path, f);\n const contents = await fs.readFile(full).catch(() => undefined);\n if (!contents) {\n continue;\n }\n const parsed = gettextParser.po.parse(contents);\n const hasTranslations = Object.entries(parsed.translations || {}).some(([ctx, msgs]) =>\n Object.keys(msgs).some((id) => !(ctx === \"\" && id === \"\")),\n );\n if (!hasTranslations && generated.has(full)) {\n await fs.unlink(full);\n }\n if (hasTranslations && !generated.has(full)) {\n build.context.logger?.warn({ path: full }, \"stray translation file\");\n }\n }\n return undefined;\n });\n },\n };\n}\n","import { relative } from \"node:path\";\nimport type Parser from \"tree-sitter\";\n\nimport type { Context, QuerySpec } from \"./types.ts\";\n\nexport function getReference(node: Parser.SyntaxNode, { path }: Context) {\n const line = node.startPosition.row + 1;\n const rel = relative(process.cwd(), path).replace(/\\\\+/g, \"/\");\n return `${rel}:${line}`;\n}\n\nfunction getComment(node: Parser.SyntaxNode): string {\n const text = node.text;\n if (text.startsWith(\"/*\")) {\n return text\n .slice(2, -2)\n .replace(/^\\s*\\*?\\s*/gm, \"\")\n .trim();\n }\n return text.replace(/^\\/\\/\\s?/, \"\").trim();\n}\n\nexport const withComment = (query: QuerySpec): QuerySpec => ({\n pattern: `(\n\t((comment) @comment)?\n .\n\t(_ ${query.pattern})\n)`,\n extract(match) {\n const result = query.extract(match);\n if (!result?.translation) {\n return result;\n }\n\n const comment = match.captures.find((c) => c.name === \"comment\")?.node;\n if (!comment) {\n return result;\n }\n\n if (comment) {\n result.translation.comments = {\n ...result.translation.comments,\n extracted: getComment(comment),\n };\n }\n\n return result;\n },\n});\n","import type Parser from \"tree-sitter\";\nimport type { ImportQuerySpec } from \"./types.ts\";\n\nexport const importQuery: ImportQuerySpec = {\n pattern: `\n [\n (import_statement\n source: (string (string_fragment) @import))\n (export_statement\n source: (string (string_fragment) @import))\n (call_expression\n function: (identifier) @func\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @func \"require\"))\n (call_expression\n function: (member_expression\n object: (identifier) @obj\n property: (property_identifier) @method)\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @obj \"require\")\n (#eq? @method \"resolve\"))\n (call_expression\n function: (import)\n arguments: (arguments (string (string_fragment) @import)))\n ]\n `,\n extract(match: Parser.QueryMatch): string | undefined {\n const node = match.captures.find((c) => c.name === \"import\")?.node;\n return node?.text;\n },\n};\n","import type Parser from \"tree-sitter\";\n\nexport const callPattern = (fnName: string, args: string, allowMember = true): string => `(\n (call_expression\n function: ${\n allowMember\n ? `[\n (identifier) @func\n (member_expression property: (property_identifier) @func)\n ]`\n : `(identifier) @func`\n }\n arguments: ${args}\n ) @call\n (#eq? @func \"${fnName}\")\n)`;\n\nexport function isDescendant(node: Parser.SyntaxNode, ancestor: Parser.SyntaxNode): boolean {\n let current: Parser.SyntaxNode | null = node;\n while (current) {\n if (current.id === ancestor.id) return true;\n current = current.parent;\n }\n return false;\n}\n","import type Parser from \"tree-sitter\";\nimport { withComment } from \"./comment.ts\";\nimport type { MessageMatch, QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst notInPlural = (query: QuerySpec): QuerySpec => ({\n pattern: query.pattern,\n extract(match) {\n const result = query.extract(match);\n if (!result?.node) {\n return result;\n }\n\n let parent = result.node.parent;\n\n if (parent && parent.type === \"arguments\") {\n parent = parent.parent;\n }\n\n if (parent && parent.type === \"call_expression\") {\n const fn = parent.childForFieldName(\"function\");\n if (fn) {\n if (\n (fn.type === \"identifier\" &&\n (fn.text === \"plural\" ||\n fn.text === \"ngettext\" ||\n fn.text === \"pgettext\" ||\n fn.text === \"npgettext\")) ||\n (fn.type === \"member_expression\" &&\n [\"plural\", \"ngettext\", \"pgettext\", \"npgettext\"].includes(\n fn.childForFieldName(\"property\")?.text ?? \"\",\n ))\n ) {\n return undefined;\n }\n }\n }\n\n return result;\n },\n});\n\nexport const messageArg = `[\n (string (string_fragment) @msgid)\n (object\n (_)*\n (pair\n key: (property_identifier) @id_key\n value: (string (string_fragment) @id)\n (#eq? @id_key \"id\")\n )?\n (_)*\n (pair\n key: (property_identifier) @msg_key\n value: (string (string_fragment) @message)\n (#eq? @msg_key \"message\")\n )?\n (_)*\n )\n (template_string) @tpl\n]`;\n\nexport const messageArgs = `[ (arguments ${messageArg}) (template_string) @tpl ]`;\n\nexport const extractMessage =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) {\n return undefined;\n }\n\n const msgid = match.captures.find((c) => c.name === \"msgid\")?.node.text;\n if (msgid) {\n return {\n node,\n translation: {\n id: msgid,\n message: [msgid],\n },\n };\n }\n\n const tpl = match.captures.find((c) => c.name === \"tpl\")?.node;\n if (tpl) {\n for (const child of tpl.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node,\n error: `${name}() template expressions must be simple identifiers`,\n };\n }\n }\n\n const text = tpl.text.slice(1, -1);\n\n return {\n node,\n translation: { id: text, message: [text] },\n };\n }\n\n const id = match.captures.find((c) => c.name === \"id\")?.node.text;\n const message = match.captures.find((c) => c.name === \"message\")?.node.text;\n const msgId = id ?? message;\n if (!msgId) {\n return undefined;\n }\n\n const msgstr = message ?? id ?? \"\";\n\n return {\n node,\n translation: {\n id: msgId,\n message: [msgstr],\n },\n };\n };\n\nexport const messageQuery: QuerySpec = notInPlural(\n withComment({\n pattern: callPattern(\"message\", messageArgs),\n extract: extractMessage(\"message\"),\n }),\n);\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\"]);\n\nexport const messageInvalidQuery: QuerySpec = notInPlural({\n pattern: callPattern(\"message\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"message() argument must be a string literal, object literal, or template literal\",\n };\n },\n});\n","import type Parser from \"tree-sitter\";\nimport { extractMessage } from \"./message.ts\";\nimport type { MessageMatch, Translation } from \"./types.ts\";\nimport { isDescendant } from \"./utils.ts\";\n\nexport const extractPluralForms =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const n = match.captures.find((c) => c.name === \"n\")?.node;\n if (!call || !n || n.nextNamedSibling) {\n return undefined;\n }\n\n const msgctxt = match.captures.find((c) => c.name === \"msgctxt\")?.node?.text;\n const msgNodes = match.captures.filter((c) => c.name === \"msg\").map((c) => c.node);\n\n const ids: string[] = [];\n const strs: string[] = [];\n\n for (const node of msgNodes) {\n const relevant = match.captures.filter(\n (c) => [\"msgid\", \"id\", \"message\", \"tpl\"].includes(c.name) && isDescendant(c.node, node),\n );\n\n const subMatch: Parser.QueryMatch = {\n pattern: 0,\n captures: [{ name: \"call\", node }, ...relevant],\n };\n\n const result = extractMessage(name)(subMatch);\n if (!result) continue;\n if (result.error) {\n return { node: call, error: result.error };\n }\n if (result.translation) {\n ids.push(result.translation.id);\n strs.push(result.translation.message[0] ?? \"\");\n }\n }\n\n if (ids.length === 0) {\n return undefined;\n }\n\n const translation: Translation = {\n id: ids[0],\n plural: ids[1],\n message: strs,\n };\n if (msgctxt) translation.context = msgctxt;\n\n return { node: call, translation };\n };\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst ctxCall = callPattern(\n \"context\",\n `[\n (arguments (string (string_fragment) @msgctxt))\n (template_string) @msgctxt\n]`,\n)\n .replace(/@call/g, \"@ctx\")\n .replace(/@func/g, \"@ctxfn\");\n\nexport const contextMsgQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: ${messageArgs}\n ) @call\n (#eq? @func \"message\")\n)`,\n extract(match) {\n const result = extractMessage(\"context.message\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !result.translation || !contextNode) {\n return result;\n }\n\n if (contextNode.type === \"template_string\") {\n for (const child of contextNode.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node: contextNode,\n error: \"context() template expressions must be simple identifiers\",\n };\n }\n }\n }\n\n const contextText =\n contextNode.type === \"template_string\" ? contextNode.text.slice(1, -1) : contextNode.text;\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextText,\n },\n };\n },\n});\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const contextPluralQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: (arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))\n ) @call\n (#eq? @func \"plural\")\n)`,\n extract: extractPluralForms(\"context.plural\"),\n});\n\nexport const contextInvalidQuery: QuerySpec = withComment({\n pattern: ctxCall,\n extract(match) {\n const call = match.captures.find((c) => c.name === \"ctx\")?.node;\n if (!call) {\n return undefined;\n }\n\n const parent = call.parent;\n if (parent && parent.type === \"member_expression\" && parent.childForFieldName(\"object\")?.id === call.id) {\n const property = parent.childForFieldName(\"property\")?.text;\n const grandparent = parent.parent;\n if (\n grandparent &&\n grandparent.type === \"call_expression\" &&\n grandparent.childForFieldName(\"function\")?.id === parent.id &&\n (property === \"message\" || property === \"plural\")\n ) {\n return undefined;\n }\n }\n\n return {\n node: call,\n error: \"context() must be used with message() or plural() in the same expression\",\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const gettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"gettext\", messageArgs),\n extract: extractMessage(\"gettext\"),\n});\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\", \"identifier\", \"call_expression\"]);\n\nexport const gettextInvalidQuery: QuerySpec = {\n pattern: callPattern(\"gettext\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"gettext() argument must be a string literal, object literal, or template literal\",\n };\n },\n};\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const ngettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"ngettext\", `(arguments ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`),\n extract: extractPluralForms(\"ngettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const npgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"npgettext\",\n `(arguments (string (string_fragment) @msgctxt) \",\" ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`,\n ),\n extract: extractPluralForms(\"npgettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArg } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const pgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"pgettext\", `(arguments (string (string_fragment) @msgctxt) \",\" ${messageArg})`),\n extract(match) {\n const result = extractMessage(\"pgettext\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !contextNode || !result.translation) {\n return result;\n }\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextNode.text,\n },\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"plural\",\n `(arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))`,\n false,\n ),\n extract: extractPluralForms(\"plural\"),\n});\n","import { contextInvalidQuery, contextMsgQuery, contextPluralQuery } from \"./context.ts\";\nimport { gettextInvalidQuery, gettextQuery } from \"./gettext.ts\";\nimport { messageInvalidQuery, messageQuery } from \"./message.ts\";\nimport { ngettextQuery } from \"./ngettext.ts\";\nimport { npgettextQuery } from \"./npgettext.ts\";\nimport { pgettextQuery } from \"./pgettext.ts\";\nimport { pluralQuery } from \"./plural.ts\";\nimport type { QuerySpec } from \"./types.ts\";\n\nexport type { MessageMatch, QuerySpec } from \"./types.ts\";\n\nexport const queries: QuerySpec[] = [\n contextMsgQuery,\n contextPluralQuery,\n contextInvalidQuery,\n messageQuery,\n messageInvalidQuery,\n gettextQuery,\n gettextInvalidQuery,\n pluralQuery,\n ngettextQuery,\n pgettextQuery,\n npgettextQuery,\n];\n","import fs from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\n\nimport Parser from \"tree-sitter\";\nimport JavaScript from \"tree-sitter-javascript\";\nimport TS from \"tree-sitter-typescript\";\n\nimport { getReference } from \"./queries/comment.ts\";\nimport { importQuery } from \"./queries/import.ts\";\nimport { queries } from \"./queries/index.ts\";\nimport type { Context, Translation, Warning } from \"./queries/types.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n imports: string[];\n warnings: Warning[];\n}\n\nfunction getLanguage(ext: string) {\n switch (ext) {\n case \".ts\":\n return TS.typescript;\n case \".tsx\":\n return TS.tsx;\n default:\n return JavaScript;\n }\n}\n\nconst parserCache = new Map<string, { parser: Parser; language: Parser.Language }>();\nconst queryCache = new WeakMap<Parser.Language, Map<string, Parser.Query>>();\n\nfunction getCachedParser(ext: string) {\n let cached = parserCache.get(ext);\n if (!cached) {\n const parser = new Parser();\n const language = getLanguage(ext) as Parser.Language;\n parser.setLanguage(language);\n cached = { parser, language };\n parserCache.set(ext, cached);\n }\n return cached;\n}\n\nfunction getCachedQuery(language: Parser.Language, pattern: string) {\n let cache = queryCache.get(language);\n if (!cache) {\n cache = new Map();\n queryCache.set(language, cache);\n }\n\n let query = cache.get(pattern);\n if (!query) {\n query = new Parser.Query(language, pattern);\n cache.set(pattern, query);\n }\n\n return query;\n}\n\nexport function getParser(path: string) {\n const ext = extname(path);\n return getCachedParser(ext);\n}\n\nexport function getQuery(language: Parser.Language, pattern: string) {\n return getCachedQuery(language, pattern);\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = {\n path,\n };\n\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const imports: string[] = [];\n\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getCachedQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) {\n continue;\n }\n\n const { node, translation, error } = message;\n if (seen.has(node.id)) {\n continue;\n }\n seen.add(node.id);\n const reference = getReference(node, context);\n\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n const importTreeQuery = getCachedQuery(language, importQuery.pattern);\n for (const match of importTreeQuery.matches(tree.rootNode)) {\n const imp = importQuery.extract(match);\n if (imp) {\n imports.push(imp);\n }\n }\n\n return { translations, imports, warnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ResolverFactory } from \"oxc-resolver\";\n\nfunction findTsconfig(dir: string): string | undefined {\n let current = dir;\n while (true) {\n const config = path.join(current, \"tsconfig.json\");\n if (fs.existsSync(config)) {\n return config;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n current = parent;\n }\n}\n\nconst resolverCache = new Map<string, ResolverFactory>();\n\nfunction getResolver(dir: string) {\n const tsconfig = findTsconfig(dir);\n const key = tsconfig ?? \"__default__\";\n let resolver = resolverCache.get(key);\n if (!resolver) {\n resolver = new ResolverFactory({\n extensions: [\".ts\", \".tsx\", \".js\", \".jsx\", \".mjs\", \".cjs\", \".json\"],\n conditionNames: [\"import\", \"require\", \"node\"],\n ...(tsconfig ? { tsconfig: { configFile: tsconfig } } : {}),\n });\n resolverCache.set(key, resolver);\n }\n return resolver;\n}\n\nfunction resolveFromDir(dir: string, spec: string): string | undefined {\n const resolver = getResolver(dir);\n const res = resolver.sync(dir, spec) as { path?: string };\n return res.path;\n}\n\nexport function resolveImport(file: string, spec: string): string | undefined {\n const dir = path.dirname(path.resolve(file));\n return resolveFromDir(dir, spec);\n}\n\nexport function resolveImports(file: string, imports: string[]): string[] {\n const dir = path.dirname(path.resolve(file));\n const resolver = getResolver(dir);\n const resolved: string[] = [];\n for (const spec of imports) {\n const res = resolver.sync(dir, spec) as { path?: string };\n if (res.path) {\n resolved.push(res.path);\n }\n }\n return resolved;\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport { parseSource } from \"./parse.ts\";\nimport type { Translation } from \"./queries/types.ts\";\nimport { resolveImports } from \"./resolve.ts\";\n\nconst filter = /\\.([cm]?tsx?|jsx?)$/;\nconst namespace = \"source\";\n\nexport function core(): Plugin<string, Translation[]> {\n return {\n name: \"core\",\n setup(build) {\n build.context.logger?.debug(\"core plugin initialized\");\n build.onResolve({ filter, namespace }, ({ entrypoint, path }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n\n build.onLoad({ filter, namespace }, async ({ entrypoint, path }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter, namespace }, ({ entrypoint, path, data }) => {\n const { translations, imports, warnings } = parseSource(data, path);\n\n if (build.context.config.walk) {\n const paths = resolveImports(path, imports);\n for (const path of paths) {\n build.resolve({ entrypoint, path, namespace });\n }\n }\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n\n return undefined;\n });\n },\n };\n}\n","import type { GetTextTranslationRecord } from \"gettext-parser\";\nimport { getNPlurals } from \"plural-forms\";\n\nimport type { Translation } from \"../core/queries/types.ts\";\n\nexport function collect(source: Translation[], locale?: string): GetTextTranslationRecord {\n const translations: GetTextTranslationRecord = { \"\": {} };\n const nplurals = locale ? getNPlurals(locale) : undefined;\n\n for (const { context, id, message, comments, obsolete, plural } of source) {\n const ctx = context || \"\";\n if (!translations[ctx]) {\n translations[ctx] = {};\n }\n\n const length = plural ? (nplurals ?? message.length) : 1;\n\n const existing = translations[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (comments?.reference) {\n comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n\n const msgstr = existing?.msgstr ? existing.msgstr.slice(0, length) : Array.from({ length }, () => \"\");\n while (msgstr.length < length) msgstr.push(\"\");\n\n translations[ctx][id] = {\n msgctxt: context || undefined,\n msgid: id,\n msgid_plural: plural,\n msgstr,\n comments: {\n ...existing?.comments,\n ...comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n obsolete: existing?.obsolete ?? obsolete,\n };\n }\n\n return translations;\n}\n","import { isDeepStrictEqual } from \"node:util\";\nimport type { GetTextTranslations } from \"gettext-parser\";\nimport * as gettextParser from \"gettext-parser\";\n\nconst IGNORED_HEADER_KEYS = new Set([\"pot-creation-date\", \"po-revision-date\"]);\nconst IGNORED_HEADER_LINE_PREFIXES = [\"pot-creation-date:\", \"po-revision-date:\"];\n\nfunction normalizeHeaderString(value: string): string {\n const lines = value.split(\"\\n\");\n const hadTrailingNewline = value.endsWith(\"\\n\");\n\n const filtered = lines\n .filter((line) => {\n const trimmed = line.trimStart().toLowerCase();\n return !IGNORED_HEADER_LINE_PREFIXES.some((prefix) => trimmed.startsWith(prefix));\n })\n .map((line) => {\n const separatorIndex = line.indexOf(\":\");\n if (separatorIndex === -1) {\n return line;\n }\n\n const key = line.slice(0, separatorIndex).trim().toLowerCase();\n const value = line.slice(separatorIndex + 1);\n return `${key}:${value}`;\n });\n\n if (hadTrailingNewline && filtered[filtered.length - 1] !== \"\") {\n filtered.push(\"\");\n }\n\n return filtered.join(\"\\n\");\n}\n\nfunction normalize(translations: GetTextTranslations): GetTextTranslations {\n const compiled = gettextParser.po.compile(translations);\n const parsed = gettextParser.po.parse(compiled);\n\n if (parsed.headers) {\n const normalizedHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(parsed.headers)) {\n if (!IGNORED_HEADER_KEYS.has(key.toLowerCase())) {\n normalizedHeaders[key.toLowerCase()] = value as string;\n }\n }\n parsed.headers = normalizedHeaders;\n }\n\n const headerMessage = parsed.translations?.[\"\"]?.[\"\"];\n if (headerMessage?.msgstr) {\n headerMessage.msgstr = headerMessage.msgstr.map((item) => normalizeHeaderString(item));\n }\n\n return parsed;\n}\n\nexport function hasChanges(left: GetTextTranslations, right?: GetTextTranslations): boolean {\n if (!right) {\n return true;\n }\n\n const normalizedLeft = normalize(left);\n const normalizedRight = normalize(right);\n\n return !isDeepStrictEqual(normalizedLeft, normalizedRight);\n}\n","import type { GetTextTranslationRecord, GetTextTranslations } from \"gettext-parser\";\nimport { getFormula, getNPlurals } from \"plural-forms\";\n\nimport type { ObsoleteStrategy } from \"../../configuration.ts\";\n\nexport interface Collected {\n translations: GetTextTranslationRecord;\n}\n\nexport function formatDate(date: Date): string {\n const pad = (n: number) => n.toString().padStart(2, \"0\");\n const year = date.getFullYear();\n const month = pad(date.getMonth() + 1);\n const day = pad(date.getDate());\n const hours = pad(date.getHours());\n const minutes = pad(date.getMinutes());\n const tzo = -date.getTimezoneOffset();\n const sign = tzo >= 0 ? \"+\" : \"-\";\n const offsetHours = pad(Math.floor(Math.abs(tzo) / 60));\n const offsetMinutes = pad(Math.abs(tzo) % 60);\n return `${year}-${month}-${day} ${hours}:${minutes}${sign}${offsetHours}${offsetMinutes}`;\n}\n\nexport function merge(\n sources: Collected[],\n existing: GetTextTranslations | undefined,\n obsolete: ObsoleteStrategy,\n locale: string,\n generatedAt: Date,\n): GetTextTranslations {\n let headers: Record<string, string> = {};\n let translations: GetTextTranslationRecord = { \"\": {} };\n let obsoleteTranslations: GetTextTranslationRecord = {};\n const nplurals = getNPlurals(locale);\n\n if (existing) {\n headers = existing.headers ? structuredClone(existing.headers) : {};\n translations = existing.translations ? structuredClone(existing.translations) : { \"\": {} };\n obsoleteTranslations = existing.obsolete ? structuredClone(existing.obsolete) : {};\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") continue;\n translations[ctx][id].obsolete = true;\n }\n }\n }\n\n const collected: GetTextTranslationRecord = { \"\": {} };\n for (const { translations } of sources) {\n for (const [ctx, msgs] of Object.entries(translations)) {\n if (!collected[ctx]) collected[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existing = collected[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (entry.comments?.reference) {\n entry.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n collected[ctx][id] = {\n ...existing,\n ...entry,\n comments: {\n ...existing?.comments,\n ...entry.comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n };\n }\n }\n }\n\n for (const [ctx, msgs] of Object.entries(collected)) {\n if (!translations[ctx]) translations[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existingEntry = translations[ctx][id] ?? obsoleteTranslations[ctx]?.[id];\n if (existingEntry) {\n entry.msgstr = existingEntry.msgstr;\n entry.comments = {\n ...entry.comments,\n translator: existingEntry.comments?.translator,\n };\n }\n delete entry.obsolete;\n entry.msgstr = entry.msgstr.slice(0, nplurals);\n while (entry.msgstr.length < nplurals) {\n entry.msgstr.push(\"\");\n }\n translations[ctx][id] = entry;\n if (obsoleteTranslations[ctx]) {\n delete obsoleteTranslations[ctx][id];\n }\n }\n }\n\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") {\n continue;\n }\n const entry = translations[ctx][id];\n if (entry.obsolete) {\n if (!obsoleteTranslations[ctx]) {\n obsoleteTranslations[ctx] = {};\n }\n obsoleteTranslations[ctx][id] = entry;\n delete translations[ctx][id];\n }\n }\n }\n\n headers = {\n ...headers,\n \"Content-Type\": headers[\"Content-Type\"] || \"text/plain; charset=UTF-8\",\n \"Plural-Forms\": `nplurals=${nplurals}; plural=${getFormula(locale)};`,\n language: locale,\n \"MIME-Version\": \"1.0\",\n \"Content-Transfer-Encoding\": \"8bit\",\n \"POT-Creation-Date\": formatDate(generatedAt),\n \"x-generator\": \"@let-value/translate-extract\",\n };\n\n return {\n charset: \"utf-8\",\n headers,\n translations,\n ...(obsolete === \"mark\" && Object.keys(obsoleteTranslations).length ? { obsolete: obsoleteTranslations } : {}),\n };\n}\n","import fs from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { collect } from \"./collect.ts\";\nimport { hasChanges } from \"./hasChanges.ts\";\nimport { merge } from \"./merge.ts\";\n\nconst namespace = \"translate\";\n\nexport function po(): Plugin {\n return {\n name: \"po\",\n setup(build) {\n build.context.logger?.debug(\"po plugin initialized\");\n const collections = new Map<\n string,\n {\n locale: string;\n translations: Translation[];\n }\n >();\n let dispatched = false;\n\n build.onResolve({ filter: /.*/, namespace }, async ({ entrypoint, path, data }) => {\n if (!data || !Array.isArray(data)) {\n return undefined;\n }\n\n for (const locale of build.context.config.locales) {\n const destination = build.context.config.destination({ entrypoint, locale, path });\n if (!collections.has(destination)) {\n collections.set(destination, { locale, translations: [] });\n }\n\n collections.get(destination)?.translations.push(...data);\n }\n\n Promise.all([build.defer(\"source\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of collections.keys()) {\n build.load({ entrypoint, path, namespace });\n }\n });\n\n return undefined;\n });\n\n build.onLoad({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path }) => {\n const contents = await fs.readFile(path).catch(() => undefined);\n const data = contents ? gettextParser.po.parse(contents) : undefined;\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path, data }) => {\n const collected = collections.get(path);\n if (!collected) {\n build.context.logger?.warn({ path }, \"no translations collected for this path\");\n return undefined;\n }\n\n const { locale, translations } = collected;\n\n const record = collect(translations, locale);\n\n const out = merge(\n [{ translations: record }],\n data as never,\n build.context.config.obsolete,\n locale,\n build.context.generatedAt,\n );\n\n if (hasChanges(out, data as never)) {\n await fs.mkdir(dirname(path), { recursive: true });\n await fs.writeFile(path, gettextParser.po.compile(out));\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"cleanup\",\n data: translations,\n });\n });\n },\n };\n}\n","import { basename, dirname, extname, join } from \"node:path\";\nimport type { PluralFormsLocale } from \"@let-value/translate\";\nimport type { LogLevel } from \"./logger.ts\";\n\nimport type { Plugin } from \"./plugin.ts\";\nimport { cleanup } from \"./plugins/cleanup/cleanup.ts\";\nimport { core } from \"./plugins/core/core.ts\";\nimport { po } from \"./plugins/po/po.ts\";\n\nexport type DestinationFn = (args: { locale: string; entrypoint: string; path: string }) => string;\nexport type ExcludeFn = (args: { entrypoint: string; path: string }) => boolean;\nexport type Exclude = RegExp | ExcludeFn;\n\nconst defaultPlugins = { core, po, cleanup };\ntype DefaultPlugins = typeof defaultPlugins;\n\n/**\n * Strategy to handle obsolete translations in existing locale files:\n * - \"mark\": keep obsolete entries in the locale file but mark them as obsolete\n * - \"remove\": remove obsolete entries from the locale file\n */\nexport type ObsoleteStrategy = \"mark\" | \"remove\";\n\nexport interface EntrypointConfig {\n entrypoint: string;\n destination?: DestinationFn;\n obsolete?: ObsoleteStrategy;\n walk?: boolean;\n exclude?: Exclude | Exclude[];\n}\n\nexport interface UserConfig {\n /**\n * Default locale to use as the base for extraction\n * @default \"en\"\n * @see {@link PluralFormsLocale} for available locales\n */\n defaultLocale?: PluralFormsLocale;\n /**\n * Array of locales to extract translations for\n * @default [defaultLocale]\n * @see {@link PluralFormsLocale} for available locales\n */\n locales?: PluralFormsLocale[];\n /**\n * Array of plugins to use or a function to override the default plugins\n * @default DefaultPlugins\n * @see {@link DefaultPlugins} for available plugins\n */\n plugins?: Plugin[] | ((defaultPlugins: DefaultPlugins) => Plugin[]);\n /**\n * One or more entrypoints to extract translations from, could be:\n * - file path, will be treated as a single file entrypoint\n * - glob pattern will be expanded to match files, each treated as a separate entrypoint\n * - configuration object with options for the entrypoint\n * @see {@link EntrypointConfig} for configuration options\n */\n entrypoints: string | EntrypointConfig | Array<string | EntrypointConfig>;\n /**\n * Function to determine the destination path for each extracted locale file\n * @default `./translations/entrypoint.locale.po`\n * @see {@link DestinationFn}\n * @see Can be overridden per entrypoint via `destination` in {@link EntrypointConfig\n */\n destination?: DestinationFn;\n /**\n * Strategy to handle obsolete translations in existing locale files\n * @default \"mark\"\n * @see {@link ObsoleteStrategy} for available strategies\n * @see Can be overridden per entrypoint via `obsolete` in {@link EntrypointConfig\n */\n obsolete?: ObsoleteStrategy;\n /**\n * Whether to recursively walk dependencies of the entrypoints\n * @default true\n * @see Can be overridden per entrypoint via `walk` in {@link EntrypointConfig}.\n */\n walk?: boolean;\n /**\n * Paths or patterns to exclude from extraction, applied to all entrypoints\n * @default [/node_modules/, /dist/, /build/]\n * @see Can be overridden per entrypoint via `exclude` in {@link EntrypointConfig}.\n */\n exclude?: Exclude | Exclude[];\n /**\n * Log level for the extraction process\n * @default \"info\"\n */\n logLevel?: LogLevel;\n}\n\nexport interface ResolvedEntrypoint extends Omit<EntrypointConfig, \"exclude\"> {\n exclude?: Exclude[];\n}\n\nexport interface ResolvedConfig {\n plugins: Plugin[];\n entrypoints: ResolvedEntrypoint[];\n defaultLocale: string;\n locales: string[];\n destination: DestinationFn;\n obsolete: ObsoleteStrategy;\n walk: boolean;\n logLevel: LogLevel;\n exclude: Exclude[];\n}\n\nconst defaultDestination: DestinationFn = ({ entrypoint, locale }) =>\n join(dirname(entrypoint), \"translations\", `${basename(entrypoint, extname(entrypoint))}.${locale}.po`);\n\nconst defaultExclude: Exclude[] = [\n /(?:^|[\\\\/])node_modules(?:[\\\\/]|$)/,\n /(?:^|[\\\\/])dist(?:[\\\\/]|$)/,\n /(?:^|[\\\\/])build(?:[\\\\/]|$)/,\n];\n\nfunction normalizeExclude(exclude?: Exclude | Exclude[]): Exclude[] {\n if (!exclude) return [];\n return Array.isArray(exclude) ? exclude : [exclude];\n}\n\nfunction resolveEntrypoint(ep: string | EntrypointConfig): ResolvedEntrypoint {\n if (typeof ep === \"string\") {\n return { entrypoint: ep };\n }\n const { entrypoint, destination, obsolete, walk, exclude } = ep;\n return { entrypoint, destination, obsolete, walk, exclude: exclude ? normalizeExclude(exclude) : undefined };\n}\n\nfunction resolvePlugins(user?: UserConfig[\"plugins\"]): Plugin[] {\n if (typeof user === \"function\") {\n return user(defaultPlugins);\n }\n if (Array.isArray(user)) {\n return [...Object.values(defaultPlugins).map((plugin) => plugin()), ...user];\n }\n return Object.values(defaultPlugins).map((plugin) => plugin());\n}\n\n/**\n * Type helper to make it easier to use translate.config.ts\n * @param config - {@link UserConfig}.\n */\nexport function defineConfig(config: UserConfig): ResolvedConfig {\n const defaultLocale = config.defaultLocale ?? \"en\";\n\n const plugins = resolvePlugins(config.plugins);\n\n const raw = Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints];\n const entrypoints = raw.map(resolveEntrypoint);\n\n return {\n plugins,\n entrypoints,\n defaultLocale,\n locales: config.locales ?? [defaultLocale],\n destination: config.destination ?? defaultDestination,\n obsolete: config.obsolete ?? \"mark\",\n walk: config.walk ?? true,\n logLevel: config.logLevel ?? \"info\",\n exclude: config.exclude ? normalizeExclude(config.exclude) : defaultExclude,\n };\n}\n","import type Parser from \"tree-sitter\";\n\nexport function buildTemplate(node: Parser.SyntaxNode): { text: string; error?: string } {\n const source = node.tree.rootNode.text;\n const open = node.childForFieldName(\"open_tag\");\n const close = node.childForFieldName(\"close_tag\");\n const contentStart = open?.endIndex ?? node.startIndex;\n const contentEnd = close?.startIndex ?? node.endIndex;\n\n type Part = { kind: \"text\"; text: string; raw: boolean } | { kind: \"expr\"; value: string };\n\n const parts: Part[] = [];\n let segmentStart = contentStart;\n\n const pushRawText = (endIndex: number) => {\n if (endIndex <= segmentStart) {\n segmentStart = Math.max(segmentStart, endIndex);\n return;\n }\n const text = source.slice(segmentStart, endIndex);\n if (text) {\n parts.push({ kind: \"text\", text, raw: true });\n }\n segmentStart = endIndex;\n };\n\n const children = node.namedChildren.slice(1, -1);\n for (const child of children) {\n if (child.type === \"jsx_expression\") {\n pushRawText(child.startIndex);\n const expr = child.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n parts.push({ kind: \"expr\", value: expr.text });\n } else if (expr.type === \"string\") {\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else if (expr.type === \"template_string\") {\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n segmentStart = child.endIndex;\n } else if (child.type === \"string\") {\n pushRawText(child.startIndex);\n parts.push({ kind: \"text\", text: child.text.slice(1, -1), raw: false });\n segmentStart = child.endIndex;\n } else if (child.type === \"jsx_text\" || child.type === \"html_character_reference\" || child.isError) {\n } else {\n return { text: \"\", error: \"Unsupported JSX child\" };\n }\n }\n\n pushRawText(contentEnd);\n\n const firstRawIndex = parts.findIndex((part) => part.kind === \"text\" && part.raw);\n if (firstRawIndex === 0) {\n const part = parts[firstRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/^\\s+/, \"\");\n }\n\n let lastRawIndex = -1;\n for (let i = parts.length - 1; i >= 0; i--) {\n const part = parts[i];\n if (part.kind === \"text\" && part.raw) {\n lastRawIndex = i;\n break;\n }\n }\n if (lastRawIndex !== -1 && lastRawIndex === parts.length - 1) {\n const part = parts[lastRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/\\s+$/, \"\");\n }\n\n const strings: string[] = [\"\"];\n const values: string[] = [];\n for (const part of parts) {\n if (part.kind === \"text\") {\n if (part.text) {\n strings[strings.length - 1] += part.text;\n }\n } else {\n values.push(part.value);\n strings.push(\"\");\n }\n }\n\n let text = \"\";\n for (let i = 0; i < strings.length; i++) {\n text += strings[i];\n if (values[i]) {\n text += `\\${${values[i]}}`;\n }\n }\n return { text };\n}\n\nexport function buildAttrValue(node: Parser.SyntaxNode): { text: string; error?: string } {\n if (node.type === \"string\") {\n return { text: node.text.slice(1, -1) };\n }\n if (node.type === \"jsx_expression\") {\n const expr = node.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n return { text: `\\${${expr.text}}` };\n } else if (expr.type === \"string\") {\n return { text: expr.text.slice(1, -1) };\n } else if (expr.type === \"template_string\") {\n // Check if it's a simple template string with no substitutions\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n // Extract the text content from the template string\n const content = expr.text.slice(1, -1); // Remove backticks\n return { text: content };\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n }\n return { text: \"\", error: \"Unsupported JSX child\" };\n}\n","import type Parser from \"tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildAttrValue, buildTemplate } from \"./utils.ts\";\n\nexport const messageQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n (lexical_declaration \n (variable_declarator \n value: [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n ]\n )\n )\n ]\n (#eq? @name \"Message\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let childValue: Parser.SyntaxNode | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"children\" && value) {\n childValue = value;\n }\n }\n let text = \"\";\n let error: string | undefined;\n if (node.type === \"jsx_element\") {\n ({ text, error } = buildTemplate(node));\n } else if (childValue) {\n ({ text, error } = buildAttrValue(childValue));\n }\n if (error) {\n return { node, error };\n }\n if (!text) return undefined;\n const translation: Translation = {\n id: text,\n message: [text],\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type Parser from \"tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildTemplate } from \"./utils.ts\";\n\nfunction parseForms(node: Parser.SyntaxNode): { forms: string[]; error?: string } {\n const forms: string[] = [];\n if (node.type === \"jsx_expression\") {\n const arr = node.namedChildren[0];\n if (!arr || arr.type !== \"array\") {\n return { forms: [], error: \"Plural forms must be an array\" };\n }\n for (const el of arr.namedChildren) {\n if (el.type === \"jsx_element\" || el.type === \"jsx_fragment\") {\n const { text, error } = buildTemplate(el);\n if (error) return { forms: [], error };\n forms.push(text);\n } else if (el.type === \"string\") {\n forms.push(el.text.slice(1, -1));\n } else {\n return { forms: [], error: \"Unsupported plural form\" };\n }\n }\n }\n return { forms };\n}\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name))\n (jsx_self_closing_element name: (identifier) @name)\n ] @call\n (#eq? @name \"Plural\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let formsNode: Parser.SyntaxNode | null | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"forms\" && value) {\n formsNode = value;\n }\n }\n if (!formsNode) return undefined;\n const { forms, error } = parseForms(formsNode);\n if (error) {\n return { node, error };\n }\n if (forms.length === 0) return undefined;\n const translation: Translation = {\n id: forms[0],\n plural: forms[1],\n message: forms,\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type { QuerySpec } from \"../../core/queries/types.ts\";\nimport { messageQuery } from \"./message.ts\";\nimport { pluralQuery } from \"./plural.ts\";\n\nexport const queries: QuerySpec[] = [messageQuery, pluralQuery];\n","import fs from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getParser, getQuery } from \"../core/parse.ts\";\nimport { getReference } from \"../core/queries/comment.ts\";\n\nimport type { Context, Translation, Warning } from \"../core/queries/types.ts\";\nimport { queries } from \"./queries/index.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n warnings: Warning[];\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = { path };\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) continue;\n const { node, translation, error } = message;\n if (seen.has(node.id)) continue;\n seen.add(node.id);\n const reference = getReference(node, context);\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n return { translations, warnings };\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { parseSource } from \"./parse.ts\";\n\nconst filter = /\\.[cm]?[jt]sx$/;\n\nexport function react(): Plugin<string, Translation[]> {\n return {\n name: \"react\",\n setup(build) {\n build.context.logger?.debug(\"react plugin initialized\");\n build.onResolve({ filter: /.*/, namespace: \"source\" }, ({ entrypoint, path, namespace }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n build.onLoad({ filter, namespace: \"source\" }, async ({ entrypoint, path, namespace }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n build.onProcess({ filter, namespace: \"source\" }, ({ entrypoint, path, data }) => {\n const { translations, warnings } = parseSource(data, path);\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n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IAAI,KAAK,GAAG;GACjB,MAAM,YAAY,aAAa,MAAM,QAAQ;AAC7C,OAAI,YACA,cAAa,KAAK;IACd,GAAG;IACH,UAAU;KACN,GAAG,YAAY;KACf;KACH;IACJ,CAAC;AAEN,OAAI,MACA,UAAS,KAAK;IACV;IACA;IACH,CAAC;;;AAKd,QAAO;EAAE;EAAc;EAAU;;;;;AChDrC,MAAM,SAAS;AAEf,SAAgB,QAAuC;AACnD,QAAO;EACH,MAAM;EACN,MAAM,OAAO;AACT,SAAM,QAAQ,QAAQ,MAAM,2BAA2B;AACvD,SAAM,UAAU;IAAE,QAAQ;IAAM,WAAW;IAAU,GAAG,EAAE,YAAY,cAAM,6BAAgB;AACxF,WAAO;KACH;KACA;KACA,MAAM,QAAQC,OAAK;KACtB;KACH;AACF,SAAM,OAAO;IAAE;IAAQ,WAAW;IAAU,EAAE,OAAO,EAAE,YAAY,cAAM,6BAAgB;IACrF,MAAM,OAAO,MAAM,SAASA,QAAM,OAAO;AACzC,WAAO;KACH;KACA;KACA;KACA;KACH;KACH;AACF,SAAM,UAAU;IAAE;IAAQ,WAAW;IAAU,GAAG,EAAE,YAAY,cAAM,WAAW;IAC7E,MAAM,EAAE,cAAc,aAAa,YAAY,MAAMA,OAAK;AAE1D,SAAK,MAAM,WAAW,SAClB,OAAM,QAAQ,QAAQ,KAAK,GAAG,QAAQ,MAAM,MAAM,QAAQ,YAAY;AAG1E,UAAM,QAAQ;KACV;KACA;KACA,WAAW;KACX,MAAM;KACT,CAAC;KAGJ;;EAET"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@let-value/translate-extract",
3
- "version": "1.0.23",
3
+ "version": "1.0.26",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "dist"
21
21
  ],
22
22
  "dependencies": {
23
- "@let-value/translate": "1.0.23",
23
+ "@let-value/translate": "1.0.26",
24
24
  "chalk": "5.3.0",
25
25
  "cosmiconfig": "9.0.0",
26
26
  "gettext-parser": "8.0.0",