dedcf4e9b9
- Adds template variable interpolation (`${...}`) to command menu item
labels and short labels, enabling dynamic text like `Create new
${capitalize(objectMetadataItem.labelSingular)}` instead of static
`Create new record`.
- Supports `capitalize` and `lowercase` transform functions within
template expressions.
15 lines
410 B
TypeScript
15 lines
410 B
TypeScript
import { i18n, type MessageDescriptor } from '@lingui/core';
|
|
import { isString } from '@sniptt/guards';
|
|
import { type Nullable } from 'twenty-shared/types';
|
|
import { isDefined } from 'twenty-shared/utils';
|
|
|
|
export const getCommandMenuItemLabel = (
|
|
label: Nullable<string | MessageDescriptor>,
|
|
): string => {
|
|
if (!isDefined(label)) {
|
|
return '';
|
|
}
|
|
|
|
return isString(label) ? label : i18n._(label);
|
|
};
|