-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathi18n.node.php
More file actions
49 lines (32 loc) · 1.27 KB
/
i18n.node.php
File metadata and controls
49 lines (32 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// load WordPress
require_once __DIR__ . '/../../../wp-load.php';
$jsSourceStrings = require_once 'translationStrings.php';
require_once __DIR__ . '/app/Services/TransStrings.php';
$manualStrings = \FluentCrm\App\Services\TransStrings::getStrings();
$newStrings = [];
foreach ($jsSourceStrings as $key => $value) {
if (!isset($manualStrings[$key])) {
$manualStrings[$key] = $value;
}
}
// short the $manualStrings
ksort($manualStrings);
// print as php array
$string = "<?php\n\nnamespace FluentCrm\App\Services;\n\n//This is an auto-generated file. Please do not edit manually\nclass TransStrings\n{\n\n public static function getStrings()\n {\n";
$string .= "return [\n";
foreach ($manualStrings as $key => $value) {
// escape single quote
if(is_string($value) && strpos($value, "'") !== false) {
$value = str_replace("\'", "'", $value);
$value = str_replace("'", "\'", $value);
}
if(is_string($key) && strpos($key, "'") !== false) {
$key = str_replace("\'", "'", $key);
$key = str_replace("'", "\'", $key);
}
$string .= " '$key' => __('$value', 'fluent-crm'),\n";
}
$string .= "];\n }\n\n}\n";
// save the string in all-translations.php file
file_put_contents(__DIR__ . '/transStrings.php', $string);