lingui-po-translate 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.
|
@@ -8,11 +8,13 @@ exports.hasManualMarking = exports.shouldSkipForManual = exports.parseExtractedC
|
|
|
8
8
|
* - @manual:zh-Hans,zh-Hant - languages requiring manual translation
|
|
9
9
|
* - @context:text - context for AI translation
|
|
10
10
|
* - Plain text (without @) - also treated as context
|
|
11
|
+
* - Multiple directives can be separated by ; or newline
|
|
11
12
|
*
|
|
12
13
|
* Example:
|
|
14
|
+
* #. @manual:zh-Hans; @context:This is a save button
|
|
15
|
+
* Or:
|
|
13
16
|
* #. @manual:zh-Hans
|
|
14
17
|
* #. @context:This is a save button
|
|
15
|
-
* #. Some additional context
|
|
16
18
|
*
|
|
17
19
|
* @param extracted - The extracted comment string from PO file
|
|
18
20
|
* @returns ParsedComment with manual languages and context
|
|
@@ -25,30 +27,38 @@ function parseExtractedComment(extracted) {
|
|
|
25
27
|
if (!extracted) {
|
|
26
28
|
return result;
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
// Split by newline first, then by ; for each line
|
|
31
|
+
const parts = [];
|
|
32
|
+
for (const line of extracted.split("\n")) {
|
|
33
|
+
for (const part of line.split(";")) {
|
|
34
|
+
const trimmed = part.trim();
|
|
35
|
+
if (trimmed) {
|
|
36
|
+
parts.push(trimmed);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
29
40
|
const contextParts = [];
|
|
30
|
-
for (const
|
|
31
|
-
|
|
32
|
-
if (trimmedLine.startsWith("@manual:")) {
|
|
41
|
+
for (const part of parts) {
|
|
42
|
+
if (part.startsWith("@manual:")) {
|
|
33
43
|
// Parse @manual:zh-Hans,zh-Hant
|
|
34
|
-
const langList =
|
|
44
|
+
const langList = part.substring("@manual:".length).trim();
|
|
35
45
|
if (langList) {
|
|
36
46
|
result.manual = langList.split(",").map((lang) => lang.trim()).filter(Boolean);
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
|
-
else if (
|
|
49
|
+
else if (part.startsWith("@context:")) {
|
|
40
50
|
// Parse @context:text
|
|
41
|
-
const contextText =
|
|
51
|
+
const contextText = part.substring("@context:".length).trim();
|
|
42
52
|
if (contextText) {
|
|
43
53
|
contextParts.push(contextText);
|
|
44
54
|
}
|
|
45
55
|
}
|
|
46
|
-
else if (
|
|
56
|
+
else if (!part.startsWith("@")) {
|
|
47
57
|
// Plain text without @ prefix is also context
|
|
48
|
-
contextParts.push(
|
|
58
|
+
contextParts.push(part);
|
|
49
59
|
}
|
|
50
60
|
}
|
|
51
|
-
result.context = contextParts.join("
|
|
61
|
+
result.context = contextParts.join(" ");
|
|
52
62
|
return result;
|
|
53
63
|
}
|
|
54
64
|
exports.parseExtractedComment = parseExtractedComment;
|