1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-03-23 14:50:07 +00:00

chore(translations): add missing translations (#884)

This commit is contained in:
Savely Krasovsky
2025-08-27 18:13:35 +02:00
committed by GitHub
parent 641bbc9351
commit afb7fc32e7
6 changed files with 39 additions and 26 deletions

View File

@@ -0,0 +1,29 @@
import { m } from '$lib/paraglide/messages';
export const eventTypes: Record<string, string> = {
SIGN_IN: m.sign_in(),
TOKEN_SIGN_IN: m.token_sign_in(),
CLIENT_AUTHORIZATION: m.client_authorization(),
NEW_CLIENT_AUTHORIZATION: m.new_client_authorization(),
ACCOUNT_CREATED: m.account_created()
}
/**
* Translates an audit log event type using paraglide messages.
* Falls back to a formatted string if no specific translation is found.
* @param event The event type string from the backend (e.g., "CLIENT_AUTHORIZATION").
* @returns The translated string.
*/
export function translateAuditLogEvent(event: string): string {
if (event in eventTypes) {
return eventTypes[event];
}
// If no specific translation is found, provide a readable fallback.
// This converts "SOME_EVENT" to "Some Event".
const words = event.split('_');
const capitalizedWords = words.map((word) => {
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
});
return capitalizedWords.join(' ');
}