FIX: Broken locales in context menu (#63)

This commit is contained in:
Keegan George 2023-09-01 11:55:36 -07:00 committed by GitHub
parent bfd91fc3bc
commit b740ebd4ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 54 deletions

View File

@ -1,44 +0,0 @@
import I18n from "I18n";
function prefixedLocale(localeString) {
return I18n.t(
themePrefix(`discourse_table_builder.spreadsheet.${localeString}`)
);
}
export const localeMapping = {
noRecordsFound: prefixedLocale("no_records_found"),
show: prefixedLocale("show"),
entries: prefixedLocale("entries"),
insertANewColumnBefore: prefixedLocale("context_menu.col.before"),
insertANewColumnAfter: prefixedLocale("context_menu.col.after"),
deleteSelectedColumns: prefixedLocale("context_menu.col.delete"),
renameThisColumn: prefixedLocale("context_menu.col.rename"),
orderAscending: prefixedLocale("context_menu.order.ascending"),
orderDescending: prefixedLocale("context_menu.order.descending"),
insertANewRowBefore: prefixedLocale("context_menu.row.before"),
insertANewRowAfter: prefixedLocale("context_menu.row.after"),
deleteSelectedRows: prefixedLocale("context_menu.row.delete"),
copy: prefixedLocale("context_menu.copy"),
paste: prefixedLocale("context_menu.paste"),
saveAs: prefixedLocale("context_menu.save"),
about: prefixedLocale("about"),
areYouSureToDeleteTheSelectedRows: prefixedLocale(
"prompts.delete_selected_rows"
),
areYouSureToDeleteTheSelectedColumns: prefixedLocale(
"prompts.delete_selected_cols"
),
thisActionWillDestroyAnyExistingMergedCellsAreYouSure: prefixedLocale(
"prompts.will_destroy_merged_cells"
),
thisActionWillClearYourSearchResultsAreYouSure: prefixedLocale(
"prompts.will_clear_search_results"
),
thereIsAConflictWithAnotherMergedCell: prefixedLocale(
"prompts.conflict_with_merged_cells"
),
invalidMergeProperties: prefixedLocale("invalid_merge_props"),
cellAlreadyMerged: prefixedLocale("cells_already_merged"),
noCellsSelected: prefixedLocale("no_cells_selected"),
};

View File

@ -12,7 +12,6 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
import I18n from "I18n"; import I18n from "I18n";
import { schedule } from "@ember/runloop"; import { schedule } from "@ember/runloop";
import { tracked } from "@glimmer/tracking"; import { tracked } from "@glimmer/tracking";
import { localeMapping } from "../../discourse-table-builder/lib/locale-mapping";
export default class SpreadsheetEditor extends Component { export default class SpreadsheetEditor extends Component {
@tracked showEditReason = false; @tracked showEditReason = false;
@ -175,7 +174,7 @@ export default class SpreadsheetEditor extends Component {
defaultColAlign: "left", defaultColAlign: "left",
wordWrap: true, wordWrap: true,
csvFileName: exportFileName, csvFileName: exportFileName,
text: localeMapping, text: this.localeMapping(),
...opts, ...opts,
}); });
} }
@ -239,4 +238,49 @@ export default class SpreadsheetEditor extends Component {
return arrayToTable(table, headers); return arrayToTable(table, headers);
} }
localeMapping() {
return {
noRecordsFound: prefixedLocale("no_records_found"),
show: prefixedLocale("show"),
entries: prefixedLocale("entries"),
insertANewColumnBefore: prefixedLocale("context_menu.col.before"),
insertANewColumnAfter: prefixedLocale("context_menu.col.after"),
deleteSelectedColumns: prefixedLocale("context_menu.col.delete"),
renameThisColumn: prefixedLocale("context_menu.col.rename"),
orderAscending: prefixedLocale("context_menu.order.ascending"),
orderDescending: prefixedLocale("context_menu.order.descending"),
insertANewRowBefore: prefixedLocale("context_menu.row.before"),
insertANewRowAfter: prefixedLocale("context_menu.row.after"),
deleteSelectedRows: prefixedLocale("context_menu.row.delete"),
copy: prefixedLocale("context_menu.copy"),
paste: prefixedLocale("context_menu.paste"),
saveAs: prefixedLocale("context_menu.save"),
about: prefixedLocale("about"),
areYouSureToDeleteTheSelectedRows: prefixedLocale(
"prompts.delete_selected_rows"
),
areYouSureToDeleteTheSelectedColumns: prefixedLocale(
"prompts.delete_selected_cols"
),
thisActionWillDestroyAnyExistingMergedCellsAreYouSure: prefixedLocale(
"prompts.will_destroy_merged_cells"
),
thisActionWillClearYourSearchResultsAreYouSure: prefixedLocale(
"prompts.will_clear_search_results"
),
thereIsAConflictWithAnotherMergedCell: prefixedLocale(
"prompts.conflict_with_merged_cells"
),
invalidMergeProperties: prefixedLocale("invalid_merge_props"),
cellAlreadyMerged: prefixedLocale("cells_already_merged"),
noCellsSelected: prefixedLocale("no_cells_selected"),
};
}
}
function prefixedLocale(localeString) {
return I18n.t(
themePrefix(`discourse_table_builder.spreadsheet.${localeString}`)
);
} }

View File

@ -19,14 +19,6 @@ if (!require.entries[`${base}/discourse/components/spreadsheet-editor`]) {
_exports.findTableRegex = utilities.findTableRegex; _exports.findTableRegex = utilities.findTableRegex;
} }
); );
define(
`discourse/discourse-table-builder/lib/locale-mapping`,
["exports", `${base}/discourse-table-builder/lib/locale-mapping`],
function (_exports, localeMapping) {
_exports.localeMapping = localeMapping.localeMapping;
}
);
} }
export default { export default {