mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-29 16:16:02 +00:00
fix: tsc
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 } from '../i18n';
|
||||
|
||||
// Here starting the shared values for string manipulation.
|
||||
|
||||
@@ -110,3 +112,39 @@ 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 => {
|
||||
const validNamespaces: I18nNamespaces[] = [
|
||||
'string',
|
||||
'number',
|
||||
'video',
|
||||
'list',
|
||||
'json',
|
||||
'time',
|
||||
'csv',
|
||||
'pdf',
|
||||
'audio',
|
||||
'xml',
|
||||
'translation',
|
||||
'image'
|
||||
];
|
||||
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