@wuchale/svelte 0.18.2 → 0.19.0

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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createHeuristic, deepMergeObjects, defaultGenerateLoadID, defaultHeuristicOpts } from 'wuchale';
1
+ import { createHeuristic, deepMergeObjects, defaultGenerateLoadID, defaultHeuristicOpts, pofile } from 'wuchale';
2
2
  import { loaderPathResolver } from 'wuchale/adapter-utils';
3
3
  import { pluralPattern } from 'wuchale/adapter-vanilla';
4
4
  import { SvelteTransformer } from './transformer.js';
@@ -40,7 +40,7 @@ export const svelteDefaultHeuristicDerivedReq = msg => {
40
40
  };
41
41
  export const defaultArgs = {
42
42
  files: ['src/**/*.svelte', 'src/**/*.svelte.{js,ts}'],
43
- localesDir: './src/locales',
43
+ storage: pofile(),
44
44
  patterns: [pluralPattern],
45
45
  heuristic: svelteKitDefaultHeuristic,
46
46
  granularLoad: false,
@@ -1,5 +1,6 @@
1
1
  import MagicString from 'magic-string';
2
2
  import { parse, preprocess } from 'svelte/compiler';
3
+ import { getKey } from 'wuchale';
3
4
  import { MixedVisitor, nonWhitespaceText, varNames } from 'wuchale/adapter-utils';
4
5
  import { parseScript, Transformer } from 'wuchale/adapter-vanilla';
5
6
  const nodesWithChildren = ['RegularElement', 'Component'];
@@ -96,7 +97,7 @@ export class SvelteTransformer extends Transformer {
96
97
  begin += `{${this.vars().nestCtx}} n`;
97
98
  }
98
99
  else {
99
- const index = this.index.get(msgInfo.toKey());
100
+ const index = this.index.get(getKey(msgInfo.msgStr, msgInfo.context));
100
101
  begin += `{${this.vars().rtCtx}(${index})}`;
101
102
  }
102
103
  let end = ' />\n';
@@ -137,7 +138,7 @@ export class SvelteTransformer extends Transformer {
137
138
  if (!pass) {
138
139
  return [];
139
140
  }
140
- this.mstr.update(node.start + startWh, node.end - endWh, `{${this.vars().rtTrans}(${this.index.get(msgInfo.toKey())})}`);
141
+ this.mstr.update(node.start + startWh, node.end - endWh, `{${this.vars().rtTrans}(${this.index.get(getKey(msgInfo.msgStr, msgInfo.context))})}`);
141
142
  return [msgInfo];
142
143
  };
143
144
  visitSpreadAttribute = (node) => this.visit(node.expression);
@@ -184,7 +185,7 @@ export class SvelteTransformer extends Transformer {
184
185
  if (!pass) {
185
186
  return [];
186
187
  }
187
- this.mstr.update(value.start, value.end, `{${this.vars().rtTrans}(${this.index.get(msgInfo.toKey())})}`);
188
+ this.mstr.update(value.start, value.end, `{${this.literalRepl(msgInfo)}}`);
188
189
  if (`'"`.includes(this.content[value.start - 1])) {
189
190
  this.mstr.remove(value.start - 1, value.start);
190
191
  this.mstr.remove(value.end, value.end + 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuchale/svelte",
3
- "version": "0.18.2",
3
+ "version": "0.19.0",
4
4
  "description": "Protobuf-like i18n from plain code: Svelte adapter",
5
5
  "scripts": {
6
6
  "dev": "tsc --watch",
@@ -52,11 +52,11 @@
52
52
  "license": "MIT",
53
53
  "dependencies": {
54
54
  "magic-string": "^0.30.21",
55
- "svelte": "^5.53.1",
56
- "wuchale": "^0.20.0"
55
+ "svelte": "^5",
56
+ "wuchale": "^0.21.0"
57
57
  },
58
58
  "devDependencies": {
59
- "acorn": "^8.15.0",
59
+ "acorn": "^8.16.0",
60
60
  "typescript": "^5.9.3"
61
61
  },
62
62
  "type": "module"
@@ -4,7 +4,7 @@ import { locales } from '${DATA}'
4
4
  let locale = $state(locales[0])
5
5
 
6
6
  /**
7
- * @param {string} newLocale
7
+ * @param {import('${DATA}').Locale} newLocale
8
8
  */
9
9
  export function setLocale(newLocale) {
10
10
  locale = newLocale