mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-29 16:16:02 +00:00
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:
@@ -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';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user