feat(i18n): data.js, bookmark-import.js, storage.js auf t() umstellen
This commit is contained in:
+19
-19
@@ -42,8 +42,8 @@ const BrowserBookmarkImport = {
|
|||||||
tree = await api.getTree();
|
tree = await api.getTree();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await HellionDialog.alert(
|
await HellionDialog.alert(
|
||||||
'Zugriff auf Browser-Lesezeichen nicht möglich. Stelle sicher, dass die Extension die nötigen Berechtigungen hat.',
|
t('bm_import.no_access'),
|
||||||
{ type: 'warning', title: 'Lesezeichen-Import' }
|
{ type: 'warning', title: t('bm_import.title') }
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -51,8 +51,8 @@ const BrowserBookmarkImport = {
|
|||||||
const folders = this._extractFolders(tree[0]);
|
const folders = this._extractFolders(tree[0]);
|
||||||
if (folders.length === 0) {
|
if (folders.length === 0) {
|
||||||
await HellionDialog.alert(
|
await HellionDialog.alert(
|
||||||
'Keine Lesezeichen-Ordner gefunden.',
|
t('bm_import.no_folders'),
|
||||||
{ type: 'warning', title: 'Lesezeichen-Import' }
|
{ type: 'warning', title: t('bm_import.title') }
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ const BrowserBookmarkImport = {
|
|||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
id: child.id,
|
id: child.id,
|
||||||
title: child.title || 'Unbenannt',
|
title: child.title || t('bm_import.unnamed'),
|
||||||
depth: depth,
|
depth: depth,
|
||||||
bookmarkCount: bookmarkCount,
|
bookmarkCount: bookmarkCount,
|
||||||
subfolderCount: subfolderCount,
|
subfolderCount: subfolderCount,
|
||||||
@@ -114,7 +114,7 @@ const BrowserBookmarkImport = {
|
|||||||
header.className = 'bm-import-header';
|
header.className = 'bm-import-header';
|
||||||
|
|
||||||
const title = document.createElement('span');
|
const title = document.createElement('span');
|
||||||
title.textContent = 'Browser-Lesezeichen importieren';
|
title.textContent = t('bm_import.modal_title');
|
||||||
header.appendChild(title);
|
header.appendChild(title);
|
||||||
|
|
||||||
const closeBtn = document.createElement('button');
|
const closeBtn = document.createElement('button');
|
||||||
@@ -128,7 +128,7 @@ const BrowserBookmarkImport = {
|
|||||||
// Info
|
// Info
|
||||||
const info = document.createElement('div');
|
const info = document.createElement('div');
|
||||||
info.className = 'bm-import-info';
|
info.className = 'bm-import-info';
|
||||||
info.textContent = 'Wähle die Ordner aus, die als Boards importiert werden sollen. Jeder Ordner wird ein eigenes Board.';
|
info.textContent = t('bm_import.info');
|
||||||
modal.appendChild(info);
|
modal.appendChild(info);
|
||||||
|
|
||||||
// Ordner-Liste
|
// Ordner-Liste
|
||||||
@@ -155,13 +155,13 @@ const BrowserBookmarkImport = {
|
|||||||
meta.className = 'bm-import-folder-meta';
|
meta.className = 'bm-import-folder-meta';
|
||||||
const parts = [];
|
const parts = [];
|
||||||
if (folder.bookmarkCount > 0) {
|
if (folder.bookmarkCount > 0) {
|
||||||
parts.push(folder.bookmarkCount + ' Link' + (folder.bookmarkCount !== 1 ? 's' : ''));
|
parts.push(t('bm_import.link_count', { count: folder.bookmarkCount }));
|
||||||
}
|
}
|
||||||
if (folder.subfolderCount > 0) {
|
if (folder.subfolderCount > 0) {
|
||||||
parts.push(folder.subfolderCount + ' Ordner');
|
parts.push(t('bm_import.folder_count', { count: folder.subfolderCount }));
|
||||||
}
|
}
|
||||||
if (parts.length === 0) {
|
if (parts.length === 0) {
|
||||||
parts.push('leer');
|
parts.push(t('bm_import.empty'));
|
||||||
}
|
}
|
||||||
meta.textContent = parts.join(', ');
|
meta.textContent = parts.join(', ');
|
||||||
row.appendChild(meta);
|
row.appendChild(meta);
|
||||||
@@ -177,18 +177,18 @@ const BrowserBookmarkImport = {
|
|||||||
|
|
||||||
const selectAll = document.createElement('button');
|
const selectAll = document.createElement('button');
|
||||||
selectAll.className = 'btn-secondary';
|
selectAll.className = 'btn-secondary';
|
||||||
selectAll.textContent = 'Alle auswählen';
|
selectAll.textContent = t('bm_import.select_all');
|
||||||
selectAll.addEventListener('click', () => {
|
selectAll.addEventListener('click', () => {
|
||||||
const boxes = list.querySelectorAll('.bm-import-checkbox');
|
const boxes = list.querySelectorAll('.bm-import-checkbox');
|
||||||
const allChecked = Array.from(boxes).every(function(cb) { return cb.checked; });
|
const allChecked = Array.from(boxes).every(function(cb) { return cb.checked; });
|
||||||
boxes.forEach(function(cb) { cb.checked = !allChecked; });
|
boxes.forEach(function(cb) { cb.checked = !allChecked; });
|
||||||
selectAll.textContent = allChecked ? 'Alle auswählen' : 'Alle abwählen';
|
selectAll.textContent = allChecked ? t('bm_import.select_all') : t('bm_import.deselect_all');
|
||||||
});
|
});
|
||||||
footer.appendChild(selectAll);
|
footer.appendChild(selectAll);
|
||||||
|
|
||||||
const importBtn = document.createElement('button');
|
const importBtn = document.createElement('button');
|
||||||
importBtn.className = 'btn-primary';
|
importBtn.className = 'btn-primary';
|
||||||
importBtn.textContent = 'Importieren';
|
importBtn.textContent = t('bm_import.import_btn');
|
||||||
importBtn.addEventListener('click', () => this._importSelected(folders));
|
importBtn.addEventListener('click', () => this._importSelected(folders));
|
||||||
footer.appendChild(importBtn);
|
footer.appendChild(importBtn);
|
||||||
|
|
||||||
@@ -216,8 +216,8 @@ const BrowserBookmarkImport = {
|
|||||||
const checkboxes = document.querySelectorAll('.bm-import-checkbox:checked');
|
const checkboxes = document.querySelectorAll('.bm-import-checkbox:checked');
|
||||||
if (checkboxes.length === 0) {
|
if (checkboxes.length === 0) {
|
||||||
await HellionDialog.alert(
|
await HellionDialog.alert(
|
||||||
'Bitte wähle mindestens einen Ordner aus.',
|
t('bm_import.no_selection'),
|
||||||
{ type: 'warning', title: 'Lesezeichen-Import' }
|
{ type: 'warning', title: t('bm_import.title') }
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -289,15 +289,15 @@ const BrowserBookmarkImport = {
|
|||||||
|
|
||||||
// Ergebnis-Dialog
|
// Ergebnis-Dialog
|
||||||
const lines = [];
|
const lines = [];
|
||||||
lines.push(boardsCreated + ' Board' + (boardsCreated !== 1 ? 's' : '') + ' erstellt');
|
lines.push(t('bm_import.boards_created', { count: boardsCreated }));
|
||||||
lines.push(totalImported + ' Lesezeichen importiert');
|
lines.push(t('bm_import.bookmarks_imported', { count: totalImported }));
|
||||||
if (totalSkipped > 0) {
|
if (totalSkipped > 0) {
|
||||||
lines.push(totalSkipped + ' Duplikat' + (totalSkipped !== 1 ? 'e' : '') + ' übersprungen');
|
lines.push(t('bm_import.duplicates_skipped', { count: totalSkipped }));
|
||||||
}
|
}
|
||||||
|
|
||||||
await HellionDialog.alert(
|
await HellionDialog.alert(
|
||||||
lines.join('\n'),
|
lines.join('\n'),
|
||||||
{ type: 'success', title: 'Import abgeschlossen' }
|
{ type: 'success', title: t('bm_import.success_title') }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+10
-10
@@ -37,7 +37,7 @@ function initDataButtons() {
|
|||||||
if (!file) return;
|
if (!file) return;
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(await file.text());
|
const data = JSON.parse(await file.text());
|
||||||
if (!Array.isArray(data.boards)) throw new Error('Ungültiges Format');
|
if (!Array.isArray(data.boards)) throw new Error(t('data.invalid_format'));
|
||||||
const validBoards = data.boards.filter(b => {
|
const validBoards = data.boards.filter(b => {
|
||||||
if (!b || typeof b.title !== 'string' || !Array.isArray(b.bookmarks)) return false;
|
if (!b || typeof b.title !== 'string' || !Array.isArray(b.bookmarks)) return false;
|
||||||
b.id = b.id || uid();
|
b.id = b.id || uid();
|
||||||
@@ -50,10 +50,10 @@ function initDataButtons() {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (validBoards.length === 0) throw new Error('Keine gültigen Boards gefunden');
|
if (validBoards.length === 0) throw new Error(t('data.no_boards'));
|
||||||
const ok = await HellionDialog.confirm(
|
const ok = await HellionDialog.confirm(
|
||||||
`${validBoards.length} Boards importieren? Bestehende Daten bleiben erhalten.`,
|
t('data.import_confirm', { count: validBoards.length }),
|
||||||
{ type: 'info', title: 'JSON Import' }
|
{ type: 'info', title: t('data.import_confirm.title') }
|
||||||
);
|
);
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
boards = [...boards, ...validBoards];
|
boards = [...boards, ...validBoards];
|
||||||
@@ -112,15 +112,15 @@ function initDataButtons() {
|
|||||||
// Gemeinsam speichern
|
// Gemeinsam speichern
|
||||||
await Store.set('widgetStates', existingWidgets);
|
await Store.set('widgetStates', existingWidgets);
|
||||||
|
|
||||||
const noteMsg = notesImported > 0 ? ` + ${notesImported} Note(s)` : '';
|
const noteMsg = notesImported > 0 ? t('data.notes_suffix', { count: notesImported }) : '';
|
||||||
const calcMsg = calcImported ? ' + Calculator-History' : '';
|
const calcMsg = calcImported ? t('data.calc_suffix') : '';
|
||||||
const timerMsg = timerImported ? ' + Timer-Presets' : '';
|
const timerMsg = timerImported ? t('data.timer_suffix') : '';
|
||||||
await HellionDialog.alert(
|
await HellionDialog.alert(
|
||||||
`${validBoards.length} Board(s)${noteMsg}${calcMsg}${timerMsg} erfolgreich importiert.`,
|
t('data.import_success', { boards: validBoards.length, notes: noteMsg, calc: calcMsg, timer: timerMsg }),
|
||||||
{ type: 'success', title: 'Import erfolgreich' }
|
{ type: 'success', title: t('data.import_success.title') }
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await HellionDialog.alert('Fehler beim Import: ' + err.message, { type: 'danger', title: 'Import fehlgeschlagen' });
|
await HellionDialog.alert(t('data.import_error', { error: err.message }), { type: 'danger', title: t('data.import_error.title') });
|
||||||
}
|
}
|
||||||
e.target.value = '';
|
e.target.value = '';
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ const Store = {
|
|||||||
chrome.storage.local.set({ [key]: value }, () => {
|
chrome.storage.local.set({ [key]: value }, () => {
|
||||||
if (chrome.runtime.lastError) {
|
if (chrome.runtime.lastError) {
|
||||||
console.error('Storage-Fehler:', chrome.runtime.lastError.message);
|
console.error('Storage-Fehler:', chrome.runtime.lastError.message);
|
||||||
HellionDialog.alert('Speicher voll! Bitte lösche alte Boards oder das Hintergrundbild, um Platz zu schaffen.', { type: 'danger', title: 'Speicher voll' });
|
HellionDialog.alert(t('storage.quota_full'), { type: 'danger', title: t('storage.quota_full.title') });
|
||||||
reject(new Error(chrome.runtime.lastError.message));
|
reject(new Error(chrome.runtime.lastError.message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ const Store = {
|
|||||||
resolve();
|
resolve();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Storage-Fehler:', e.message);
|
console.error('Storage-Fehler:', e.message);
|
||||||
HellionDialog.alert('Speicher voll! Bitte lösche alte Boards oder das Hintergrundbild, um Platz zu schaffen.', { type: 'danger', title: 'Speicher voll' });
|
HellionDialog.alert(t('storage.quota_full'), { type: 'danger', title: t('storage.quota_full.title') });
|
||||||
reject(e);
|
reject(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user