diff --git a/app/assets/javascripts/discourse/app/templates/preferences/interface.hbs b/app/assets/javascripts/discourse/app/templates/preferences/interface.hbs
index 2afd22045a5..e14094c3a6f 100644
--- a/app/assets/javascripts/discourse/app/templates/preferences/interface.hbs
+++ b/app/assets/javascripts/discourse/app/templates/preferences/interface.hbs
@@ -99,6 +99,7 @@
{{combo-box
valueProperty="value"
+ langProperty="value"
content=availableLocales
value=model.locale
onChange=(action (mut model.locale))
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js
index dd7972d4907..ac9c4ee1b63 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js
@@ -313,4 +313,35 @@ discourseModule("Integration | Component | select-kit/single-select", function (
assert.equal(row.title(), "JACKSON");
},
});
+
+ componentTest("langProperty", {
+ template:
+ '{{single-select langProperty="foo" value=value content=content}}',
+
+ beforeEach() {
+ this.setProperties({
+ content: [{ id: 1, name: "john", foo: "be" }],
+ value: null,
+ });
+ },
+
+ async test(assert) {
+ assert.equal(
+ this.subject.header().el()[0].querySelector(".selected-name").lang,
+ ""
+ );
+
+ await this.subject.expand();
+
+ const row = this.subject.rowByValue(1);
+ assert.equal(row.el()[0].lang, "be");
+
+ await this.subject.selectRowByValue(1);
+
+ assert.equal(
+ this.subject.header().el()[0].querySelector(".selected-name").lang,
+ "be"
+ );
+ },
+ });
});
diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit.js b/app/assets/javascripts/select-kit/addon/components/select-kit.js
index 1ad7f666316..5432a602953 100644
--- a/app/assets/javascripts/select-kit/addon/components/select-kit.js
+++ b/app/assets/javascripts/select-kit/addon/components/select-kit.js
@@ -58,6 +58,7 @@ export default Component.extend(
multiSelect: false,
labelProperty: null,
titleProperty: null,
+ langProperty: null,
init() {
this._super(...arguments);
@@ -79,6 +80,7 @@ export default Component.extend(
nameProperty: this.nameProperty,
labelProperty: this.labelProperty,
titleProperty: this.titleProperty,
+ langProperty: this.langProperty,
options: EmberObject.create(),
isLoading: false,
diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-row.js b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-row.js
index 287637a56d0..0d899112df6 100644
--- a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-row.js
+++ b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-row.js
@@ -5,6 +5,7 @@ import UtilsMixin from "select-kit/mixins/utils";
import { guidFor } from "@ember/object/internals";
import layout from "select-kit/templates/components/select-kit/select-kit-row";
import { makeArray } from "discourse-common/lib/helpers";
+import { reads } from "@ember/object/computed";
export default Component.extend(UtilsMixin, {
layout,
@@ -18,6 +19,7 @@ export default Component.extend(UtilsMixin, {
"rowName:data-name",
"ariaLabel:aria-label",
"guid:data-guid",
+ "rowLang:lang",
],
classNameBindings: [
"isHighlighted",
@@ -47,6 +49,8 @@ export default Component.extend(UtilsMixin, {
return guidFor(this.item);
}),
+ lang: reads("item.lang"),
+
ariaLabel: computed("item.ariaLabel", "title", function () {
return this.getProperty(this.item, "ariaLabel") || this.title;
}),
@@ -82,6 +86,7 @@ export default Component.extend(UtilsMixin, {
rowValue: this.getValue(this.item),
rowLabel: this.getProperty(this.item, "labelProperty"),
rowTitle: this.getProperty(this.item, "titleProperty"),
+ rowLang: this.getProperty(this.item, "langProperty"),
});
},
diff --git a/app/assets/javascripts/select-kit/addon/components/selected-name.js b/app/assets/javascripts/select-kit/addon/components/selected-name.js
index e9cc1688a77..0ec2da4077f 100644
--- a/app/assets/javascripts/select-kit/addon/components/selected-name.js
+++ b/app/assets/javascripts/select-kit/addon/components/selected-name.js
@@ -3,12 +3,16 @@ import Component from "@ember/component";
import UtilsMixin from "select-kit/mixins/utils";
import layout from "select-kit/templates/components/selected-name";
import { makeArray } from "discourse-common/lib/helpers";
+import { reads } from "@ember/object/computed";
export default Component.extend(UtilsMixin, {
tagName: "",
layout,
name: null,
value: null,
+ headerTitle: null,
+ headerLang: null,
+ headerLabel: null,
@action
onSelectedNameClick() {
@@ -25,12 +29,15 @@ export default Component.extend(UtilsMixin, {
this.setProperties({
headerLabel: this.getProperty(this.item, "labelProperty"),
headerTitle: this.getProperty(this.item, "titleProperty"),
+ headerLang: this.getProperty(this.item, "langProperty"),
name: this.getName(this.item),
value:
this.item === this.selectKit.noneItem ? null : this.getValue(this.item),
});
},
+ lang: reads("headerLang"),
+
ariaLabel: computed("item", "sanitizedTitle", function () {
return this._safeProperty("ariaLabel", this.item) || this.sanitizedTitle;
}),
diff --git a/app/assets/javascripts/select-kit/addon/templates/components/selected-name.hbs b/app/assets/javascripts/select-kit/addon/templates/components/selected-name.hbs
index 7fb7650bf1b..8a9c1480652 100644
--- a/app/assets/javascripts/select-kit/addon/templates/components/selected-name.hbs
+++ b/app/assets/javascripts/select-kit/addon/templates/components/selected-name.hbs
@@ -1,5 +1,5 @@
{{#if selectKit.options.showFullTitle}}
-
+
{{#if item.icon}}
{{d-icon item.icon}}
{{/if}}
@@ -23,7 +23,7 @@
{{else}}
{{#if item.icon}}
-
+
{{d-icon item.icon}}
{{/if}}