Overwrite standard translations (#11134)
Manage overwriting translations for standard fields and standard objects properties
This commit is contained in:
@ -105,7 +105,6 @@ export const SettingsDataModelFieldIconLabelForm = ({
|
||||
|
||||
const fillNameFromLabel = (label: string) => {
|
||||
isDefined(label) &&
|
||||
fieldMetadataItem?.isCustom &&
|
||||
setValue('name', computeMetadataNameFromLabel(label), {
|
||||
shouldDirty: true,
|
||||
});
|
||||
@ -141,7 +140,11 @@ export const SettingsDataModelFieldIconLabelForm = ({
|
||||
}
|
||||
}}
|
||||
error={getErrorMessageFromError(errors.label?.message)}
|
||||
disabled={isLabelSyncedWithName === true}
|
||||
disabled={
|
||||
isLabelSyncedWithName === true &&
|
||||
fieldMetadataItem &&
|
||||
!fieldMetadataItem?.isCustom
|
||||
}
|
||||
maxLength={maxLength}
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
@ -100,6 +100,7 @@ export const SettingsDataModelObjectAboutForm = ({
|
||||
setValue('labelPlural', labelPluralFromSingularLabel, {
|
||||
shouldDirty: true,
|
||||
});
|
||||
fillNamePluralFromLabelPlural(labelPluralFromSingularLabel);
|
||||
};
|
||||
|
||||
const fillNameSingularFromLabelSingular = (
|
||||
@ -161,7 +162,11 @@ export const SettingsDataModelObjectAboutForm = ({
|
||||
}
|
||||
}}
|
||||
onBlur={() => onNewDirtyField?.()}
|
||||
disabled={!objectMetadataItem?.isCustom && isLabelSyncedWithName}
|
||||
disabled={
|
||||
objectMetadataItem &&
|
||||
!objectMetadataItem?.isCustom &&
|
||||
isLabelSyncedWithName
|
||||
}
|
||||
fullWidth
|
||||
maxLength={OBJECT_NAME_MAXIMUM_LENGTH}
|
||||
/>
|
||||
@ -187,7 +192,11 @@ export const SettingsDataModelObjectAboutForm = ({
|
||||
}
|
||||
}}
|
||||
onBlur={() => onNewDirtyField?.()}
|
||||
disabled={!objectMetadataItem?.isCustom && isLabelSyncedWithName}
|
||||
disabled={
|
||||
objectMetadataItem &&
|
||||
!objectMetadataItem?.isCustom &&
|
||||
isLabelSyncedWithName
|
||||
}
|
||||
fullWidth
|
||||
maxLength={OBJECT_NAME_MAXIMUM_LENGTH}
|
||||
/>
|
||||
@ -293,37 +302,40 @@ export const SettingsDataModelObjectAboutForm = ({
|
||||
</AdvancedSettingsWrapper>
|
||||
),
|
||||
)}
|
||||
<AdvancedSettingsWrapper>
|
||||
<Controller
|
||||
name="isLabelSyncedWithName"
|
||||
control={control}
|
||||
defaultValue={objectMetadataItem?.isLabelSyncedWithName}
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<Card rounded>
|
||||
<SettingsOptionCardContentToggle
|
||||
Icon={IconRefresh}
|
||||
title={t`Synchronize Objects Labels and API Names`}
|
||||
description={t`Should changing an object's label also change the API?`}
|
||||
checked={value ?? true}
|
||||
advancedMode
|
||||
onChange={(value) => {
|
||||
onChange(value);
|
||||
onNewDirtyField?.();
|
||||
{(!objectMetadataItem || objectMetadataItem?.isCustom) && (
|
||||
<AdvancedSettingsWrapper>
|
||||
<Controller
|
||||
name="isLabelSyncedWithName"
|
||||
control={control}
|
||||
defaultValue={objectMetadataItem?.isLabelSyncedWithName}
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<Card rounded>
|
||||
<SettingsOptionCardContentToggle
|
||||
Icon={IconRefresh}
|
||||
title={t`Synchronize Objects Labels and API Names`}
|
||||
description={t`Should changing an object's label also change the API?`}
|
||||
checked={value ?? true}
|
||||
advancedMode
|
||||
onChange={(value) => {
|
||||
onChange(value);
|
||||
onNewDirtyField?.();
|
||||
|
||||
if (
|
||||
value === true &&
|
||||
isDefined(objectMetadataItem) &&
|
||||
objectMetadataItem.isCustom
|
||||
) {
|
||||
fillNamePluralFromLabelPlural(labelPlural);
|
||||
fillNameSingularFromLabelSingular(labelSingular);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
/>
|
||||
</AdvancedSettingsWrapper>
|
||||
if (
|
||||
value === true &&
|
||||
((isDefined(objectMetadataItem) &&
|
||||
objectMetadataItem.isCustom) ||
|
||||
!isDefined(objectMetadataItem))
|
||||
) {
|
||||
fillNamePluralFromLabelPlural(labelPlural);
|
||||
fillNameSingularFromLabelSingular(labelSingular);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
/>
|
||||
</AdvancedSettingsWrapper>
|
||||
)}
|
||||
</StyledAdvancedSettingsSectionInputWrapper>
|
||||
</StyledAdvancedSettingsContainer>
|
||||
</StyledAdvancedSettingsOuterContainer>
|
||||
|
||||
@ -9,10 +9,10 @@ import { Select } from '@/ui/input/components/Select';
|
||||
|
||||
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
|
||||
import { logError } from '~/utils/logError';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
|
||||
import { logError } from '~/utils/logError';
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
display: flex;
|
||||
@ -62,7 +62,7 @@ export const LocalePicker = () => {
|
||||
await refreshObjectMetadataItems();
|
||||
};
|
||||
|
||||
const localeOptions: Array<{
|
||||
const unsortedLocaleOptions: Array<{
|
||||
label: string;
|
||||
value: (typeof APP_LOCALES)[keyof typeof APP_LOCALES];
|
||||
}> = [
|
||||
@ -187,13 +187,18 @@ export const LocalePicker = () => {
|
||||
value: APP_LOCALES['vi-VN'],
|
||||
},
|
||||
];
|
||||
|
||||
if (isDebugMode) {
|
||||
localeOptions.push({
|
||||
unsortedLocaleOptions.push({
|
||||
label: t`Pseudo-English`,
|
||||
value: APP_LOCALES['pseudo-en'],
|
||||
});
|
||||
}
|
||||
|
||||
const localeOptions = [...unsortedLocaleOptions].sort((a, b) =>
|
||||
a.label.localeCompare(b.label),
|
||||
);
|
||||
|
||||
return (
|
||||
<StyledContainer>
|
||||
<Select
|
||||
|
||||
Reference in New Issue
Block a user