Migrate more strings to translation keys (#11522)
This commit is contained in:
parent
e650397bac
commit
bf68e4afb6
69 changed files with 4870 additions and 3876 deletions
|
@ -60,7 +60,7 @@ export default abstract class Exporter {
|
|||
|
||||
protected onBeforeUnload(e: BeforeUnloadEvent): string {
|
||||
e.preventDefault();
|
||||
return (e.returnValue = _t("Are you sure you want to exit during this export?"));
|
||||
return (e.returnValue = _t("export_chat|unload_confirm"));
|
||||
}
|
||||
|
||||
protected updateProgress(progress: string, log = true, show = true): void {
|
||||
|
@ -79,7 +79,7 @@ export default abstract class Exporter {
|
|||
protected makeFileNameNoExtension(brand = "matrix"): string {
|
||||
// First try to use the real name of the room, then a translated copy of a generic name,
|
||||
// then finally hardcoded default to guarantee we'll have a name.
|
||||
const safeRoomName = sanitizeFilename(this.room.name ?? _t("Unnamed Room")).trim() || "Unnamed Room";
|
||||
const safeRoomName = sanitizeFilename(this.room.name ?? _t("common|unnamed_room")).trim() || "Unnamed Room";
|
||||
const safeDate = formatFullDateNoDayISO(new Date()).replace(/:/g, "-"); // ISO format automatically removes a lot of stuff for us
|
||||
const safeBrand = sanitizeFilename(brand);
|
||||
return `${safeBrand} - ${safeRoomName} - Chat Export - ${safeDate}`;
|
||||
|
@ -92,7 +92,7 @@ export default abstract class Exporter {
|
|||
|
||||
const zip = new JSZip();
|
||||
// Create a writable stream to the directory
|
||||
if (!this.cancelled) this.updateProgress(_t("Generating a ZIP"));
|
||||
if (!this.cancelled) this.updateProgress(_t("export_chat|generating_zip"));
|
||||
else return this.cleanUp();
|
||||
|
||||
for (const file of this.files) zip.file(filenameWithoutExt + "/" + file.name, file.blob);
|
||||
|
@ -182,14 +182,14 @@ export default abstract class Exporter {
|
|||
|
||||
if (this.exportType === ExportType.LastNMessages) {
|
||||
this.updateProgress(
|
||||
_t("Fetched %(count)s events out of %(total)s", {
|
||||
_t("export_chat|fetched_n_events_with_total", {
|
||||
count: events.length,
|
||||
total: this.exportOptions.numberOfMessages,
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
this.updateProgress(
|
||||
_t("Fetched %(count)s events so far", {
|
||||
_t("export_chat|fetched_n_events", {
|
||||
count: events.length,
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -57,8 +57,8 @@ export default class HTMLExporter extends Exporter {
|
|||
this.permalinkCreator = new RoomPermalinkCreator(this.room);
|
||||
this.totalSize = 0;
|
||||
this.mediaOmitText = !this.exportOptions.attachmentsIncluded
|
||||
? _t("Media omitted")
|
||||
: _t("Media omitted - file size limit exceeded");
|
||||
? _t("export_chat|media_omitted")
|
||||
: _t("export_chat|media_omitted_file_size");
|
||||
}
|
||||
|
||||
protected async getRoomAvatar(): Promise<string> {
|
||||
|
@ -91,7 +91,7 @@ export default class HTMLExporter extends Exporter {
|
|||
const topic = this.room.currentState.getStateEvents(EventType.RoomTopic, "")?.getContent()?.topic || "";
|
||||
|
||||
const safeCreatedText = escapeHtml(
|
||||
_t("%(creatorName)s created this room.", {
|
||||
_t("export_chat|creator_summary", {
|
||||
creatorName,
|
||||
}),
|
||||
);
|
||||
|
@ -101,7 +101,7 @@ export default class HTMLExporter extends Exporter {
|
|||
const safeExportedText = renderToStaticMarkup(
|
||||
<p>
|
||||
{_t(
|
||||
"This is the start of export of <roomName/>. Exported by <exporterDetails/> at %(exportDate)s.",
|
||||
"export_chat|export_info",
|
||||
{
|
||||
exportDate,
|
||||
},
|
||||
|
@ -127,12 +127,12 @@ export default class HTMLExporter extends Exporter {
|
|||
</p>,
|
||||
);
|
||||
|
||||
const safeTopicText = topic ? _t("Topic: %(topic)s", { topic: safeTopic }) : "";
|
||||
const safeTopicText = topic ? _t("export_chat|topic", { topic: safeTopic }) : "";
|
||||
const previousMessagesLink = renderToStaticMarkup(
|
||||
currentPage !== 0 ? (
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<a href={`./messages${currentPage === 1 ? "" : currentPage}.html`} style={{ fontWeight: "bold" }}>
|
||||
{_t("Previous group of messages")}
|
||||
{_t("export_chat|previous_page")}
|
||||
</a>
|
||||
</div>
|
||||
) : (
|
||||
|
@ -144,7 +144,7 @@ export default class HTMLExporter extends Exporter {
|
|||
currentPage < nbPages - 1 ? (
|
||||
<div style={{ textAlign: "center", margin: "10px" }}>
|
||||
<a href={"./messages" + (currentPage + 2) + ".html"} style={{ fontWeight: "bold" }}>
|
||||
{_t("Next group of messages")}
|
||||
{_t("export_chat|next_page")}
|
||||
</a>
|
||||
</div>
|
||||
) : (
|
||||
|
@ -161,7 +161,7 @@ export default class HTMLExporter extends Exporter {
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="css/style.css" rel="stylesheet" />
|
||||
<script src="js/script.js"></script>
|
||||
<title>${_t("Exported Data")}</title>
|
||||
<title>${_t("export_chat|html_title")}</title>
|
||||
</head>
|
||||
<body style="height: 100vh;">
|
||||
<section
|
||||
|
@ -385,7 +385,7 @@ export default class HTMLExporter extends Exporter {
|
|||
} catch (e) {
|
||||
logger.log("Error while fetching file" + e);
|
||||
eventTile = await this.getEventTileMarkup(
|
||||
this.createModifiedEvent(_t("Error fetching file"), mxEv),
|
||||
this.createModifiedEvent(_t("export_chat|error_fetching_file"), mxEv),
|
||||
joined,
|
||||
);
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ export default class HTMLExporter extends Exporter {
|
|||
for (let i = start; i < Math.min(start + 1000, events.length); i++) {
|
||||
const event = events[i];
|
||||
this.updateProgress(
|
||||
_t("Processing event %(number)s out of %(total)s", {
|
||||
_t("export_chat|processing_event_n", {
|
||||
number: i + 1,
|
||||
total: events.length,
|
||||
}),
|
||||
|
@ -444,14 +444,14 @@ export default class HTMLExporter extends Exporter {
|
|||
}
|
||||
|
||||
public async export(): Promise<void> {
|
||||
this.updateProgress(_t("Starting export…"));
|
||||
this.updateProgress(_t("export_chat|starting_export"));
|
||||
|
||||
const fetchStart = performance.now();
|
||||
const res = await this.getRequiredEvents();
|
||||
const fetchEnd = performance.now();
|
||||
|
||||
this.updateProgress(
|
||||
_t("Fetched %(count)s events in %(seconds)ss", {
|
||||
_t("export_chat|fetched_n_events_in_time", {
|
||||
count: res.length,
|
||||
seconds: (fetchEnd - fetchStart) / 1000,
|
||||
}),
|
||||
|
@ -459,7 +459,7 @@ export default class HTMLExporter extends Exporter {
|
|||
false,
|
||||
);
|
||||
|
||||
this.updateProgress(_t("Creating HTML…"));
|
||||
this.updateProgress(_t("export_chat|creating_html"));
|
||||
|
||||
const usedClasses = new Set<string>();
|
||||
for (let page = 0; page < res.length / 1000; page++) {
|
||||
|
@ -482,9 +482,9 @@ export default class HTMLExporter extends Exporter {
|
|||
if (this.cancelled) {
|
||||
logger.info("Export cancelled successfully");
|
||||
} else {
|
||||
this.updateProgress(_t("Export successful!"));
|
||||
this.updateProgress(_t("export_chat|export_successful"));
|
||||
this.updateProgress(
|
||||
_t("Exported %(count)s events in %(seconds)s seconds", {
|
||||
_t("export_chat|exported_n_events_in_time", {
|
||||
count: res.length,
|
||||
seconds: (exportEnd - fetchStart) / 1000,
|
||||
}),
|
||||
|
|
|
@ -83,7 +83,7 @@ export default class JSONExporter extends Exporter {
|
|||
for (let i = 0; i < events.length; i++) {
|
||||
const event = events[i];
|
||||
this.updateProgress(
|
||||
_t("Processing event %(number)s out of %(total)s", {
|
||||
_t("export_chat|processing_event_n", {
|
||||
number: i + 1,
|
||||
total: events.length,
|
||||
}),
|
||||
|
|
|
@ -39,8 +39,8 @@ export default class PlainTextExporter extends Exporter {
|
|||
super(room, exportType, exportOptions, setProgressText);
|
||||
this.totalSize = 0;
|
||||
this.mediaOmitText = !this.exportOptions.attachmentsIncluded
|
||||
? _t("Media omitted")
|
||||
: _t("Media omitted - file size limit exceeded");
|
||||
? _t("export_chat|media_omitted")
|
||||
: _t("export_chat|media_omitted_file_size");
|
||||
}
|
||||
|
||||
public get destinationFileName(): string {
|
||||
|
@ -92,14 +92,14 @@ export default class PlainTextExporter extends Exporter {
|
|||
} else {
|
||||
this.totalSize += blob.size;
|
||||
const filePath = this.getFilePath(mxEv);
|
||||
mediaText = " (" + _t("File Attached") + ")";
|
||||
mediaText = " (" + _t("export_chat|file_attached") + ")";
|
||||
this.addFile(filePath, blob);
|
||||
if (this.totalSize == this.exportOptions.maxSize) {
|
||||
this.exportOptions.attachmentsIncluded = false;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
mediaText = " (" + _t("Error fetching file") + ")";
|
||||
mediaText = " (" + _t("export_chat|error_fetching_file") + ")";
|
||||
logger.log("Error fetching file " + error);
|
||||
}
|
||||
} else mediaText = ` (${this.mediaOmitText})`;
|
||||
|
@ -113,7 +113,7 @@ export default class PlainTextExporter extends Exporter {
|
|||
for (let i = 0; i < events.length; i++) {
|
||||
const event = events[i];
|
||||
this.updateProgress(
|
||||
_t("Processing event %(number)s out of %(total)s", {
|
||||
_t("export_chat|processing_event_n", {
|
||||
number: i + 1,
|
||||
total: events.length,
|
||||
}),
|
||||
|
@ -134,8 +134,8 @@ export default class PlainTextExporter extends Exporter {
|
|||
}
|
||||
|
||||
public async export(): Promise<void> {
|
||||
this.updateProgress(_t("Starting export process…"));
|
||||
this.updateProgress(_t("Fetching events…"));
|
||||
this.updateProgress(_t("export_chat|starting_export"));
|
||||
this.updateProgress(_t("export_chat|fetching_events"));
|
||||
|
||||
const fetchStart = performance.now();
|
||||
const res = await this.getRequiredEvents();
|
||||
|
@ -143,7 +143,7 @@ export default class PlainTextExporter extends Exporter {
|
|||
|
||||
logger.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart) / 1000}s`);
|
||||
|
||||
this.updateProgress(_t("Creating output…"));
|
||||
this.updateProgress(_t("export_chat|creating_output"));
|
||||
const text = await this.createOutput(res);
|
||||
|
||||
if (this.files.length) {
|
||||
|
|
|
@ -36,11 +36,11 @@ export type ExportTypeKey = "Timeline" | "Beginning" | "LastNMessages";
|
|||
export const textForFormat = (format: ExportFormat): string => {
|
||||
switch (format) {
|
||||
case ExportFormat.Html:
|
||||
return _t("HTML");
|
||||
return _t("export_chat|html");
|
||||
case ExportFormat.Json:
|
||||
return _t("JSON");
|
||||
return _t("export_chat|json");
|
||||
case ExportFormat.PlainText:
|
||||
return _t("Plain Text");
|
||||
return _t("export_chat|text");
|
||||
default:
|
||||
throw new Error("Unknown format");
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ export const textForFormat = (format: ExportFormat): string => {
|
|||
export const textForType = (type: ExportType): string => {
|
||||
switch (type) {
|
||||
case ExportType.Beginning:
|
||||
return _t("From the beginning");
|
||||
return _t("export_chat|from_the_beginning");
|
||||
case ExportType.LastNMessages:
|
||||
return _t("Specify a number of messages");
|
||||
return _t("export_chat|number_of_messages");
|
||||
case ExportType.Timeline:
|
||||
return _t("Current Timeline");
|
||||
return _t("export_chat|current_timeline");
|
||||
default:
|
||||
throw new Error("Unknown type: " + type);
|
||||
// case exportTypes.START_DATE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue