Skip to content

Commit

Permalink
Update: Make unit translateable
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto committed Feb 1, 2024
1 parent 9ce91b0 commit 01a9436
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions Resources/Private/RangeEditor/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function Editor(props, second) {
const numLength = (value) => value.toString().length;
const additionalStepLength = numLength(options.step) - 1;
const styleWidth = Math.max(numLength(options.min), numLength(options.max)) + additionalStepLength + "ch";
const unit = options.unit ? i18nRegistry.translate(options.unit) : "";

const { valueLabels, valueLabelsFile } = options;
const showMiddle = between(value, options.min, options.max);
Expand All @@ -70,11 +71,11 @@ function Editor(props, second) {

const getLabel = (value) => {
if (value <= options.min) {
const label = options.minLabel || getValueLabel(options.min) || options.min + options.unit;
const label = options.minLabel || getValueLabel(options.min) || options.min + unit;
return i18nRegistry.translate(label);
}
if (value >= options.max) {
const label = options.maxLabel || getValueLabel(options.max) || options.max + options.unit;
const label = options.maxLabel || getValueLabel(options.max) || options.max + unit;
return i18nRegistry.translate(label);
}
return i18nRegistry.translate(getValueLabel(value));
Expand Down Expand Up @@ -117,7 +118,7 @@ function Editor(props, second) {
style={{ width: styleWidth }}
disabled={options.disabled}
/>
{options.unit}
{unit}
</span>
)}
<button
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/Plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 01a9436

Please sign in to comment.