mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-01 02:49:42 +00:00
Implémenter une app vue avec la liste des tickets attribués
This commit is contained in:
@@ -8,6 +8,26 @@ import { TranslatableString } from "ChillMainAssets/types";
|
||||
* @param locale defaults to browser locale
|
||||
* @returns The localized string or null if no translation is available
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prepends the current HTML lang code to the given URL.
|
||||
* Example: If lang="fr" and url="/about", returns "/fr/about"
|
||||
*
|
||||
* @param url The URL to localize
|
||||
* @returns The localized URL
|
||||
*/
|
||||
export function localizedUrl(url: string): string {
|
||||
const lang =
|
||||
document.documentElement.lang || navigator.language.split("-")[0] || "fr";
|
||||
// Ensure url starts with a slash and does not already start with /{lang}/
|
||||
const normalizedUrl = url.startsWith("/") ? url : `/${url}`;
|
||||
const langPrefix = `/${lang}`;
|
||||
if (normalizedUrl.startsWith(langPrefix + "/")) {
|
||||
return normalizedUrl;
|
||||
}
|
||||
return `${langPrefix}${normalizedUrl}`;
|
||||
}
|
||||
|
||||
export function localizeString(
|
||||
translatableString: TranslatableString | null | undefined,
|
||||
locale?: string,
|
||||
|
Reference in New Issue
Block a user