Refactor comments and CSS for improved clarity in Khoj plugin

- Translated comments from French to English for better accessibility and understanding.
- Updated CSS comment for loading animation to reflect the change in language.
- Enhanced code readability by ensuring consistent language usage across multiple files.
- Improved user experience by clarifying the purpose of various functions and settings in the codebase.
This commit is contained in:
Henri Jamet
2025-01-08 09:31:43 +01:00
parent 1aff78a969
commit f42b0cb08c
5 changed files with 16 additions and 16 deletions

View File

@@ -59,18 +59,18 @@ export default class Khoj extends Plugin {
// Add a settings tab so the user can configure khoj
this.addSettingTab(new KhojSettingTab(this.app, this));
// Démarrer le timer de synchronisation
// Start the sync timer
this.startSyncTimer();
}
// Méthode pour démarrer le timer de synchronisation
// Method to start the sync timer
private startSyncTimer() {
// Nettoyer l'ancien timer s'il existe
// Clean up the old timer if it exists
if (this.indexingTimer) {
clearInterval(this.indexingTimer);
}
// Démarrer un nouveau timer avec l'intervalle configuré
// Start a new timer with the configured interval
this.indexingTimer = setInterval(async () => {
if (this.settings.autoConfigure) {
this.settings.lastSync = await updateContentIndex(
@@ -79,10 +79,10 @@ export default class Khoj extends Plugin {
this.settings.lastSync
);
}
}, this.settings.syncInterval * 60 * 1000); // Convertir les minutes en millisecondes
}, this.settings.syncInterval * 60 * 1000); // Convert minutes to milliseconds
}
// Méthode publique pour redémarrer le timer (appelée depuis les paramètres)
// Public method to restart the timer (called from settings)
public restartSyncTimer() {
this.startSyncTimer();
}

View File

@@ -13,7 +13,7 @@ export class KhojSearchModal extends SuggestModal<SearchResult> {
find_similar_notes: boolean;
query: string = "";
app: App;
currentController: AbortController | null = null; // Pour annuler les requêtes
currentController: AbortController | null = null; // To cancel requests
isLoading: boolean = false;
loadingEl: HTMLElement;
@@ -37,11 +37,11 @@ export class KhojSearchModal extends SuggestModal<SearchResult> {
this.loadingEl.style.zIndex = "1000";
this.loadingEl.style.display = "none";
// Ajouter l'élément au modal
// Add the element to the modal
this.modalEl.appendChild(this.loadingEl);
// Customize empty state message
// @ts-ignore - Accès à la propriété privée pour personnaliser le message
// @ts-ignore - Access to private property to customize the message
this.emptyStateText = "";
// Register Modal Keybindings to Rerank Results
@@ -99,7 +99,7 @@ export class KhojSearchModal extends SuggestModal<SearchResult> {
}
async getSuggestions(query: string): Promise<SearchResult[]> {
// Ne pas afficher le chargement si la requête est vide
// Do not show loading if the query is empty
if (!query.trim()) {
this.isLoading = false;
this.updateLoadingState();

View File

@@ -178,7 +178,7 @@ export class KhojSettingTab extends PluginSettingTab {
.onChange(async (value) => {
this.plugin.settings.syncInterval = parseInt(value);
await this.plugin.saveSettings();
// Redémarrer le timer avec le nouvel intervalle
// Restart the timer with the new interval
this.plugin.restartSyncTimer();
}));
@@ -311,13 +311,13 @@ class FolderSuggestModal extends SuggestModal<string> {
const folders = new Set<string>();
folders.add(''); // Root folder
// Récupérer tous les fichiers et extraire les chemins des dossiers
// Get all files and extract folder paths
this.app.vault.getAllLoadedFiles().forEach(file => {
const folderPath = file.parent?.path;
if (folderPath) {
folders.add(folderPath);
// Ajouter aussi tous les dossiers parents
// Also add all parent folders
let parent = folderPath;
while (parent.includes('/')) {
parent = parent.substring(0, parent.lastIndexOf('/'));

View File

@@ -74,9 +74,9 @@ export async function updateContentIndex(vault: Vault, setting: KhojSetting, las
})
// Filter files based on specified folders
.filter(file => {
// Si aucun dossier n'est spécifié, synchroniser tous les fichiers
// If no folders are specified, sync all files
if (setting.syncFolders.length === 0) return true;
// Sinon, vérifier si le fichier est dans un des dossiers spécifiés
// Otherwise, check if the file is in one of the specified folders
return setting.syncFolders.some(folder =>
file.path.startsWith(folder + '/') || file.path === folder
);

View File

@@ -813,7 +813,7 @@ img.copy-icon {
display: block;
}
/* Animation de chargement */
/* Loading animation */
.khoj-loading {
display: flex;
justify-content: center;