Merge branch 'main' of https://github.com/iib0011/omni-tools into fork/y1hao/bookmark

# Conflicts:
#	src/components/Hero.tsx
#	src/components/ToolHeader.tsx
#	src/components/ToolLayout.tsx
#	src/tools/defineTool.tsx
This commit is contained in:
Ibrahima G. Coulibaly
2025-07-15 14:08:42 +01:00
339 changed files with 10494 additions and 1786 deletions

View File

@@ -1,5 +1,7 @@
import { UpdateField } from '@components/options/ToolOptions';
import { getToolsByCategory } from '@tools/index';
import { ToolCategory } from '@tools/defineTool';
import { I18nNamespaces, validNamespaces } from '../i18n';
// Here starting the shared values for string manipulation.
@@ -110,3 +112,25 @@ export function itemCounter(
export const getToolCategoryTitle = (categoryName: string): string =>
getToolsByCategory().find((category) => category.type === categoryName)!
.rawTitle;
// Type guard to check if a value is a valid I18nNamespaces
const isValidI18nNamespace = (value: string): value is I18nNamespaces => {
return validNamespaces.includes(value as I18nNamespaces);
};
export const getI18nNamespaceFromToolCategory = (
category: ToolCategory
): I18nNamespaces => {
// Map image-related categories to 'image'
if (['png', 'image-generic'].includes(category)) {
return 'image';
} else if (['gif'].includes(category)) {
return 'video';
}
// Use type guard to check if category is a valid I18nNamespaces
if (isValidI18nNamespace(category)) {
return category;
}
return 'translation';
};