@l10nmonster/helpers-json 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/i18next.js +19 -17
  2. package/package.json +1 -1
package/i18next.js CHANGED
@@ -55,26 +55,28 @@ exports.Filter = class I18nextFilter {
55
55
  }
56
56
 
57
57
  async parseResource({ resource }) {
58
- const segments = [];
59
- if (!resource) {
60
- return { segments };
58
+ const response = {
59
+ segments: []
61
60
  }
62
- const [ parsedResource, notes ] = parseResourceAnnotations(
63
- JSON.parse(resource),
64
- this.enableArbAnnotations,
65
- this.arbAnnotationHandlers,
66
- );
67
- for (const [key, value] of parsedResource) {
68
- let seg = { sid: key, str: value };
69
- notes[key] && (seg.notes = notes[key]);
70
- if (this.enablePluralSuffixes && key.indexOf('_') !== -1 && validPluralSuffixes.has(key.split('_').slice(-1)[0])) {
71
- seg.isSuffixPluralized = true;
61
+ if (resource) {
62
+ const unParsedResource = JSON.parse(resource);
63
+ const targetLangs = unParsedResource['@@targetLocales'];
64
+ Array.isArray(targetLangs) && (response.targetLangs = targetLangs);
65
+ const [ parsedResource, notes ] = parseResourceAnnotations(
66
+ unParsedResource,
67
+ this.enableArbAnnotations,
68
+ this.arbAnnotationHandlers,
69
+ );
70
+ for (const [key, value] of parsedResource) {
71
+ let seg = { sid: key, str: value };
72
+ notes[key] && (seg.notes = notes[key]);
73
+ if (this.enablePluralSuffixes && key.indexOf('_') !== -1 && validPluralSuffixes.has(key.split('_').slice(-1)[0])) {
74
+ seg.isSuffixPluralized = true;
75
+ }
76
+ response.segments.push(seg);
72
77
  }
73
- segments.push(seg);
74
78
  }
75
- return {
76
- segments,
77
- };
79
+ return response;
78
80
  }
79
81
 
80
82
  async translateResource({ resource, translator }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@l10nmonster/helpers-json",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Helpers to deal with JSON file formats",
5
5
  "main": "index.js",
6
6
  "scripts": {