Skip to content

Commit a17b40c

Browse files
author
Michiel Verkoijen
committed
Add plugin page description translation. Move free compression constant to config. Simplify size_format display and add   to units.
1 parent f56e088 commit a17b40c

11 files changed

Lines changed: 35 additions & 31 deletions

src/class-tiny-compress-fopen.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function shrink_options($input) {
3131
'content' => $input,
3232
'follow_location' => 0,
3333
'max_redirects' => 1, // Necessary for PHP 5.2
34-
'ignore_errors' => TRUE // Apparently, a 201 is a failure :'(
34+
'ignore_errors' => true // Apparently, a 201 is a failure
3535
),
3636
'ssl' => array(
3737
'cafile' => self::get_ca_file(),

src/class-tiny-settings.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
class Tiny_Settings extends Tiny_WP_Base {
2222
const DUMMY_SIZE = '_tiny_dummy';
23-
const MONTHLY_FREE_COMPRESSIONS = 500;
2423

2524
private $sizes;
2625
private $tinify_sizes;
@@ -267,7 +266,7 @@ public function render_image_sizes_notice($active_image_sizes_count, $resize_ori
267266
if ($active_image_sizes_count < 1) {
268267
echo self::translate_escape('With these settings no images will be compressed') . '.';
269268
} else {
270-
$free_images_per_month = floor(self::MONTHLY_FREE_COMPRESSIONS / $active_image_sizes_count);
269+
$free_images_per_month = floor( Tiny_Config::MONTHLY_FREE_COMPRESSIONS / $active_image_sizes_count );
271270
echo self::translate_escape('With these settings you can compress');
272271
echo ' <strong>';
273272
printf(self::translate_escape('at least %s images'), $free_images_per_month);
@@ -290,7 +289,7 @@ public function render_total_savings() {
290289

291290
echo '<p>';
292291
if ($total_savings > 0) {
293-
printf(self::translate_escape("You have saved a total of %s on images") . '!', '<strong>' . size_format($total_savings, 1) . '</strong>');
292+
printf( self::translate_escape( "You have saved a total of %s on images") . '!', '<strong>' . size_format( $total_savings ) . '</strong>' );
294293
} else {
295294
$link = '<a href="upload.php?page=tiny-bulk-compress">' . self::translate_escape('Compress All Images') . '</a>';
296295
printf(self::translate_escape('No images compressed yet. Use %s to compress existing images') . '.', $link);
@@ -381,12 +380,11 @@ public function render_status() {
381380
}
382381
}
383382
echo '</p>';
384-
385383
if ($status) {
386384
$compressions = self::get_compression_count();
387385
echo '<p>';
388386
// It is not possible to check if a subscription is free or flexible.
389-
if ($compressions == self::MONTHLY_FREE_COMPRESSIONS) {
387+
if ( $compressions == Tiny_Config::MONTHLY_FREE_COMPRESSIONS ) {
390388
$link = '<a href="https://tinypng.com/developers" target="_blank">' . self::translate_escape('TinyPNG API account') . '</a>';
391389
printf(self::translate_escape('You have reached your limit of %s compressions this month') . '.', $compressions);
392390
echo '<br>';

src/config/tiny-config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
class Tiny_Config {
44
const URL = 'https://api.tinify.com/shrink';
5+
const MONTHLY_FREE_COMPRESSIONS = 500;
56
}
183 Bytes
Binary file not shown.

src/languages/tiny-compress-images-nl_NL.po

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
msgid "Speed up your website. Optimize your JPEG and PNG images automatically with TinyPNG."
2+
msgstr "Maak je website sneller. Optimaliseer alle JPEG en PNG afbeeldingen automatisch met TinyPNG."
3+
14
msgid "PNG and JPEG compression"
25
msgstr "PNG- en JPEG-compressie"
36

@@ -73,17 +76,17 @@ msgstr "(verkleind naar %dx%d)"
7376
msgid "(modified after compression)"
7477
msgstr "(veranderd na compressie)"
7578

76-
msgid "(missing)"
77-
msgstr "(bestand mist)"
79+
msgid "(file missing)"
80+
msgstr "(bestand ontbreekt)"
7881

7982
msgid "ago"
8083
msgstr "geleden"
8184

8285
msgid "Combined"
8386
msgstr "Gecombineerd"
8487

85-
msgid "Total savings"
86-
msgstr "Totaal bespaard"
88+
msgid "Total savings %s"
89+
msgstr "Totaal bespaard %s"
8790

8891
msgid "size being compressed"
8992
msgstr "afmeting wordt gecomprimeerd"
@@ -94,11 +97,11 @@ msgstr "afmetingen worden gecomprimeerd"
9497
msgid "Total size"
9598
msgstr "Totale grootte"
9699

97-
msgid "Original size"
98-
msgstr "Originele grootte"
100+
msgid "Original"
101+
msgstr "Origineel"
99102

100-
msgid "Compressed size"
101-
msgstr "Gecomprimeerde grootte"
103+
msgid "Compressed"
104+
msgstr "Gecomprimeerd"
102105

103106
msgid "Latest error"
104107
msgstr "Laatste fout"
210 Bytes
Binary file not shown.

src/languages/tiny-compress-images-ru_RU.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ msgstr ""
1313
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
1414
"Language: ru_RU\n"
1515

16+
msgid "Speed up your website. Optimize your JPEG and PNG images automatically with TinyPNG."
17+
msgstr "Speed up your website. Optimize your JPEG and PNG images automatically with TinyPNG."
18+
1619
msgid "PNG and JPEG compression"
1720
msgstr "Сжатие PNG и JPEG"
1821

186 Bytes
Binary file not shown.

src/languages/tiny-compress-images-zh_TW.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ msgstr ""
1212
"Plural-Forms: nplurals=1; plural=0;\n"
1313
"Language: zh_TW\n"
1414

15+
msgid "Speed up your website. Optimize your JPEG and PNG images automatically with TinyPNG."
16+
msgstr "Speed up your website. Optimize your JPEG and PNG images automatically with TinyPNG."
17+
1518
msgid "PNG and JPEG compression"
1619
msgstr "PNG 和 JPEG 壓縮"
1720

src/views/compress-details.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<?php if ($savings["input"] - $savings["output"]) { ?>
4444
<span class="message">
45-
<?php echo self::translate_escape('Total savings') ?>&nbsp;<?php echo size_format($savings["input"] - $savings["output"], 1) ?>
45+
<?php printf( self::translate_escape( 'Total savings %s' ), str_replace( " ", "&nbsp;", size_format( $savings["input"] - $savings["output"] ) ) ) ?>
4646
</span>
4747
<br />
4848
<?php } ?>
@@ -72,8 +72,8 @@
7272
<table>
7373
<tr>
7474
<th><?php echo self::translate_escape('Size') ?></th>
75-
<th><?php echo self::translate_escape('Original size') ?></th>
76-
<th><?php echo self::translate_escape('Compressed size') ?></th>
75+
<th><?php echo self::translate_escape('Original') ?></th>
76+
<th><?php echo self::translate_escape('Compressed') ?></th>
7777
<th><?php echo self::translate_escape('Date') ?></th>
7878
</tr>
7979
<?php $i = 0; ?>
@@ -82,26 +82,22 @@
8282
<tr class="<?php echo ($i % 2 == 0) ? 'even' : 'odd' ?>">
8383
<td>
8484
<?php
85-
if ($size == "0") {
86-
echo 'original';
87-
} else {
88-
echo $size;
89-
}
85+
echo ($size == "0" ? self::translate_escape('original') : $size ) . ' ';
9086
if ($tiny_metadata->still_exists($size)) {
9187
if ($tiny_metadata->is_compressed($size)) {
9288
if ($tiny_metadata->is_resized($size)) {
93-
?><em>&nbsp;<?php printf(self::translate_escape('(resized to %dx%d)'), $meta['output']['width'], $meta['output']['height']) ?></em><?php
89+
printf('<em>' . self::translate_escape('(resized to %dx%d)') . '</em>', $meta['output']['width'], $meta['output']['height']);
9490
}
9591
} else {
96-
?><em>&nbsp;<?php echo self::translate_escape('(modified after compression)') ?></em><?php
92+
echo '<em>' . self::translate_escape('(modified after compression)') . '</em>';
9793
}
9894
} else {
99-
?><em>&nbsp;<?php echo self::translate_escape('(missing)') ?></em><?php
95+
echo '<em>' . self::translate_escape('(file missing)') . '</em>';
10096
}
10197
?>
10298
</td>
103-
<td><?php echo size_format($meta["input"]["size"], 1) ?></td>
104-
<td><?php echo size_format($meta["output"]["size"], 1) ?></td>
99+
<td><?php echo size_format( $meta["input"]["size"] ) ?></td>
100+
<td><?php echo size_format( $meta["output"]["size"] ) ?></td>
105101
<td><?php echo human_time_diff($tiny_metadata->get_end_time($size)) . ' ' . self::translate_escape('ago') ?></td>
106102
</tr>
107103
<?php $i++; ?>
@@ -110,15 +106,14 @@
110106
<tfoot>
111107
<tr>
112108
<td><?php echo self::translate_escape('Combined') ?></td>
113-
<td><?php echo size_format($savings['input'], 1) ?></td>
114-
<td><?php echo size_format($savings['output'], 1) ?></td>
109+
<td><?php echo size_format( $savings['input'] ) ?></td>
110+
<td><?php echo size_format( $savings['output'] ) ?></td>
115111
<td></td>
116112
</tr>
117113
</tfoot>
118114
<?php } ?>
119115
</table>
120-
121-
<p><strong><?php printf(self::translate_escape('Total savings %s'), size_format($savings["input"] - $savings["output"], 1)) ?></strong></p>
116+
<p><strong><?php printf( self::translate_escape( 'Total savings %s' ), size_format( $savings["input"] - $savings["output"] ) ) ?></strong></p>
122117
</div>
123118
</div>
124119
<?php } ?>

0 commit comments

Comments
 (0)