Skip to content

Commit 4f16229

Browse files
committed
Improve range formatting
1 parent 7032a00 commit 4f16229

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

src/i18n/I18N.php

+3
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ public function translate($category, $message, $params, $language)
350350
}
351351
}
352352

353+
// Normalize ranges to use thin spaces and en-dashes (see https://clagnut.com/blog/2419)
354+
$translation = preg_replace('/(?<=\d) ?(?:-|–|—) ?(?=\d)/', ' – ', $translation);
355+
353356
if ($this->_shouldAddTranslationDebugOutput()) {
354357
switch ($category) {
355358
case 'site':

src/web/assets/cp/dist/cp.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/dist/cp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/src/js/Craft.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ $.extend(Craft, {
8383
}
8484

8585
if (params) {
86-
return this.formatMessage(message, params);
86+
message = this.formatMessage(message, params);
8787
}
8888

89-
return message;
89+
// Normalize ranges to use thin spaces and en-dashes (see https://clagnut.com/blog/2419)
90+
return message.replace(/(\d) ?(?:-||) ?(\d)/, '$1 – $2', message);
9091
},
9192

9293
formatMessage: function (pattern, args) {

0 commit comments

Comments
 (0)