add: settings page locales

This commit is contained in:
Mahyar Khanbolooki
2025-08-12 03:09:22 +03:30
parent 67f7ac35bf
commit 81bb8e9c14
9 changed files with 421 additions and 173 deletions
+31
View File
@@ -0,0 +1,31 @@
import React from 'react';
import { IconType, SmartIconType } from "@/types/iconType";
import { SmartIcon } from '@/components/utils/SmartIcon';
export function isSmartIconType(icon: unknown): icon is SmartIconType {
return (
typeof icon === 'object' &&
icon !== null &&
'Name' in icon &&
typeof (icon as SmartIconType).Name === 'string'
);
}
export function renderIcon(icon: IconType) {
if (React.isValidElement(icon)) {
return icon; // It's a React node
} else if (typeof icon === 'function') {
const IconComponent = icon; // It's a functional component
// Create a ref to pass to the forwardRef component
const ref = React.createRef<SVGSVGElement>(); // Adjust the type based on your icon component
return <IconComponent ref={ref} size={20} className='stroke-foreground mb-0.5' />;
} else if (isSmartIconType(icon)) {
// Handle SmartIconType
return (
<SmartIcon icon={icon} />
);
}
return null; // No valid icon provided
}
+4
View File
@@ -3,6 +3,10 @@ import { initReactI18next } from 'react-i18next/initReactI18next';
import resourcesToBackend from 'i18next-resources-to-backend';
import i18nConfig from '../../i18nConfig';
export const getI18nObject = (t, x) => {
return t(x, { returnObjects: true })
}
export default async function initTranslations(
locale,
namespaces,