initial commit

This commit is contained in:
ferdiansyah783
2025-08-05 12:35:40 +07:00
commit fffa2ead5c
1069 changed files with 118056 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
// Type Imports
import type { Locale } from '@configs/i18n'
const dictionaries = {
en: () => import('@/data/dictionaries/en.json').then(module => module.default),
fr: () => import('@/data/dictionaries/fr.json').then(module => module.default),
ar: () => import('@/data/dictionaries/ar.json').then(module => module.default)
}
export const getDictionary = async (locale: Locale) => dictionaries[locale]()
+3
View File
@@ -0,0 +1,3 @@
// Returns initials from string
export const getInitials = (string: string) =>
string.split(/\s/).reduce((response, word) => (response += word.slice(0, 1)), '')
+17
View File
@@ -0,0 +1,17 @@
// Config Imports
import { i18n } from '@configs/i18n'
// Util Imports
import { ensurePrefix } from '@/utils/string'
// Check if the url is missing the locale
export const isUrlMissingLocale = (url: string) => {
return i18n.locales.every(locale => !(url.startsWith(`/${locale}/`) || url === `/${locale}`))
}
// Get the localized url
export const getLocalizedUrl = (url: string, languageCode: string): string => {
if (!url || !languageCode) throw new Error("URL or Language Code can't be empty")
return isUrlMissingLocale(url) ? `/${languageCode}${ensurePrefix(url, '/')}` : url
}
+4
View File
@@ -0,0 +1,4 @@
export const ensurePrefix = (str: string, prefix: string) => (str.startsWith(prefix) ? str : `${prefix}${str}`)
export const withoutSuffix = (str: string, suffix: string) =>
str.endsWith(suffix) ? str.slice(0, -suffix.length) : str
export const withoutPrefix = (str: string, prefix: string) => (str.startsWith(prefix) ? str.slice(prefix.length) : str)