-
Notifications
You must be signed in to change notification settings - Fork 0
/
2-import-dutch.php
89 lines (73 loc) · 1.88 KB
/
2-import-dutch.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
// DEPRECATED: Use extract-language.php instead.
// Scripts to migrate E. J. Klein Velderman's Lex translation system to GNU gettext.
// Phase II: Import Dutch translations
// WORK IN PROGRESS: part 3 below is not complete!
// 1: Scan English strings
// Include the English language file, extract all globals and place them in a hash.
// 2: Scan Dutch strings
// Include the Dutch language file, and put all translations in the same hash.
// 3: Output them to a prepared .po file.
// Fix up constants manually.
$pofilename = "includes/lang/nl_NL/LC_MESSAGES/nl.po";
// Scan all English strings
include("includes/lang/inc.US_lang.php");
foreach ($GLOBALS as $key => $string)
{
if (strpos($key, "lng") === 0)
{
$strings[$key]['eng'] = $string;
// Unset to make sure no English strings are mistaken for Dutch strings
unset($$key);
}
}
// Scan all Dutch strings
error_reporting(E_ALL ^ E_NOTICE); // Squelch warning about redefined constants
include("includes/lang/inc.NL_lang.php");
error_reporting(E_ALL);
foreach ($GLOBALS as $key => $string)
{
if (strpos($key, "lng") === 0)
{
$strings[$key]['nl'] = $string;
}
}
echo "Strings with missing translations:\n";
$missing = 0;
foreach ($strings as $key => $string)
{
if (count($string) < 2)
{
echo "\n\$$key:\n";
print_r($string);
$missing++;
}
}
if ($missing > 0)
{
echo "\nPlease add missing strings and rerun the script.\n";
exit(1);
}
else
{
echo "None; all is well.\n";
}
// Import the prepared .po file
$pofile = file_get_contents($pofilename);
$progress['count'] = count($strings);
$progress['current'] = 0;
$progress['width'] = 80;
foreach ($strings as $key => $string)
{
$progress['current']++;
// Find the English string
$eng_pos = strpos($pofile, "msgid \"". $string['eng'] ."\"");
if ($eng_pos === false)
{
echo "\nDid not find $". $key .": \"". $string['eng'] ."\"\n";
}
else
echo "=";
}
echo "\n";
?>