Skip to content

Commit 8b67d4c

Browse files
committed
Make translation of custom file input text easier; fixes #18922
[skip sauce]
1 parent 27596f4 commit 8b67d4c

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

scss/_custom-forms.scss

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,10 @@
217217
@include border-radius($custom-file-border-radius);
218218
@include box-shadow($custom-file-box-shadow);
219219

220-
&::after {
221-
content: $custom-file-placeholder;
220+
@each $lang, $text in map-get($custom-file-text, placeholder) {
221+
&:lang(#{$lang})::after {
222+
content: $text;
223+
}
222224
}
223225

224226
&::before {
@@ -232,9 +234,14 @@
232234
padding: $custom-file-padding-x $custom-file-padding-y;
233235
line-height: $custom-file-line-height;
234236
color: $custom-file-button-color;
235-
content: $custom-file-button-label;
236237
background-color: $custom-file-button-bg;
237238
border: $custom-file-border-width solid $custom-file-border-color;
238239
@include border-radius(0 $custom-file-border-radius $custom-file-border-radius 0);
239240
}
241+
242+
@each $lang, $text in map-get($custom-file-text, button-label) {
243+
&:lang(#{$lang})::before {
244+
content: $text;
245+
}
246+
}
240247
}

scss/_variables.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,16 @@ $custom-file-border-width: $border-width !default;
386386
$custom-file-border-color: #ddd !default;
387387
$custom-file-border-radius: $border-radius !default;
388388
$custom-file-box-shadow: inset 0 .2rem .4rem rgba(0,0,0,.05) !default;
389-
$custom-file-placeholder: "Choose file..." !default;
390-
$custom-file-button-label: "Browse" !default;
391389
$custom-file-button-color: $custom-file-color !default;
392390
$custom-file-button-bg: #eee !default;
391+
$custom-file-text: (
392+
placeholder: (
393+
en: "Choose file..."
394+
),
395+
button-label: (
396+
en: "Browse"
397+
)
398+
) !default;
393399

394400

395401
// Form validation icons

0 commit comments

Comments
 (0)