google-spreadsheet-translation-sync 1.5.3 → 1.5.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.
- package/package.json +1 -1
- package/src/handlers/wordpress.js +3 -2
- package/src/util/string-utils.js +3 -0
- package/test/data/wp-expected-en.txt +23 -0
- package/test/test.js +2 -22
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
const withoutError = require('../helpers').withoutError
|
|
5
5
|
const gettextParser = require("gettext-parser");
|
|
6
6
|
const constraints = require('../util/constraints');
|
|
7
|
+
const stringUtils = require('../util/string-utils');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
module.exports.loadTranslationFile = function (filePath, callback) {
|
|
@@ -133,14 +134,14 @@ module.exports.updateTranslations = function (translationData, translationRootFo
|
|
|
133
134
|
phpContent += 'return [\n';
|
|
134
135
|
|
|
135
136
|
Object.keys(parsedObj.headers).forEach((header) => {
|
|
136
|
-
phpContent += `
|
|
137
|
+
phpContent += ` '${stringUtils.escapeSingleQuotes(header.toLocaleLowerCase())}' => '${stringUtils.escapeSingleQuotes(parsedObj.headers[header])}',\n`;
|
|
137
138
|
})
|
|
138
139
|
|
|
139
140
|
phpContent += ` "messages" => [\n`;
|
|
140
141
|
|
|
141
142
|
Object.keys(parsedObj.translations['']).forEach((key) => {
|
|
142
143
|
if (key) {
|
|
143
|
-
phpContent += `
|
|
144
|
+
phpContent += ` '${stringUtils.escapeSingleQuotes(key)}' => '${stringUtils.escapeSingleQuotes(parsedObj.translations[''][key].msgstr[0])}',\n`;
|
|
144
145
|
}
|
|
145
146
|
});
|
|
146
147
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
return [
|
|
3
|
+
'content-type' => 'text/plain; charset=utf-8',
|
|
4
|
+
'plural-forms' => 'nplurals=2; plural=(n!=1);',
|
|
5
|
+
'x-generator' => 'node-google-spreadsheet-translation-sync',
|
|
6
|
+
'project-id-version' => 'karmapa-chenno',
|
|
7
|
+
'language' => 'en',
|
|
8
|
+
"messages" => [
|
|
9
|
+
'add_address' => 'Add new address',
|
|
10
|
+
'add_as_favourite' => 'Add to Quick Contacts',
|
|
11
|
+
'add_center' => 'Add Center',
|
|
12
|
+
'add_contact' => 'Add contact',
|
|
13
|
+
'add_phone_number' => 'Add new phone',
|
|
14
|
+
'additional.news' => 'Additional News',
|
|
15
|
+
'administration' => 'Administration',
|
|
16
|
+
'administration_info' => 'This page allows you to access functions connected to Members, Centers, Roles and Groups.',
|
|
17
|
+
'all' => 'All',
|
|
18
|
+
'all_centers' => 'All Centers',
|
|
19
|
+
'all_contacts' => 'All contacts',
|
|
20
|
+
'key_with_special_chars' => 'Test \'quote\' or "quote"',
|
|
21
|
+
'some.key' => 'a Key 370',
|
|
22
|
+
]
|
|
23
|
+
];
|
package/test/test.js
CHANGED
|
@@ -411,29 +411,9 @@ const tests = [
|
|
|
411
411
|
expect(translationsPl.add_address).to.be.undefined;
|
|
412
412
|
|
|
413
413
|
const phpContent = fs.readFileSync(testFilePhp).toString();
|
|
414
|
+
const expectedContent = fs.readFileSync(path.resolve('./test/data/wp-expected-en.txt')).toString();
|
|
414
415
|
|
|
415
|
-
expect(phpContent).to.equal(
|
|
416
|
-
'return [\n' +
|
|
417
|
-
' "content-type" => "text/plain; charset=utf-8",\n' +
|
|
418
|
-
' "plural-forms" => "nplurals=2; plural=(n!=1);",\n' +
|
|
419
|
-
' "x-generator" => "node-google-spreadsheet-translation-sync",\n' +
|
|
420
|
-
' "project-id-version" => "karmapa-chenno",\n' +
|
|
421
|
-
' "language" => "en",\n' +
|
|
422
|
-
' "messages" => [\n' +
|
|
423
|
-
' "add_address" => "Add new address",\n' +
|
|
424
|
-
' "add_as_favourite" => "Add to Quick Contacts",\n' +
|
|
425
|
-
' "add_center" => "Add Center",\n' +
|
|
426
|
-
' "add_contact" => "Add contact",\n' +
|
|
427
|
-
' "add_phone_number" => "Add new phone",\n' +
|
|
428
|
-
' "additional.news" => "Additional News",\n' +
|
|
429
|
-
' "administration" => "Administration",\n' +
|
|
430
|
-
' "administration_info" => "This page allows you to access functions connected to Members, Centers, Roles and Groups.",\n' +
|
|
431
|
-
' "all" => "All",\n' +
|
|
432
|
-
' "all_centers" => "All Centers",\n' +
|
|
433
|
-
' "all_contacts" => "All contacts",\n' +
|
|
434
|
-
' "some.key" => "a Key 370",\n' +
|
|
435
|
-
' ]\n' +
|
|
436
|
-
'];\n');
|
|
416
|
+
expect(phpContent).to.equal(expectedContent);
|
|
437
417
|
|
|
438
418
|
}
|
|
439
419
|
|