-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathmakephp.feature
More file actions
402 lines (363 loc) · 13.4 KB
/
Copy pathmakephp.feature
File metadata and controls
402 lines (363 loc) · 13.4 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
Feature: Generate PHP files from PO files
Background:
Given an empty directory
Scenario: Bail for invalid source directories
When I try `wp i18n make-php foo`
Then STDERR should contain:
"""
Error: Source file or directory does not exist.
"""
And the return code should be 1
Scenario: Uses source folder as destination by default
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin-de_DE.po file:
"""
# Copyright (C) 2018 Foo Plugin
# This file is distributed under the same license as the Foo Plugin package.
msgid ""
msgstr ""
"Project-Id-Version: Foo Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-05-02T22:06:24+00:00\n"
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
"X-Domain: foo-plugin\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: foo-plugin.js:15
msgid "Foo Plugin"
msgstr "Foo Plugin"
"""
When I run `wp i18n make-php foo-plugin`
Then STDOUT should contain:
"""
Success: Created 1 file.
"""
And the return code should be 0
And the foo-plugin/foo-plugin-de_DE.l10n.php file should exist
Scenario: Allows setting custom destination directory
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin-de_DE.po file:
"""
# Copyright (C) 2018 Foo Plugin
# This file is distributed under the same license as the Foo Plugin package.
msgid ""
msgstr ""
"Project-Id-Version: Foo Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-05-02T22:06:24+00:00\n"
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
"X-Domain: foo-plugin\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: foo-plugin.js:15
msgid "Foo Plugin"
msgstr "Foo Plugin"
"""
When I run `wp i18n make-php foo-plugin result`
Then STDOUT should contain:
"""
Success: Created 1 file.
"""
And the return code should be 0
And the result/foo-plugin-de_DE.l10n.php file should exist
Scenario: Does include headers
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin-de_DE.po file:
"""
# Translation of 5.2.x in German
# This file is distributed under the same license as the 5.2.x package.
msgid ""
msgstr ""
"PO-Revision-Date: 2019-03-28 19:42+0300\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Poedit 2.2.1\n"
"Project-Id-Version: Development (5.2.x)\n"
"Language: de_DE\n"
"POT-Creation-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
#. translators: Translate this to the correct language tag for your locale, see
#. https://www.w3.org/International/articles/language-tags/ for reference. Do
#. not translate into your own language.
#: wp-includes/general-template.php:716
msgid "html_lang_attribute"
msgstr "de-DE"
#. translators: 'rtl' or 'ltr'. This sets the text direction for WordPress.
#: wp-includes/class-wp-locale.php:223
msgctxt "text direction"
msgid "ltr"
msgstr "ltr"
#. translators: $dec_point argument for https://secure.php.net/number_format,
#. default is .
#: wp-includes/class-wp-locale.php:215
msgid "number_format_decimal_point"
msgstr ","
#. translators: $thousands_sep argument for
#. https://secure.php.net/number_format, default is ,
#: wp-includes/class-wp-locale.php:202
msgid "number_format_thousands_sep"
msgstr "."
#. translators: %s: Plugin name and version
#: wp-includes/script-loader.php:620
msgid "Update %s now"
msgstr "Jetzt %s aktualisieren"
#. translators: Privacy data request subject. 1: Site name, 2: Name of the action
#: wp-includes/user.php:3445
msgid "[%1$s] Confirm Action: %2$s"
msgstr "[%1$s] Aktion bestätigen: %2$s"
#. translators: %s: Site name.
#: wp-includes/user.php:3175
msgid "[%s] Erasure Request Fulfilled"
msgstr "[%s] Löschauftrag ausgeführt"
#: wp-admin/includes/file.php:2415
msgid "[%s] Personal Data Export"
msgstr "[%s] Export personenbezogener Daten"
"""
When I run `wp i18n make-php foo-plugin`
Then STDOUT should contain:
"""
Success: Created 1 file.
"""
And the return code should be 0
And STDERR should be empty
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
"""
return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=n != 1;','language'=>'de_DE','project-id-version'=>'Development (5.2.x)','pot-creation-date'=>'','po-revision-date'=>'2019-03-28 19:42+0300','x-generator'=>'Poedit 2.2.1','messages'=>['html_lang_attribute'=>'de-DE','text directionltr'=>'ltr','number_format_decimal_point'=>',','number_format_thousands_sep'=>'.','Update %s now'=>'Jetzt %s aktualisieren','[%1$s] Confirm Action: %2$s'=>'[%1$s] Aktion bestätigen: %2$s','[%s] Erasure Request Fulfilled'=>'[%s] Löschauftrag ausgeführt','[%s] Personal Data Export'=>'[%s] Export personenbezogener Daten']];
"""
Scenario: Does include translations
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin-de_DE.po file:
"""
# Copyright (C) 2018 Foo Plugin
# This file is distributed under the same license as the Foo Plugin package.
msgid ""
msgstr ""
"Project-Id-Version: Foo Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-05-02T22:06:24+00:00\n"
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
"X-Domain: foo-plugin\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: foo-plugin.js:15
msgctxt "Plugin Name"
msgid "Foo Plugin (EN)"
msgstr "Foo Plugin (DE)"
#: foo-plugin.js:15
msgid "Foo Plugin"
msgstr "Bar Plugin"
#: foo-plugin.php:60
msgid "You have %d new message"
msgid_plural "You have %d new messages"
msgstr[0] "Sie haben %d neue Nachricht"
msgstr[1] "Sie haben %d neue Nachrichten"
"""
When I run `wp i18n make-php foo-plugin`
Then STDOUT should contain:
"""
Success: Created 1 file.
"""
And the return code should be 0
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
"""
You have %d new message
"""
And the foo-plugin/foo-plugin-de_DE.l10n.php file should not contain:
"""
Foo Plugin (DE)
"""
And the foo-plugin/foo-plugin-de_DE.l10n.php file should not contain:
"""
Bar Plugin
"""
Scenario: Excludes strings without translations
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin-de_DE.po file:
"""
# Copyright (C) 2018 Foo Plugin
# This file is distributed under the same license as the Foo Plugin package.
msgid ""
msgstr ""
"Project-Id-Version: Foo Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-05-02T22:06:24+00:00\n"
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
"X-Domain: foo-plugin\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: foo-plugin.php:10
msgid "I exist"
msgstr "I exist (DE)"
#: foo-plugin.php:20
msgid "I am empty"
msgstr ""
#: foo-plugin.php:30
msgid "You have %d new message"
msgid_plural "You have %d new messages"
msgstr[0] ""
msgstr[1] ""
"""
When I run `wp i18n make-php foo-plugin`
Then STDOUT should contain:
"""
Success: Created 1 file.
"""
And the return code should be 0
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
"""
I exist
"""
And the foo-plugin/foo-plugin-de_DE.l10n.php file should not contain:
"""
I am empty
"""
And the foo-plugin/foo-plugin-de_DE.l10n.php file should not contain:
"""
new message
"""
Scenario: Should create pretty-printed PHP files
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin-de_DE.po file:
"""
# Copyright (C) 2018 Foo Plugin
# This file is distributed under the same license as the Foo Plugin package.
msgid ""
msgstr ""
"Project-Id-Version: Foo Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-05-02T22:06:24+00:00\n"
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
"X-Domain: foo-plugin\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: foo-plugin.php:15
msgid "Foo Plugin"
msgstr "Bar Plugin"
"""
When I run `wp i18n make-php foo-plugin --pretty-print`
Then STDOUT should contain:
"""
Success: Created 1 file.
"""
And the return code should be 0
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
"""
'domain' => 'foo-plugin',
"""
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
"""
'messages' => [
"""
Scenario: Excludes JS-only strings from PHP files
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin-de_DE.po file:
"""
# Copyright (C) 2018 Foo Plugin
# This file is distributed under the same license as the Foo Plugin package.
msgid ""
msgstr ""
"Project-Id-Version: Foo Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-05-02T22:06:24+00:00\n"
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
"X-Domain: foo-plugin\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: foo-plugin.js:15
msgid "JS Only String"
msgstr "JS Only Translation"
#: foo-plugin.php:10
msgid "PHP String"
msgstr "PHP Translation"
#: foo-plugin.js:20
#: foo-plugin.php:15
msgid "Both JS and PHP"
msgstr "Both Translation"
"""
When I run `wp i18n make-php foo-plugin`
Then STDOUT should contain:
"""
Success: Created 1 file.
"""
And the return code should be 0
And the foo-plugin/foo-plugin-de_DE.l10n.php file should exist
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
"""
PHP Translation
"""
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
"""
Both Translation
"""
And the foo-plugin/foo-plugin-de_DE.l10n.php file should not contain:
"""
JS Only Translation
"""
Scenario: Should create valid PHP files with pretty-print when there are no translations
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin-de_DE.po file:
"""
# Copyright (C) 2018 Foo Plugin
# This file is distributed under the same license as the Foo Plugin package.
msgid ""
msgstr ""
"Project-Id-Version: Foo Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-05-02T22:06:24+00:00\n"
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
"X-Domain: foo-plugin\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"""
When I run `wp i18n make-php foo-plugin --pretty-print`
Then STDOUT should contain:
"""
Success: Created 1 file.
"""
And the return code should be 0
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
"""
'messages' => [],
"""
And the foo-plugin/foo-plugin-de_DE.l10n.php file should not contain:
"""
[,
"""