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:
29
frontend/src/lib/utils/audit-log-translator.ts
Normal file
29
frontend/src/lib/utils/audit-log-translator.ts
Normal 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(' ');
|
||||
}
|
||||
Reference in New Issue
Block a user