Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/scss/_component-examples.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
}
}

.custom-file-input:lang(es) ~ .custom-file-label::after {
content: "Elegir";
}

> .form-control {
+ .form-control {
margin-top: .5rem;
Expand Down
11 changes: 10 additions & 1 deletion docs/4.0/components/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,17 @@ The [`:lang()` pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:l
{% highlight scss %}
$custom-file-text: (
en: "Browse",
es: "Navegar"
es: "Elegir"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“Browse” is usually translated as Examinar (see, e.g., Microsoft Terminology)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open a new issue :).

);
{% endhighlight %}

Here's `lang(es)` in action on the custom file input for a Spanish translation:

{% example html %}
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFileLang" lang="es">
<label class="custom-file-label" for="customFileLang">Seleccionar Archivo</label>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Seleccionar un archivo because: 1) some browsers use the treatment and others use usted; the infinitive is neutral in that sense; and 2) Title Case is not used in Spanish.

</div>
{% endexample %}

You'll need to set the language of your document (or subtree thereof) correctly in order for the correct text to be shown. This can be done using [the `lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang) on the `<html>` element or the [`Content-Language` HTTP header](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12), among other methods.