DEV: Consolidate i18n import paths (#29804)

Enables our new eslint rules which enforce consistent i18n imports. For more info, see 0d58b40cd7
This commit is contained in:
David Taylor
2024-11-19 20:45:18 +00:00
committed by GitHub
parent 187b7d74fb
commit 32665cf9dd
909 changed files with 3453 additions and 3591 deletions

View File

@ -5,7 +5,7 @@ import {
acceptance,
updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n";
import { i18n } from 'discourse-i18n';
import { displayPollBuilderButton } from "discourse/plugins/poll/helpers/display-poll-builder-button";
acceptance("Poll Builder - polls are enabled", function (needs) {
@ -25,7 +25,7 @@ acceptance("Poll Builder - polls are enabled", function (needs) {
await displayPollBuilderButton();
const pollBuilderButtonSelector = `.select-kit-row[data-name='${I18n.t(
const pollBuilderButtonSelector = `.select-kit-row[data-name='${i18n(
"poll.ui_builder.title"
)}']`;
@ -71,7 +71,7 @@ acceptance("Poll Builder - polls are enabled", function (needs) {
await displayPollBuilderButton();
assert
.dom(`.select-kit-row[data-name='${I18n.t("poll.ui_builder.title")}']`)
.dom(`.select-kit-row[data-name='${i18n("poll.ui_builder.title")}']`)
.exists("it shows the builder button");
});
});

View File

@ -5,7 +5,7 @@ import {
publishToMessageBus,
query,
} from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n";
import { i18n } from 'discourse-i18n';
acceptance("Poll results", function (needs) {
needs.user();
@ -1121,7 +1121,7 @@ acceptance("Poll results", function (needs) {
query(
".poll-container .discourse-poll-ranked_choice-results .tab-container .tab.nav-item.active button"
).innerText,
I18n.t("poll.results.tabs.outcome"),
i18n("poll.results.tabs.outcome"),
"Outcome tab is active"
);
@ -1133,7 +1133,7 @@ acceptance("Poll results", function (needs) {
query(
".poll-container .discourse-poll-ranked_choice-results .tab-container .tab.nav-item.active button"
).innerText,
I18n.t("poll.results.tabs.votes"),
i18n("poll.results.tabs.votes"),
"Votes tab is active"
);

View File

@ -3,7 +3,7 @@ import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n";
import { i18n } from 'discourse-i18n';
module("Poll | Component | poll-buttons-dropdown", function (hooks) {
setupRenderingTest(hooks);
@ -40,7 +40,7 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
assert.dom("li.dropdown-menu__item").exists({ count: 2 });
assert.strictEqual(
query("li.dropdown-menu__item span").textContent.trim(),
I18n.t("poll.export-results.label"),
i18n("poll.export-results.label"),
"displays the poll Export action"
);
});
@ -76,7 +76,7 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
assert
.dom(query("li.dropdown-menu__item span"))
.hasText(
I18n.t("poll.show-tally.label"),
i18n("poll.show-tally.label"),
"displays the show absolute button"
);
});
@ -108,7 +108,7 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
assert.dom("button.widget-button").exists({ count: 1 });
assert.strictEqual(
query("button.widget-button span.d-button-label").textContent.trim(),
I18n.t("poll.breakdown.breakdown"),
i18n("poll.breakdown.breakdown"),
"displays the poll Close action"
);
});

View File

@ -3,7 +3,7 @@ import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n";
import { i18n } from 'discourse-i18n';
const OPTIONS = [
{ id: "1ddc47be0d2315b9711ee8526ca9d83f", html: "This", votes: 2, rank: 0 },
@ -47,7 +47,7 @@ module("Poll | Component | poll-info", function (hooks) {
assert.strictEqual(
query(".poll-info_instructions li.multiple-help-text").textContent.trim(),
I18n.t("poll.multiple.help.up_to_max_options", {
i18n("poll.multiple.help.up_to_max_options", {
count: this.max,
}).replace(/<\/?[^>]+(>|$)/g, ""),
"displays the multiple help text"
@ -55,7 +55,7 @@ module("Poll | Component | poll-info", function (hooks) {
assert.strictEqual(
query(".poll-info_instructions li.is-public").textContent.trim(),
I18n.t("poll.public.title").replace(/<\/?[^>]+(>|$)/g, ""),
i18n("poll.public.title").replace(/<\/?[^>]+(>|$)/g, ""),
"displays the public label"
);
});
@ -93,7 +93,7 @@ module("Poll | Component | poll-info", function (hooks) {
assert.strictEqual(
query(".poll-info_instructions li.multiple-help-text").textContent.trim(),
I18n.t("poll.multiple.help.up_to_max_options", {
i18n("poll.multiple.help.up_to_max_options", {
count: this.max,
}).replace(/<\/?[^>]+(>|$)/g, ""),
"displays the multiple help text"
@ -103,13 +103,13 @@ module("Poll | Component | poll-info", function (hooks) {
query(
".poll-info_instructions li.results-on-vote span"
).textContent.trim(),
I18n.t("poll.results.vote.title").replace(/<\/?[^>]+(>|$)/g, ""),
i18n("poll.results.vote.title").replace(/<\/?[^>]+(>|$)/g, ""),
"displays the results on vote label"
);
assert.strictEqual(
query(".poll-info_instructions li.is-public").textContent.trim(),
I18n.t("poll.public.title").replace(/<\/?[^>]+(>|$)/g, ""),
i18n("poll.public.title").replace(/<\/?[^>]+(>|$)/g, ""),
"displays the public label"
);
});

View File

@ -2,7 +2,7 @@ import { click, render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import I18n from "discourse-i18n";
import { i18n } from 'discourse-i18n';
const OPTIONS = [
{ id: "1ddc47be0d2315b9711ee8526ca9d83f", html: "This", votes: 0, rank: 0 },
@ -155,10 +155,10 @@ module("Poll | Component | poll-options", function (hooks) {
assert
.dom(".dropdown-menu__item:nth-child(2)")
.hasText(`1 ${I18n.t("poll.options.ranked_choice.highest_priority")}`);
.hasText(`1 ${i18n("poll.options.ranked_choice.highest_priority")}`);
assert
.dom(".dropdown-menu__item:nth-child(4)")
.hasText(`3 ${I18n.t("poll.options.ranked_choice.lowest_priority")}`);
.hasText(`3 ${i18n("poll.options.ranked_choice.lowest_priority")}`);
});
});

View File

@ -3,7 +3,7 @@ import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n";
import { i18n } from 'discourse-i18n';
const RANKED_CHOICE_OUTCOME = {
tied: false,
@ -49,7 +49,7 @@ module("Poll | Component | poll-results-ranked-choice", function (hooks) {
assert.strictEqual(
query("span.poll-results-ranked-choice-info").textContent.trim(),
I18n.t("poll.ranked_choice.winner", {
i18n("poll.ranked_choice.winner", {
count: this.rankedChoiceOutcome.round_activity.length,
winner: this.rankedChoiceOutcome.winning_candidate.html,
}),

View File

@ -3,7 +3,7 @@ import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n";
import { i18n } from 'discourse-i18n';
const TWO_OPTIONS = [
{ id: "1ddc47be0d2315b9711ee8526ca9d83f", html: "This", votes: 5, rank: 0 },
@ -188,13 +188,13 @@ module("Poll | Component | poll-results-standard", function (hooks) {
/>`);
let percentages = queryAll(".option .absolute");
assert.dom(percentages[0]).hasText(I18n.t("poll.votes", { count: 5 }));
assert.dom(percentages[1]).hasText(I18n.t("poll.votes", { count: 4 }));
assert.dom(percentages[2]).hasText(I18n.t("poll.votes", { count: 2 }));
assert.dom(percentages[3]).hasText(I18n.t("poll.votes", { count: 1 }));
assert.dom(percentages[0]).hasText(i18n("poll.votes", { count: 5 }));
assert.dom(percentages[1]).hasText(i18n("poll.votes", { count: 4 }));
assert.dom(percentages[2]).hasText(i18n("poll.votes", { count: 2 }));
assert.dom(percentages[3]).hasText(i18n("poll.votes", { count: 1 }));
assert.dom(queryAll(".option")[3].querySelectorAll("span")[1]).hasText("a");
assert.dom(percentages[4]).hasText(I18n.t("poll.votes", { count: 1 }));
assert.dom(percentages[4]).hasText(i18n("poll.votes", { count: 1 }));
assert.dom(queryAll(".option")[4].querySelectorAll("span")[1]).hasText("b");
});
});

View File

@ -5,7 +5,7 @@ import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
import I18n from "discourse-i18n";
import { i18n } from 'discourse-i18n';
let requests = 0;
@ -171,7 +171,7 @@ module("Poll | Component | poll", function (hooks) {
);
assert
.dom(".poll-container .alert")
.hasText(I18n.t("poll.results.groups.title", { groups: "foo" }));
.hasText(i18n("poll.results.groups.title", { groups: "foo" }));
assert.strictEqual(requests, 0);
assert.dom(".chosen").doesNotExist();
});