From bebb31aee968d39d2bd3546e587736a7027c1913 Mon Sep 17 00:00:00 2001 From: Thomas de Roo <2+thomas@noreply.localhost> Date: Mon, 15 Jun 2026 09:46:26 +0200 Subject: [PATCH] Update includes/functions.php --- includes/functions.php | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index 2833564..d7ee59f 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -29,4 +29,42 @@ function userPath( return USERS_PATH . '/' . usernameToFolder($username); -} \ No newline at end of file +} + +function slug(string $value): string +{ + $value = strtolower(trim($value)); + + $value = preg_replace( + '/[^a-z0-9]+/', + '_', + $value + ); + + return trim($value, '_'); +} + +function languagePath( + string $user, + string $language +): string { + + return userPath($user) + . '/languages/' + . slug($language); +} + +function listPath( + string $user, + string $language, + string $list +): string { + + return languagePath( + $user, + $language + ) + . '/lists/' + . slug($list) + . '.json'; +}