Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

feat(i18n): complete en/fr crm label coverage

Anibal Svarcasc4c5ef5eba8a
diff --git a/src/components/admin/autocomplete-input.tsx b/src/components/admin/autocomplete-input.tsx
index 62b10098..7782a071 100644
--- a/src/components/admin/autocomplete-input.tsx
+++ b/src/components/admin/autocomplete-input.tsx
@@ -237,7 +237,7 @@ export const AutocompleteInput = (
{/* We handle the filtering ourselves */}
<Command shouldFilter={!isFromReference}>
<CommandInput
- placeholder="Search..."
+ placeholder={placeholder}
value={filterValue}
onValueChange={(filter) => {
setFilterValue(filter);
diff --git a/src/components/atomic-crm/activity/ActivityLog.tsx b/src/components/atomic-crm/activity/ActivityLog.tsx
index 3bbd7af5..5ca08019 100644
--- a/src/components/atomic-crm/activity/ActivityLog.tsx
+++ b/src/components/atomic-crm/activity/ActivityLog.tsx
@@ -2,7 +2,7 @@ import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
import { useQuery } from "@tanstack/react-query";
-import { type Identifier, useDataProvider } from "ra-core";
+import { type Identifier, useDataProvider, useTranslate } from "ra-core";
import { RotateCcw } from "lucide-react";
import type { CrmDataProvider } from "../providers/types";
@@ -21,6 +21,7 @@ export function ActivityLog({
context = "all",
}: ActivityLogProps) {
const dataProvider = useDataProvider<CrmDataProvider>();
+ const translate = useTranslate();
const { data, isPending, error, refetch } = useQuery({
queryKey: ["activityLog", companyId],
queryFn: () => dataProvider.getActivityLog(companyId),
@@ -47,7 +48,9 @@ export function ActivityLog({
return (
<div className="p-4">
<div className="text-center text-muted-foreground mb-4">
- Error loading latest activity
+ {translate("crm.dashboard.latest_activity_error", {
+ _: "Error loading latest activity",
+ })}
</div>
<div className="text-center mt-2">
<Button
@@ -56,7 +59,7 @@ export function ActivityLog({
}}
>
<RotateCcw />
- Retry
+ {translate("crm.common.retry", { _: "Retry" })}
</Button>
</div>
</div>
diff --git a/src/components/atomic-crm/activity/ActivityLogCompanyCreated.tsx b/src/components/atomic-crm/activity/ActivityLogCompanyCreated.tsx
index f9902262..5a139b42 100644
--- a/src/components/atomic-crm/activity/ActivityLogCompanyCreated.tsx
+++ b/src/components/atomic-crm/activity/ActivityLogCompanyCreated.tsx
@@ -1,3 +1,4 @@
+import { useTranslate } from "ra-core";
import { Link } from "react-router";
import { ReferenceField } from "@/components/admin/reference-field";
@@ -15,6 +16,7 @@ export function ActivityLogCompanyCreated({
activity,
}: ActivityLogCompanyCreatedProps) {
const context = useActivityLogContext();
+ const translate = useTranslate();
const { company } = activity;
return (
<div className="p-0">
@@ -25,7 +27,7 @@ export function ActivityLogCompanyCreated({
<ReferenceField source="sales_id" reference="sales" record={activity}>
<SaleName />
</ReferenceField>{" "}
- added company{" "}
+ {translate("crm.activity.added_company", { _: "added company" })}{" "}
<Link to={`/companies/${company.id}/show`}>{company.name}</Link>
{context === "all" && (
<>
diff --git a/src/components/atomic-crm/activity/ActivityLogContactCreated.tsx b/src/components/atomic-crm/activity/ActivityLogContactCreated.tsx
index 69b45c0f..3a7cd0cc 100644
--- a/src/components/atomic-crm/activity/ActivityLogContactCreated.tsx
+++ b/src/components/atomic-crm/activity/ActivityLogContactCreated.tsx
@@ -1,3 +1,4 @@
+import { useTranslate } from "ra-core";
import { Link } from "react-router";
import { ReferenceField } from "@/components/admin/reference-field";
@@ -15,6 +16,7 @@ export function ActivityLogContactCreated({
activity,
}: ActivityLogContactCreatedProps) {
const context = useActivityLogContext();
+ const translate = useTranslate();
const { contact } = activity;
return (
<div className="p-0">
@@ -24,7 +26,7 @@ export function ActivityLogContactCreated({
<ReferenceField source="sales_id" reference="sales" record={activity}>
<SaleName />
</ReferenceField>{" "}
- added{" "}
+ {translate("crm.activity.added_contact", { _: "added" })}{" "}
<Link to={`/contacts/${contact.id}/show`}>
{contact.first_name} {contact.last_name}
</Link>
@@ -33,7 +35,7 @@ export function ActivityLogContactCreated({
{activity.company_id != null && (
<>
{" "}
- to{" "}
+ {translate("crm.activity.to", { _: "to" })}{" "}
<ReferenceField
source="company_id"
reference="companies"
diff --git a/src/components/atomic-crm/activity/ActivityLogContactNoteCreated.tsx b/src/components/atomic-crm/activity/ActivityLogContactNoteCreated.tsx
index 740ba1b5..80b8397c 100644
--- a/src/components/atomic-crm/activity/ActivityLogContactNoteCreated.tsx
+++ b/src/components/atomic-crm/activity/ActivityLogContactNoteCreated.tsx
@@ -1,4 +1,4 @@
-import { useRecordContext } from "ra-core";
+import { useRecordContext, useTranslate } from "ra-core";
import { ReferenceField } from "@/components/admin/reference-field";
import { TextField } from "@/components/admin/text-field";
@@ -24,6 +24,7 @@ export function ActivityLogContactNoteCreated({
}: ActivityLogContactNoteCreatedProps) {
const context = useActivityLogContext();
const isMobile = useIsMobile();
+ const translate = useTranslate();
const { contactNote } = activity;
const link = isMobile
? `/contacts/${contactNote.contact_id}/notes/${contactNote.id}`
@@ -48,7 +49,9 @@ export function ActivityLogContactNoteCreated({
>
<SaleName />
</ReferenceField>{" "}
- added a note about{" "}
+ {translate("crm.activity.added_note_about", {
+ _: "added a note about",
+ })}{" "}
<ReferenceField
source="contact_id"
reference="contacts"
diff --git a/src/components/atomic-crm/activity/ActivityLogDealCreated.tsx b/src/components/atomic-crm/activity/ActivityLogDealCreated.tsx
index 64d706ed..d42feee8 100644
--- a/src/components/atomic-crm/activity/ActivityLogDealCreated.tsx
+++ b/src/components/atomic-crm/activity/ActivityLogDealCreated.tsx
@@ -1,4 +1,4 @@
-import type { RaRecord } from "ra-core";
+import { type RaRecord, useTranslate } from "ra-core";
import { Link } from "react-router";
import { ReferenceField } from "@/components/admin/reference-field";
@@ -17,6 +17,7 @@ export function ActivityLogDealCreated({
}: ActivityLogDealCreatedProps) {
const context = useActivityLogContext();
const isMobile = useIsMobile();
+ const translate = useTranslate();
const { deal } = activity;
return (
<div className="p-0">
@@ -26,7 +27,7 @@ export function ActivityLogDealCreated({
<ReferenceField source="sales_id" reference="sales" record={activity}>
<SaleName />
</ReferenceField>{" "}
- added deal{" "}
+ {translate("crm.activity.added_deal", { _: "added deal" })}{" "}
{isMobile ? (
deal.name
) : (
@@ -34,7 +35,7 @@ export function ActivityLogDealCreated({
)}{" "}
{context !== "company" && (
<>
- to{" "}
+ {translate("crm.activity.to", { _: "to" })}{" "}
<ReferenceField
source="company_id"
reference="companies"
diff --git a/src/components/atomic-crm/activity/ActivityLogDealNoteCreated.tsx b/src/components/atomic-crm/activity/ActivityLogDealNoteCreated.tsx
index 120ac9b0..b5993614 100644
--- a/src/components/atomic-crm/activity/ActivityLogDealNoteCreated.tsx
+++ b/src/components/atomic-crm/activity/ActivityLogDealNoteCreated.tsx
@@ -1,4 +1,4 @@
-import type { RaRecord } from "ra-core";
+import { type RaRecord, useTranslate } from "ra-core";
import { ReferenceField } from "@/components/admin/reference-field";
import { CompanyAvatar } from "../companies/CompanyAvatar";
@@ -18,6 +18,7 @@ export function ActivityLogDealNoteCreated({
}: ActivityLogDealNoteCreatedProps) {
const context = useActivityLogContext();
const isMobile = useIsMobile();
+ const translate = useTranslate();
const { dealNote } = activity;
return (
<ActivityLogNote
@@ -47,7 +48,9 @@ export function ActivityLogDealNoteCreated({
>
<SaleName />
</ReferenceField>{" "}
- added a note about deal{" "}
+ {translate("crm.activity.added_note_about_deal", {
+ _: "added a note about deal",
+ })}{" "}
<ReferenceField
source="deal_id"
reference="deals"
@@ -57,7 +60,7 @@ export function ActivityLogDealNoteCreated({
{context !== "company" && (
<>
{" "}
- at{" "}
+ {translate("crm.common.at", { _: "at" })}{" "}
<ReferenceField
source="deal_id"
reference="deals"
diff --git a/src/components/atomic-crm/activity/ActivityLogIterator.tsx b/src/components/atomic-crm/activity/ActivityLogIterator.tsx
index 05bf83f8..dc9f9cb8 100644
--- a/src/components/atomic-crm/activity/ActivityLogIterator.tsx
+++ b/src/components/atomic-crm/activity/ActivityLogIterator.tsx
@@ -1,4 +1,5 @@
import { Fragment, useState } from "react";
+import { useTranslate } from "ra-core";
import { Separator } from "@/components/ui/separator";
import {
@@ -25,6 +26,7 @@ export function ActivityLogIterator({
pageSize,
}: ActivityLogIteratorProps) {
const [activitiesDisplayed, setActivityDisplayed] = useState(pageSize);
+ const translate = useTranslate();
const filteredActivities = activities.slice(0, activitiesDisplayed);
@@ -48,7 +50,7 @@ export function ActivityLogIterator({
}}
className="flex w-full justify-center text-sm underline hover:no-underline"
>
- Load more activity
+ {translate("crm.activity.load_more", { _: "Load more activity" })}
</a>
)}
</div>
diff --git a/src/components/atomic-crm/companies/AutocompleteCompanyInput.tsx b/src/components/atomic-crm/companies/AutocompleteCompanyInput.tsx
index 5e611e91..2a29cd56 100644
--- a/src/components/atomic-crm/companies/AutocompleteCompanyInput.tsx
+++ b/src/components/atomic-crm/companies/AutocompleteCompanyInput.tsx
@@ -1,14 +1,16 @@
-import { useCreate, useGetIdentity, useNotify } from "ra-core";
+import { useCreate, useGetIdentity, useNotify, useTranslate } from "ra-core";
import { AutocompleteInput } from "@/components/admin/autocomplete-input";
import type { InputProps } from "ra-core";
import { useIsMobile } from "@/hooks/use-mobile";
export const AutocompleteCompanyInput = ({
validate,
-}: Pick<InputProps, "validate">) => {
+ label,
+}: Pick<InputProps, "validate" | "label">) => {
const [create] = useCreate();
const { identity } = useGetIdentity();
const notify = useNotify();
+ const translate = useTranslate();
const handleCreateCompany = async (name?: string) => {
if (!name) return;
try {
@@ -25,8 +27,11 @@ export const AutocompleteCompanyInput = ({
);
return newCompany;
} catch {
- notify("An error occurred while creating the company", {
+ notify("crm.companies.autocomplete.create_error", {
type: "error",
+ messageArgs: {
+ _: "An error occurred while creating the company",
+ },
});
}
};
@@ -34,11 +39,16 @@ export const AutocompleteCompanyInput = ({
return (
<AutocompleteInput
+ label={label}
optionText="name"
helperText={false}
onCreate={handleCreateCompany}
- createItemLabel="Create %{item}"
- createLabel="Start typing to create a new company"
+ createItemLabel={translate("crm.companies.autocomplete.create_item", {
+ _: "Create %{item}",
+ })}
+ createLabel={translate("crm.companies.autocomplete.create_label", {
+ _: "Start typing to create a new company",
+ })}
validate={validate}
modal={isMobile}
/>
diff --git a/src/components/atomic-crm/companies/CompanyAside.tsx b/src/components/atomic-crm/companies/CompanyAside.tsx
index 7e70ee7c..d5f7a6b3 100644
--- a/src/components/atomic-crm/companies/CompanyAside.tsx
+++ b/src/components/atomic-crm/companies/CompanyAside.tsx
@@ -13,6 +13,8 @@ import { AsideSection } from "../misc/AsideSection";
import { useConfigurationContext } from "../root/ConfigurationContext";
import { SaleName } from "../sales/SaleName";
import type { Company } from "../types";
+import { getTranslatedCompanySectorLabel } from "./getTranslatedCompanySectorLabel";
+import { getTranslatedCompanySizeLabel } from "./getTranslatedCompanySizeLabel";
import { sizes } from "./sizes";
interface CompanyAsideProps {
@@ -118,9 +120,14 @@ export const ContextInfo = ({ record }: { record: Company }) => {
return null;
}
- const sectorLabel = companySectors.find(
- (s) => s.value === record.sector,
- )?.label;
+ const sector = companySectors.find((s) => s.value === record.sector);
+ const sectorLabel = sector
+ ? getTranslatedCompanySectorLabel(sector, translate)
+ : undefined;
+ const translatedSizes = sizes.map((size) => ({
+ ...size,
+ name: getTranslatedCompanySizeLabel(size, translate),
+ }));
return (
<AsideSection
@@ -135,7 +142,7 @@ export const ContextInfo = ({ record }: { record: Company }) => {
{record.size && (
<span>
{translate("crm.companies.fields.size", { _: "Size" })}:{" "}
- <SelectField source="size" choices={sizes} />
+ <SelectField source="size" choices={translatedSizes} />
</span>
)}
{record.revenue && (
diff --git a/src/components/atomic-crm/companies/CompanyCard.tsx b/src/components/atomic-crm/companies/CompanyCard.tsx
index faa33317..55c28eaf 100644
--- a/src/components/atomic-crm/companies/CompanyCard.tsx
+++ b/src/components/atomic-crm/companies/CompanyCard.tsx
@@ -1,23 +1,31 @@
import { DollarSign } from "lucide-react";
import { Link } from "react-router";
-import { useCreatePath, useListContext, useRecordContext } from "ra-core";
+import {
+ useCreatePath,
+ useListContext,
+ useRecordContext,
+ useTranslate,
+} from "ra-core";
import { ReferenceManyField } from "@/components/admin/reference-many-field";
import { Card } from "@/components/ui/card";
import { Avatar as ContactAvatar } from "../contacts/Avatar";
import { useConfigurationContext } from "../root/ConfigurationContext";
import type { Company } from "../types";
+import { getTranslatedCompanySectorLabel } from "./getTranslatedCompanySectorLabel";
import { CompanyAvatar } from "./CompanyAvatar";
export const CompanyCard = (props: { record?: Company }) => {
const createPath = useCreatePath();
const record = useRecordContext<Company>(props);
const { companySectors } = useConfigurationContext();
+ const translate = useTranslate();
if (!record) return null;
- const sectorLabel = companySectors.find(
- (s) => s.value === record.sector,
- )?.label;
+ const sector = companySectors.find((s) => s.value === record.sector);
+ const sectorLabel = sector
+ ? getTranslatedCompanySectorLabel(sector, translate)
+ : undefined;
return (
<Link
diff --git a/src/components/atomic-crm/companies/CompanyInputs.tsx b/src/components/atomic-crm/companies/CompanyInputs.tsx
index b58e9eee..5c4e4867 100644
--- a/src/components/atomic-crm/companies/CompanyInputs.tsx
+++ b/src/components/atomic-crm/companies/CompanyInputs.tsx
@@ -11,6 +11,8 @@ import ImageEditorField from "../misc/ImageEditorField";
import { isLinkedinUrl } from "../misc/isLinkedInUrl";
import { useConfigurationContext } from "../root/ConfigurationContext";
import type { Company, Sale } from "../types";
+import { getTranslatedCompanySectorLabel } from "./getTranslatedCompanySectorLabel";
+import { getTranslatedCompanySizeLabel } from "./getTranslatedCompanySizeLabel";
import { sizes } from "./sizes";
const isUrl = (url: string) => {
@@ -63,6 +65,7 @@ const CompanyDisplayInputs = () => {
className="w-full h-fit"
validate={required()}
helperText={false}
+ label="crm.companies.fields.name"
placeholder={translate("crm.companies.fields.name", {
_: "Company name",
})}
@@ -78,13 +81,23 @@ const CompanyContactInputs = () => {
<h6 className="text-lg font-semibold">
{translate("crm.companies.inputs.contact", { _: "Contact" })}
</h6>
- <TextInput source="website" helperText={false} validate={isUrl} />
+ <TextInput
+ source="website"
+ label="crm.companies.fields.website"
+ helperText={false}
+ validate={isUrl}
+ />
<TextInput
source="linkedin_url"
+ label="crm.companies.fields.linkedin_url"
helperText={false}
validate={isLinkedinUrl}
/>
- <TextInput source="phone_number" helperText={false} />
+ <TextInput
+ source="phone_number"
+ label="crm.companies.fields.phone_number"
+ helperText={false}
+ />
</div>
);
};
@@ -92,6 +105,14 @@ const CompanyContactInputs = () => {
const CompanyContextInputs = () => {
const translate = useTranslate();
const { companySectors } = useConfigurationContext();
+ const translatedCompanySectors = companySectors.map((sector) => ({
+ ...sector,
+ label: getTranslatedCompanySectorLabel(sector, translate),
+ }));
+ const translatedSizes = sizes.map((size) => ({
+ ...size,
+ name: getTranslatedCompanySizeLabel(size, translate),
+ }));
return (
<div className="flex flex-col gap-4">
<h6 className="text-lg font-semibold">
@@ -99,14 +120,28 @@ const CompanyContextInputs = () => {
</h6>
<SelectInput
source="sector"
- choices={companySectors}
+ label="crm.companies.fields.sector"
+ choices={translatedCompanySectors}
optionText="label"
optionValue="value"
helperText={false}
/>
- <SelectInput source="size" choices={sizes} helperText={false} />
- <TextInput source="revenue" helperText={false} />
- <TextInput source="tax_identifier" helperText={false} />
+ <SelectInput
+ source="size"
+ label="crm.companies.fields.size"
+ choices={translatedSizes}
+ helperText={false}
+ />
+ <TextInput
+ source="revenue"
+ label="crm.companies.fields.revenue"
+ helperText={false}
+ />
+ <TextInput
+ source="tax_identifier"
+ label="crm.companies.fields.tax_identifier"
+ helperText={false}
+ />
</div>
);
};
@@ -118,11 +153,31 @@ const CompanyAddressInputs = () => {
<h6 className="text-lg font-semibold">
{translate("crm.companies.inputs.address", { _: "Address" })}
</h6>
- <TextInput source="address" helperText={false} />
- <TextInput source="city" helperText={false} />
- <TextInput source="zipcode" helperText={false} />
- <TextInput source="state_abbr" helperText={false} />
- <TextInput source="country" helperText={false} />
+ <TextInput
+ source="address"
+ label="crm.companies.fields.address"
+ helperText={false}
+ />
+ <TextInput
+ source="city"
+ label="crm.companies.fields.city"
+ helperText={false}
+ />
+ <TextInput
+ source="zipcode"
+ label="crm.companies.fields.zipcode"
+ helperText={false}
+ />
+ <TextInput
+ source="state_abbr"
+ label="crm.companies.fields.state_abbr"
+ helperText={false}
+ />
+ <TextInput
+ source="country"
+ label="crm.companies.fields.country"
+ helperText={false}
+ />
</div>
);
};
@@ -136,8 +191,17 @@ const CompanyAdditionalInformationInputs = () => {
_: "Additional information",
})}
</h6>
- <TextInput source="description" multiline helperText={false} />
- <ArrayInput source="context_links" helperText={false}>
+ <TextInput
+ source="description"
+ label="crm.companies.fields.description"
+ multiline
+ helperText={false}
+ />
+ <ArrayInput
+ source="context_links"
+ label="crm.companies.fields.context_links"
+ helperText={false}
+ >
<SimpleFormIterator disableReordering fullWidth getItemLabel={false}>
<TextInput
source=""
diff --git a/src/components/atomic-crm/companies/CompanyListFilter.tsx b/src/components/atomic-crm/companies/CompanyListFilter.tsx
index 4b2d44bd..f7102768 100644
--- a/src/components/atomic-crm/companies/CompanyListFilter.tsx
+++ b/src/components/atomic-crm/companies/CompanyListFilter.tsx
@@ -5,12 +5,22 @@ import { SearchInput } from "@/components/admin/search-input";
import { FilterCategory } from "../filters/FilterCategory";
import { useConfigurationContext } from "../root/ConfigurationContext";
+import { getTranslatedCompanySectorLabel } from "./getTranslatedCompanySectorLabel";
+import { getTranslatedCompanySizeLabel } from "./getTranslatedCompanySizeLabel";
import { sizes } from "./sizes";
export const CompanyListFilter = () => {
const { identity } = useGetIdentity();
const { companySectors } = useConfigurationContext();
const translate = useTranslate();
+ const translatedSizes = sizes.map((size) => ({
+ ...size,
+ name: getTranslatedCompanySizeLabel(size, translate),
+ }));
+ const translatedSectors = companySectors.map((sector) => ({
+ ...sector,
+ label: getTranslatedCompanySectorLabel(sector, translate),
+ }));
return (
<div className="w-52 min-w-52 flex flex-col gap-8">
<FilterLiveForm>
@@ -21,7 +31,7 @@ export const CompanyListFilter = () => {
icon={<Building className="h-4 w-4" />}
label={translate("crm.companies.filters.size", { _: "Size" })}
>
- {sizes.map((size) => (
+ {translatedSizes.map((size) => (
<ToggleFilterButton
className="w-full justify-between"
label={size.name}
@@ -35,7 +45,7 @@ export const CompanyListFilter = () => {
icon={<Truck className="h-4 w-4" />}
label={translate("crm.companies.filters.sector", { _: "Sector" })}
>
- {companySectors.map((sector) => (
+ {translatedSectors.map((sector) => (
<ToggleFilterButton
className="w-full justify-between"
label={sector.label}
diff --git a/src/components/atomic-crm/companies/CompanyShow.tsx b/src/components/atomic-crm/companies/CompanyShow.tsx
index 8077127d..f9eb1086 100644
--- a/src/components/atomic-crm/companies/CompanyShow.tsx
+++ b/src/components/atomic-crm/companies/CompanyShow.tsx
@@ -294,7 +294,7 @@ const DealsIterator = () => {
<div className="flex-1 min-w-0">
<div className="font-medium">{deal.name}</div>
<div className="text-sm text-muted-foreground">
- {findDealLabel(dealStages, deal.stage)},{" "}
+ {findDealLabel(dealStages, deal.stage, translate)},{" "}
{deal.amount.toLocaleString("en-US", {
notation: "compact",
style: "currency",
diff --git a/src/components/atomic-crm/companies/getTranslatedCompanySectorLabel.ts b/src/components/atomic-crm/companies/getTranslatedCompanySectorLabel.ts
new file mode 100644
index 00000000..33650f49
--- /dev/null
+++ b/src/components/atomic-crm/companies/getTranslatedCompanySectorLabel.ts
@@ -0,0 +1,32 @@
+type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
+
+const defaultCompanySectorLabels: Record<string, string> = {
+ "communication-services": "Communication Services",
+ "consumer-discretionary": "Consumer Discretionary",
+ "consumer-staples": "Consumer Staples",
+ energy: "Energy",
+ financials: "Financials",
+ "health-care": "Health Care",
+ industrials: "Industrials",
+ "information-technology": "Information Technology",
+ materials: "Materials",
+ "real-estate": "Real Estate",
+ utilities: "Utilities",
+};
+
+const getCompanySectorTranslationKey = (sectorValue: string) =>
+ `crm.companies.sectors.${sectorValue.replaceAll("-", "_")}`;
+
+export const getTranslatedCompanySectorLabel = (
+ sector: { value: string; label: string },
+ translate: TranslateFn,
+) => {
+ const defaultLabel = defaultCompanySectorLabels[sector.value];
+ if (!defaultLabel || sector.label !== defaultLabel) {
+ return sector.label;
+ }
+
+ return translate(getCompanySectorTranslationKey(sector.value), {
+ _: sector.label,
+ });
+};
diff --git a/src/components/atomic-crm/companies/getTranslatedCompanySizeLabel.ts b/src/components/atomic-crm/companies/getTranslatedCompanySizeLabel.ts
new file mode 100644
index 00000000..28553bb2
--- /dev/null
+++ b/src/components/atomic-crm/companies/getTranslatedCompanySizeLabel.ts
@@ -0,0 +1,30 @@
+type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
+
+const defaultCompanySizeLabels: Record<number, string> = {
+ 1: "1 employee",
+ 10: "2-9 employees",
+ 50: "10-49 employees",
+ 250: "50-249 employees",
+ 500: "250 or more employees",
+};
+
+const companySizeTranslationKeys: Record<number, string> = {
+ 1: "crm.companies.sizes.one_employee",
+ 10: "crm.companies.sizes.two_to_nine_employees",
+ 50: "crm.companies.sizes.ten_to_forty_nine_employees",
+ 250: "crm.companies.sizes.fifty_to_two_hundred_forty_nine_employees",
+ 500: "crm.companies.sizes.two_hundred_fifty_or_more_employees",
+};
+
+export const getTranslatedCompanySizeLabel = (
+ size: { id: number; name: string },
+ translate: TranslateFn,
+) => {
+ const defaultLabel = defaultCompanySizeLabels[size.id];
+ const translationKey = companySizeTranslationKeys[size.id];
+ if (!defaultLabel || !translationKey || size.name !== defaultLabel) {
+ return size.name;
+ }
+
+ return translate(translationKey, { _: size.name });
+};
diff --git a/src/components/atomic-crm/contacts/ContactCreateSheet.tsx b/src/components/atomic-crm/contacts/ContactCreateSheet.tsx
index fbb798c4..42821f2b 100644
--- a/src/components/atomic-crm/contacts/ContactCreateSheet.tsx
+++ b/src/components/atomic-crm/contacts/ContactCreateSheet.tsx
@@ -1,4 +1,4 @@
-import { useGetIdentity } from "ra-core";
+import { useGetIdentity, useTranslate } from "ra-core";
import { CreateSheet } from "../misc/CreateSheet";
import { ContactInputs } from "./ContactInputs";
import type { Contact } from "../types";
@@ -13,10 +13,11 @@ export const ContactCreateSheet = ({
onOpenChange,
}: ContactCreateSheetProps) => {
const { identity } = useGetIdentity();
+ const translate = useTranslate();
return (
<CreateSheet
resource="contacts"
- title="Create Contact"
+ title={translate("crm.contacts.action.new", { _: "New Contact" })}
defaultValues={{ sales_id: identity?.id }}
transform={(data: Contact) => ({
...data,
diff --git a/src/components/atomic-crm/contacts/ContactEditSheet.tsx b/src/components/atomic-crm/contacts/ContactEditSheet.tsx
index b556deb7..643525c9 100644
--- a/src/components/atomic-crm/contacts/ContactEditSheet.tsx
+++ b/src/components/atomic-crm/contacts/ContactEditSheet.tsx
@@ -1,4 +1,4 @@
-import { RecordRepresentation, type Identifier } from "ra-core";
+import { RecordRepresentation, useTranslate, type Identifier } from "ra-core";
import { EditSheet } from "../misc/EditSheet";
import { ContactInputs } from "./ContactInputs";
@@ -13,13 +13,15 @@ export const ContactEditSheet = ({
onOpenChange,
contactId,
}: ContactEditSheetProps) => {
+ const translate = useTranslate();
return (
<EditSheet
resource="contacts"
id={contactId}
title={
<h1 className="text-xl font-semibold truncate pr-10">
- Edit <RecordRepresentation />
+ {translate("crm.contacts.action.edit", { _: "Edit contact" })}{" "}
+ <RecordRepresentation />
</h1>
}
open={open}
diff --git a/src/components/atomic-crm/contacts/ContactInputs.tsx b/src/components/atomic-crm/contacts/ContactInputs.tsx
index ba4ec976..798721ba 100644
--- a/src/components/atomic-crm/contacts/ContactInputs.tsx
+++ b/src/components/atomic-crm/contacts/ContactInputs.tsx
@@ -16,6 +16,8 @@ import { contactGender } from "./contactGender";
import type { Sale } from "../types";
import { Avatar } from "./Avatar";
import { AutocompleteCompanyInput } from "../companies/AutocompleteCompanyInput.tsx";
+import { getTranslatedContactGenderLabel } from "./getTranslatedContactGenderLabel";
+import { getTranslatedPersonalInfoTypeLabel } from "./getTranslatedPersonalInfoTypeLabel";
export const ContactInputs = () => {
const isMobile = useIsMobile();
@@ -55,12 +57,25 @@ const ContactIdentityInputs = () => {
source="gender"
choices={contactGender}
helperText={false}
- optionText="label"
+ optionText={(choice) =>
+ getTranslatedContactGenderLabel(choice, translate)
+ }
+ translateChoice={false}
optionValue="value"
defaultValue={contactGender[0].value}
/>
- <TextInput source="first_name" validate={required()} helperText={false} />
- <TextInput source="last_name" validate={required()} helperText={false} />
+ <TextInput
+ source="first_name"
+ label="crm.contacts.inputs.first_name"
+ validate={required()}
+ helperText={false}
+ />
+ <TextInput
+ source="last_name"
+ label="crm.contacts.inputs.last_name"
+ validate={required()}
+ helperText={false}
+ />
</div>
);
};
@@ -72,9 +87,13 @@ const ContactPositionInputs = () => {
<h6 className="text-lg font-semibold">
{translate("crm.contacts.inputs.position", { _: "Position" })}
</h6>
- <TextInput source="title" helperText={false} />
+ <TextInput
+ source="title"
+ label="crm.contacts.inputs.title"
+ helperText={false}
+ />
<ReferenceInput source="company_id" reference="companies" perPage={10}>
- <AutocompleteCompanyInput />
+ <AutocompleteCompanyInput label="crm.contacts.inputs.company" />
</ReferenceInput>
</div>
);
@@ -83,6 +102,20 @@ const ContactPositionInputs = () => {
const ContactPersonalInformationInputs = () => {
const translate = useTranslate();
const { getValues, setValue } = useFormContext();
+ const personalInfoTypes = [
+ {
+ id: "Work",
+ name: getTranslatedPersonalInfoTypeLabel("Work", translate),
+ },
+ {
+ id: "Home",
+ name: getTranslatedPersonalInfoTypeLabel("Home", translate),
+ },
+ {
+ id: "Other",
+ name: getTranslatedPersonalInfoTypeLabel("Other", translate),
+ },
+ ];
// set first and last name based on email
const handleEmailChange = (email: string) => {
@@ -140,7 +173,7 @@ const ContactPersonalInformationInputs = () => {
source="type"
helperText={false}
label={false}
- optionText="id"
+ optionText="name"
choices={personalInfoTypes}
defaultValue="Work"
className="w-24 min-w-24"
@@ -171,7 +204,7 @@ const ContactPersonalInformationInputs = () => {
source="type"
helperText={false}
label={false}
- optionText="id"
+ optionText="name"
choices={personalInfoTypes}
defaultValue="Work"
className="w-24 min-w-24"
@@ -188,8 +221,6 @@ const ContactPersonalInformationInputs = () => {
);
};
-const personalInfoTypes = [{ id: "Work" }, { id: "Home" }, { id: "Other" }];
-
const ContactMiscInputs = () => {
const translate = useTranslate();
return (
@@ -203,7 +234,11 @@ const ContactMiscInputs = () => {
multiline
helperText={false}
/>
- <BooleanInput source="has_newsletter" helperText={false} />
+ <BooleanInput
+ source="has_newsletter"
+ label="crm.contacts.inputs.has_newsletter"
+ helperText={false}
+ />
<ReferenceInput
reference="sales"
source="sales_id"
diff --git a/src/components/atomic-crm/contacts/ContactListContent.tsx b/src/components/atomic-crm/contacts/ContactListContent.tsx
index 02f6845f..14ae3457 100644
--- a/src/components/atomic-crm/contacts/ContactListContent.tsx
+++ b/src/components/atomic-crm/contacts/ContactListContent.tsx
@@ -1,4 +1,3 @@
-import { formatRelative } from "date-fns";
import { difference, union } from "lodash";
import {
type Identifier,
@@ -18,6 +17,7 @@ import { Button } from "@/components/ui/button";
import { RotateCcw } from "lucide-react";
import { Status } from "../misc/Status";
+import { RelativeDate } from "../misc/RelativeDate";
import type { Contact } from "../types";
import { Avatar } from "./Avatar";
import { TagsList } from "./TagsList";
@@ -105,7 +105,6 @@ const ContactItemContent = ({
}) => {
const translate = useTranslate();
const { selectedIds } = useListContext<Contact>();
- const now = Date.now();
return (
<div className="flex flex-row items-center pl-2 pr-4 py-2 hover:bg-muted transition-colors first:rounded-t-xl last:rounded-b-xl">
@@ -160,7 +159,7 @@ const ContactItemContent = ({
title={contact.last_seen}
>
{`${translate("crm.common.last_activity", { _: "last activity" })} `}
- {formatRelative(contact.last_seen, now)}{" "}
+ <RelativeDate date={contact.last_seen} />{" "}
<Status status={contact.status} />
</div>
</div>
diff --git a/src/components/atomic-crm/contacts/ContactPersonalInfo.tsx b/src/components/atomic-crm/contacts/ContactPersonalInfo.tsx
index 507c5148..4896bfeb 100644
--- a/src/components/atomic-crm/contacts/ContactPersonalInfo.tsx
+++ b/src/components/atomic-crm/contacts/ContactPersonalInfo.tsx
@@ -1,4 +1,4 @@
-import { useRecordContext, WithRecord } from "ra-core";
+import { useRecordContext, useTranslate, WithRecord } from "ra-core";
import { ArrayField } from "@/components/admin/array-field";
import { SingleFieldList } from "@/components/admin/single-field-list";
import { TextField } from "@/components/admin/text-field";
@@ -6,10 +6,13 @@ import { EmailField } from "@/components/admin/email-field";
import { Mail, Phone, Linkedin } from "lucide-react";
import type { ReactNode } from "react";
import { contactGender } from "./contactGender";
+import { getTranslatedContactGenderLabel } from "./getTranslatedContactGenderLabel";
+import { getTranslatedPersonalInfoTypeLabel } from "./getTranslatedPersonalInfoTypeLabel";
import type { Contact } from "../types";
export const ContactPersonalInfo = () => {
const record = useRecordContext<Contact>();
+ const translate = useTranslate();
if (!record) return null;
@@ -26,7 +29,9 @@ export const ContactPersonalInfo = () => {
{record.has_newsletter && (
<p className="pl-6 py-1 text-sm text-muted-foreground">
- Subscribed to newsletter
+ {translate("crm.contacts.inputs.subscribed_newsletter", {
+ _: "Subscribed to newsletter",
+ })}
</p>
)}
@@ -64,7 +69,11 @@ export const ContactPersonalInfo = () => {
icon={
<genderOption.icon className="w-4 h-4 text-muted-foreground" />
}
- primary={<div>{genderOption.label}</div>}
+ primary={
+ <div>
+ {getTranslatedContactGenderLabel(genderOption, translate)}
+ </div>
+ }
/>
);
}
@@ -92,7 +101,9 @@ const PersonalInfoRow = ({
<WithRecord
render={(row) =>
row.type !== "Other" && (
- <TextField source="type" className="text-muted-foreground" />
+ <span className="text-muted-foreground">
+ {getTranslatedPersonalInfoTypeLabel(row.type, translate)}
+ </span>
)
}
/>
diff --git a/src/components/atomic-crm/contacts/TagsListEdit.tsx b/src/components/atomic-crm/contacts/TagsListEdit.tsx
index 9af046bb..1d9ac627 100644
--- a/src/components/atomic-crm/contacts/TagsListEdit.tsx
+++ b/src/components/atomic-crm/contacts/TagsListEdit.tsx
@@ -3,6 +3,7 @@ import {
useGetList,
useGetMany,
useRecordContext,
+ useTranslate,
useUpdate,
type Identifier,
} from "ra-core";
@@ -23,6 +24,7 @@ import type { Contact, Tag } from "../types";
export const TagsListEdit = () => {
const record = useRecordContext<Contact>();
const [open, setOpen] = useState(false);
+ const translate = useTranslate();
const { data: allTags, isPending: isPendingAllTags } = useGetList<Tag>(
"tags",
@@ -117,7 +119,7 @@ export const TagsListEdit = () => {
className="h-9 md:h-6 cursor-pointer"
>
<Plus className="w-4 h-4 md:w-3 md:h-3 mr-1" />
- Add tag
+ {translate("crm.tags.action.add", { _: "Add tag" })}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
@@ -144,7 +146,9 @@ export const TagsListEdit = () => {
className="w-full justify-start p-0 cursor-pointer text-base md:text-sm"
>
<Edit className="w-4 h-4 md:w-3 md:h-3 mr-2" />
- Create new tag
+ {translate("crm.tags.action.create_new", {
+ _: "Create new tag",
+ })}
</Button>
</DropdownMenuItem>
</DropdownMenuContent>
diff --git a/src/components/atomic-crm/contacts/contactGender.ts b/src/components/atomic-crm/contacts/contactGender.ts
index 1e7f11ac..3998a797 100644
--- a/src/components/atomic-crm/contacts/contactGender.ts
+++ b/src/components/atomic-crm/contacts/contactGender.ts
@@ -2,8 +2,18 @@ import { Mars, NonBinary, Venus } from "lucide-react";
import type { ContactGender } from "../types";
+export const contactGenderDefaultLabels: Record<string, string> = {
+ male: "He/Him",
+ female: "She/Her",
+ nonbinary: "They/Them",
+};
+
export const contactGender: ContactGender[] = [
- { value: "male", label: "He/Him", icon: Mars },
- { value: "female", label: "She/Her", icon: Venus },
- { value: "nonbinary", label: "They/Them", icon: NonBinary },
+ { value: "male", label: "crm.contacts.inputs.genders.male", icon: Mars },
+ { value: "female", label: "crm.contacts.inputs.genders.female", icon: Venus },
+ {
+ value: "nonbinary",
+ label: "crm.contacts.inputs.genders.nonbinary",
+ icon: NonBinary,
+ },
];
diff --git a/src/components/atomic-crm/contacts/getTranslatedContactGenderLabel.ts b/src/components/atomic-crm/contacts/getTranslatedContactGenderLabel.ts
new file mode 100644
index 00000000..1e357cba
--- /dev/null
+++ b/src/components/atomic-crm/contacts/getTranslatedContactGenderLabel.ts
@@ -0,0 +1,11 @@
+import { contactGenderDefaultLabels } from "./contactGender";
+
+type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
+
+export const getTranslatedContactGenderLabel = (
+ gender: { value: string; label: string },
+ translate: TranslateFn,
+) =>
+ translate(gender.label, {
+ _: contactGenderDefaultLabels[gender.value] ?? gender.label,
+ });
diff --git a/src/components/atomic-crm/contacts/getTranslatedPersonalInfoTypeLabel.ts b/src/components/atomic-crm/contacts/getTranslatedPersonalInfoTypeLabel.ts
new file mode 100644
index 00000000..c159c09f
--- /dev/null
+++ b/src/components/atomic-crm/contacts/getTranslatedPersonalInfoTypeLabel.ts
@@ -0,0 +1,18 @@
+type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
+
+const personalInfoTypeMap: Record<string, string> = {
+ Work: "work",
+ Home: "home",
+ Other: "other",
+};
+
+export const getTranslatedPersonalInfoTypeLabel = (
+ type: string,
+ translate: TranslateFn,
+) =>
+ translate(
+ `crm.contacts.inputs.personal_info_types.${personalInfoTypeMap[type] ?? type.toLowerCase()}`,
+ {
+ _: type,
+ },
+ );
diff --git a/src/components/atomic-crm/dashboard/DashboardActivityLog.tsx b/src/components/atomic-crm/dashboard/DashboardActivityLog.tsx
index e4c4bd9e..f68b4b37 100644
--- a/src/components/atomic-crm/dashboard/DashboardActivityLog.tsx
+++ b/src/components/atomic-crm/dashboard/DashboardActivityLog.tsx
@@ -1,4 +1,5 @@
import { Clock } from "lucide-react";
+import { useTranslate } from "ra-core";
import { Card } from "@/components/ui/card";
import { useIsMobile } from "@/hooks/use-mobile";
@@ -6,6 +7,7 @@ import { ActivityLog } from "../activity/ActivityLog";
export function DashboardActivityLog() {
const isMobile = useIsMobile();
+ const translate = useTranslate();
return (
<div className="flex flex-col">
<div className="flex items-center mb-4 md:mb-2">
@@ -13,7 +15,9 @@ export function DashboardActivityLog() {
<Clock className="text-muted-foreground w-6 h-6" />
</div>
<h2 className="text-xl font-semibold text-muted-foreground">
- Latest Activity
+ {translate("crm.dashboard.latest_activity", {
+ _: "Latest Activity",
+ })}
</h2>
</div>
{isMobile ? (
diff --git a/src/components/atomic-crm/dashboard/DealsPipeline.tsx b/src/components/atomic-crm/dashboard/DealsPipeline.tsx
index c71ba2cd..5fb80bb3 100644
--- a/src/components/atomic-crm/dashboard/DealsPipeline.tsx
+++ b/src/components/atomic-crm/dashboard/DealsPipeline.tsx
@@ -1,5 +1,5 @@
import { DollarSign } from "lucide-react";
-import { useGetIdentity, useGetList } from "ra-core";
+import { useGetIdentity, useGetList, useTranslate } from "ra-core";
import { Link } from "react-router";
import { ReferenceField } from "@/components/admin/reference-field";
import { Card } from "@/components/ui/card";
@@ -15,6 +15,7 @@ import type { Deal } from "../types";
* It's currently not used in the application but can be added to the dashboard.
*/
export const DealsPipeline = () => {
+ const translate = useTranslate();
const { identity } = useGetIdentity();
const { dealStages, dealPipelineStatuses } = useConfigurationContext();
const { data, total, isPending } = useGetList<Deal>(
@@ -52,7 +53,7 @@ export const DealsPipeline = () => {
className="text-xl font-semibold text-muted-foreground hover:underline"
to="/deals"
>
- Deals Pipeline
+ {translate("crm.dashboard.deals_pipeline", { _: "Deals Pipeline" })}
</Link>
</div>
<Card>
@@ -70,7 +71,7 @@ export const DealsPipeline = () => {
currency: "USD",
currencyDisplay: "narrowSymbol",
minimumSignificantDigits: 3,
- })} , ${findDealLabel(dealStages, deal.stage)}`
+ })} , ${findDealLabel(dealStages, deal.stage, translate)}`
}
leftAvatar={(deal) => (
<ReferenceField
diff --git a/src/components/atomic-crm/dashboard/TasksList.tsx b/src/components/atomic-crm/dashboard/TasksList.tsx
index 546a6460..cd07d4dc 100644
--- a/src/components/atomic-crm/dashboard/TasksList.tsx
+++ b/src/components/atomic-crm/dashboard/TasksList.tsx
@@ -1,10 +1,12 @@
import { CheckSquare } from "lucide-react";
+import { useTranslate } from "ra-core";
import { Card } from "@/components/ui/card";
import { AddTask } from "../tasks/AddTask";
import { TasksListContent } from "../tasks/TasksListContent";
export const TasksList = () => {
+ const translate = useTranslate();
return (
<div className="flex flex-col gap-2">
<div className="flex items-center">
@@ -12,7 +14,9 @@ export const TasksList = () => {
<CheckSquare className="text-muted-foreground w-6 h-6" />
</div>
<h2 className="text-xl font-semibold text-muted-foreground flex-1">
- Upcoming Tasks
+ {translate("crm.dashboard.upcoming_tasks", {
+ _: "Upcoming Tasks",
+ })}
</h2>
<AddTask display="icon" selectContact />
</div>
diff --git a/src/components/atomic-crm/deals/DealColumn.tsx b/src/components/atomic-crm/deals/DealColumn.tsx
index 65502621..ab925b44 100644
--- a/src/components/atomic-crm/deals/DealColumn.tsx
+++ b/src/components/atomic-crm/deals/DealColumn.tsx
@@ -1,4 +1,5 @@
import { Droppable } from "@hello-pangea/dnd";
+import { useTranslate } from "ra-core";
import { useConfigurationContext } from "../root/ConfigurationContext";
import type { Deal } from "../types";
@@ -13,13 +14,14 @@ export const DealColumn = ({
deals: Deal[];
}) => {
const totalAmount = deals.reduce((sum, deal) => sum + deal.amount, 0);
+ const translate = useTranslate();
const { dealStages } = useConfigurationContext();
return (
<div className="flex-1 pb-8">
<div className="flex flex-col items-center">
<h3 className="text-base font-medium">
- {findDealLabel(dealStages, stage)}
+ {findDealLabel(dealStages, stage, translate)}
</h3>
<p className="text-sm text-muted-foreground">
{totalAmount.toLocaleString("en-US", {
diff --git a/src/components/atomic-crm/deals/DealInputs.tsx b/src/components/atomic-crm/deals/DealInputs.tsx
index 3ec667ff..b3244eb4 100644
--- a/src/components/atomic-crm/deals/DealInputs.tsx
+++ b/src/components/atomic-crm/deals/DealInputs.tsx
@@ -12,6 +12,7 @@ import { useIsMobile } from "@/hooks/use-mobile";
import { contactOptionText } from "../misc/ContactOption";
import { useConfigurationContext } from "../root/ConfigurationContext";
import { AutocompleteCompanyInput } from "../companies/AutocompleteCompanyInput.tsx";
+import { getTranslatedDealStageLabel } from "./getTranslatedDealStageLabel";
export const DealInputs = () => {
const isMobile = useIsMobile();
@@ -67,6 +68,10 @@ const DealLinkedToInputs = () => {
const DealMiscInputs = () => {
const translate = useTranslate();
const { dealStages, dealCategories } = useConfigurationContext();
+ const translatedDealStages = dealStages.map((stage) => ({
+ ...stage,
+ label: getTranslatedDealStageLabel(stage, translate),
+ }));
return (
<div className="flex flex-col gap-4 flex-1">
<h3 className="text-base font-medium">
@@ -95,7 +100,7 @@ const DealMiscInputs = () => {
/>
<SelectInput
source="stage"
- choices={dealStages}
+ choices={translatedDealStages}
optionText="label"
optionValue="value"
defaultValue="opportunity"
diff --git a/src/components/atomic-crm/deals/DealShow.tsx b/src/components/atomic-crm/deals/DealShow.tsx
index 5956686d..e9c2e782 100644
--- a/src/components/atomic-crm/deals/DealShow.tsx
+++ b/src/components/atomic-crm/deals/DealShow.tsx
@@ -141,7 +141,7 @@ const DealShowContent = () => {
{translate("crm.deals.fields.stage", { _: "Stage" })}
</span>
<span className="text-sm">
- {findDealLabel(dealStages, record.stage)}
+ {findDealLabel(dealStages, record.stage, translate)}
</span>
</div>
</div>
diff --git a/src/components/atomic-crm/deals/deal.ts b/src/components/atomic-crm/deals/deal.ts
index 681da742..b3989df0 100644
--- a/src/components/atomic-crm/deals/deal.ts
+++ b/src/components/atomic-crm/deals/deal.ts
@@ -1,5 +1,21 @@
import type { DealStage } from "../types";
+import { getTranslatedDealStageLabel } from "./getTranslatedDealStageLabel";
-export const findDealLabel = (dealStages: DealStage[], dealValue: string) => {
- return dealStages.find((dealStage) => dealStage.value === dealValue)?.label;
+type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
+
+export const findDealLabel = (
+ dealStages: DealStage[],
+ dealValue: string,
+ translate?: TranslateFn,
+) => {
+ const dealStage = dealStages.find((stage) => stage.value === dealValue);
+ if (!dealStage) {
+ return undefined;
+ }
+
+ if (!translate) {
+ return dealStage.label;
+ }
+
+ return getTranslatedDealStageLabel(dealStage, translate);
};
diff --git a/src/components/atomic-crm/deals/getTranslatedDealStageLabel.ts b/src/components/atomic-crm/deals/getTranslatedDealStageLabel.ts
new file mode 100644
index 00000000..a6f10d3c
--- /dev/null
+++ b/src/components/atomic-crm/deals/getTranslatedDealStageLabel.ts
@@ -0,0 +1,29 @@
+import type { DealStage } from "../types";
+
+type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
+
+const defaultDealStageLabels: Record<string, string> = {
+ opportunity: "Opportunity",
+ "proposal-sent": "Proposal Sent",
+ "in-negociation": "In Negotiation",
+ won: "Won",
+ lost: "Lost",
+ delayed: "Delayed",
+};
+
+const getDealStageTranslationKey = (stageValue: string) =>
+ `crm.deals.stages.${stageValue.replaceAll("-", "_")}`;
+
+export const getTranslatedDealStageLabel = (
+ stage: Pick<DealStage, "value" | "label">,
+ translate: TranslateFn,
+) => {
+ const defaultLabel = defaultDealStageLabels[stage.value];
+ if (!defaultLabel || stage.label !== defaultLabel) {
+ return stage.label;
+ }
+
+ return translate(getDealStageTranslationKey(stage.value), {
+ _: stage.label,
+ });
+};
diff --git a/src/components/atomic-crm/misc/RelativeDate.tsx b/src/components/atomic-crm/misc/RelativeDate.tsx
index c3b9eb15..081cf6b2 100644
--- a/src/components/atomic-crm/misc/RelativeDate.tsx
+++ b/src/components/atomic-crm/misc/RelativeDate.tsx
@@ -1,12 +1,16 @@
import { differenceInDays, formatRelative } from "date-fns";
+import { enUS, fr } from "date-fns/locale";
+import { useLocaleState } from "ra-core";
export function RelativeDate({ date }: { date: string }) {
+ const [locale = "en"] = useLocaleState();
const dateObj = new Date(date);
const now = new Date();
+ const dateFnsLocale = locale.startsWith("fr") ? fr : enUS;
if (differenceInDays(now, dateObj) > 6) {
- return dateObj.toLocaleDateString();
+ return new Intl.DateTimeFormat(locale).format(dateObj);
}
- return formatRelative(dateObj, now);
+ return formatRelative(dateObj, now, { locale: dateFnsLocale });
}
diff --git a/src/components/atomic-crm/root/englishCrmMessages.ts b/src/components/atomic-crm/root/englishCrmMessages.ts
index 9f85081d..82578b16 100644
--- a/src/components/atomic-crm/root/englishCrmMessages.ts
+++ b/src/components/atomic-crm/root/englishCrmMessages.ts
@@ -40,6 +40,16 @@ export const englishCrmMessages = {
me: "Me",
task_count: "task |||| tasks",
},
+ activity: {
+ you: "You",
+ added_company: "added company",
+ added_contact: "added",
+ added_note_about: "added a note about",
+ added_note_about_deal: "added a note about deal",
+ added_deal: "added deal",
+ to: "to",
+ load_more: "Load more activity",
+ },
companies: {
empty: {
description: "It seems your company list is empty.",
@@ -76,16 +86,51 @@ export const englishCrmMessages = {
},
fields: {
name: "Company name",
+ website: "Website",
+ linkedin_url: "LinkedIn URL",
+ phone_number: "Phone number",
revenue: "Revenue",
sector: "Sector",
size: "Size",
tax_identifier: "Tax Identifier",
+ address: "Address",
+ city: "City",
+ zipcode: "Zip code",
+ state_abbr: "State",
+ country: "Country",
+ description: "Description",
+ context_links: "Context links",
},
filters: {
only_mine: "Only companies I manage",
sector: "Sector",
size: "Size",
},
+ sectors: {
+ communication_services: "Communication Services",
+ consumer_discretionary: "Consumer Discretionary",
+ consumer_staples: "Consumer Staples",
+ energy: "Energy",
+ financials: "Financials",
+ health_care: "Health Care",
+ industrials: "Industrials",
+ information_technology: "Information Technology",
+ materials: "Materials",
+ real_estate: "Real Estate",
+ utilities: "Utilities",
+ },
+ sizes: {
+ one_employee: "1 employee",
+ two_to_nine_employees: "2-9 employees",
+ ten_to_forty_nine_employees: "10-49 employees",
+ fifty_to_two_hundred_forty_nine_employees: "50-249 employees",
+ two_hundred_fifty_or_more_employees: "250 or more employees",
+ },
+ autocomplete: {
+ create_error: "An error occurred while creating the company",
+ create_item: "Create %{item}",
+ create_label: "Start typing to create a new company",
+ },
},
contacts: {
action: {
@@ -121,15 +166,31 @@ export const englishCrmMessages = {
},
inputs: {
background_info_short: "Background info",
+ first_name: "First name",
+ last_name: "Last name",
email: "Email",
identity: "Identity",
personal_info: "Personal info",
phone_number: "Phone number",
position: "Position",
+ title: "Title",
+ company: "Company",
email_addresses: "Email addresses",
phone_numbers: "Phone numbers",
linkedin_url: "LinkedIn URL",
background_info: "Background info (bio, how you met, etc)",
+ has_newsletter: "Has newsletter",
+ subscribed_newsletter: "Subscribed to newsletter",
+ genders: {
+ male: "He/Him",
+ female: "She/Her",
+ nonbinary: "They/Them",
+ },
+ personal_info_types: {
+ work: "Work",
+ home: "Home",
+ other: "Other",
+ },
},
list: {
error_loading: "Error loading contacts",
@@ -174,11 +235,15 @@ export const englishCrmMessages = {
},
},
dashboard: {
+ deals_pipeline: "Deals Pipeline",
+ latest_activity: "Latest Activity",
+ latest_activity_error: "Error loading latest activity",
stepper: {
install: "Install Atomic CRM",
progress: "%{step}/3 done",
whats_next: "What's next?",
},
+ upcoming_tasks: "Upcoming Tasks",
welcome: {
paragraph_1:
"is a template designed to help you quickly build your own CRM.",
@@ -235,6 +300,14 @@ export const englishCrmMessages = {
filters: {
company: "Company",
},
+ stages: {
+ opportunity: "Opportunity",
+ proposal_sent: "Proposal Sent",
+ in_negociation: "In Negotiation",
+ won: "Won",
+ lost: "Lost",
+ delayed: "Delayed",
+ },
},
header: {
import_data: "Import data",
@@ -372,7 +445,9 @@ export const englishCrmMessages = {
empty_list_hint: "Tasks added to your contacts will appear here.",
fields: {
due: "due",
+ due_date: "Due date",
description: "Description",
+ type: "Type",
},
filters: {
later: "Later",
@@ -385,6 +460,17 @@ export const englishCrmMessages = {
updated: "Task updated",
name: "Task |||| Tasks",
forcedCaseName: "Task",
+ types: {
+ none: "None",
+ email: "Email",
+ demo: "Demo",
+ lunch: "Lunch",
+ meeting: "Meeting",
+ follow_up: "Follow-up",
+ thank_you: "Thank you",
+ ship: "Ship",
+ call: "Call",
+ },
},
theme: {
dark: "Dark theme",
@@ -400,8 +486,14 @@ export const englishCrmMessages = {
},
tags: {
name: "Tag |||| Tags",
+ action: {
+ add: "Add tag",
+ create_new: "Create new tag",
+ },
dialog: {
color: "Color",
+ create_title: "Create a new tag",
+ edit_title: "Edit tag",
name_label: "Tag name",
name_placeholder: "Enter tag name",
},
diff --git a/src/components/atomic-crm/root/frenchCrmMessages.ts b/src/components/atomic-crm/root/frenchCrmMessages.ts
index 652aa50c..f589fbce 100644
--- a/src/components/atomic-crm/root/frenchCrmMessages.ts
+++ b/src/components/atomic-crm/root/frenchCrmMessages.ts
@@ -40,6 +40,16 @@ export const frenchCrmMessages = {
loading: "Chargement...",
me: "Moi",
},
+ activity: {
+ you: "Vous",
+ added_company: "a ajouté l'entreprise",
+ added_contact: "a ajouté",
+ added_note_about: "a ajouté une note sur",
+ added_note_about_deal: "a ajouté une note sur l'affaire",
+ added_deal: "a ajouté l'affaire",
+ to: "à",
+ load_more: "Charger plus d'activité",
+ },
companies: {
empty: {
description: "Il semble que la liste de vos entreprises soit vide.",
@@ -76,16 +86,52 @@ export const frenchCrmMessages = {
},
fields: {
name: "Nom de l'entreprise",
+ website: "Site web",
+ linkedin_url: "URL LinkedIn",
+ phone_number: "Numéro de téléphone",
revenue: "Chiffre d'affaires",
sector: "Secteur",
size: "Taille",
tax_identifier: "Identifiant fiscal",
+ address: "Adresse",
+ city: "Ville",
+ zipcode: "Code postal",
+ state_abbr: "État",
+ country: "Pays",
+ description: "Description",
+ context_links: "Liens de contexte",
},
filters: {
only_mine: "Seulement les entreprises que je gère",
sector: "Secteur",
size: "Taille",
},
+ sectors: {
+ communication_services: "Services de communication",
+ consumer_discretionary: "Consommation discrétionnaire",
+ consumer_staples: "Biens de consommation de base",
+ energy: "Énergie",
+ financials: "Finance",
+ health_care: "Santé",
+ industrials: "Industrie",
+ information_technology: "Technologies de l'information",
+ materials: "Matériaux",
+ real_estate: "Immobilier",
+ utilities: "Services publics",
+ },
+ sizes: {
+ one_employee: "1 employé",
+ two_to_nine_employees: "2-9 employés",
+ ten_to_forty_nine_employees: "10-49 employés",
+ fifty_to_two_hundred_forty_nine_employees: "50-249 employés",
+ two_hundred_fifty_or_more_employees: "250 employés ou plus",
+ },
+ autocomplete: {
+ create_error:
+ "Une erreur s'est produite lors de la création de l'entreprise",
+ create_item: "Créer %{item}",
+ create_label: "Commencez à taper pour créer une nouvelle entreprise",
+ },
},
contacts: {
action: {
@@ -122,16 +168,32 @@ export const frenchCrmMessages = {
},
inputs: {
background_info_short: "Informations générales",
+ first_name: "Prénom",
+ last_name: "Nom",
email: "E-mail",
identity: "Identité",
personal_info: "Informations personnelles",
phone_number: "Numéro de téléphone",
position: "Position",
+ title: "Titre",
+ company: "Entreprise",
email_addresses: "Adresses e-mail",
phone_numbers: "Numéros de téléphone",
linkedin_url: "URL LinkedIn",
background_info:
"Informations de contexte (bio, comment vous vous êtes rencontrés, etc.)",
+ has_newsletter: "Abonné à la newsletter",
+ subscribed_newsletter: "Abonné à la newsletter",
+ genders: {
+ male: "Il/Lui",
+ female: "Elle",
+ nonbinary: "Iel",
+ },
+ personal_info_types: {
+ work: "Pro",
+ home: "Perso",
+ other: "Autre",
+ },
},
list: {
error_loading: "Erreur lors du chargement des contacts",
@@ -176,11 +238,16 @@ export const frenchCrmMessages = {
},
},
dashboard: {
+ deals_pipeline: "Pipeline des affaires",
+ latest_activity: "Dernière activité",
+ latest_activity_error:
+ "Erreur lors du chargement de la dernière activité",
stepper: {
install: "Installer Atomic CRM",
progress: "%{step}/3 terminé",
whats_next: "Et ensuite ?",
},
+ upcoming_tasks: "Tâches à venir",
welcome: {
paragraph_1:
"est un modèle conçu pour vous aider à créer rapidement votre propre CRM.",
@@ -237,6 +304,14 @@ export const frenchCrmMessages = {
filters: {
company: "Entreprise",
},
+ stages: {
+ opportunity: "Opportunité",
+ proposal_sent: "Proposition envoyée",
+ in_negociation: "En négociation",
+ won: "Gagnée",
+ lost: "Perdue",
+ delayed: "Reportée",
+ },
},
header: {
import_data: "Importer des données",
@@ -375,7 +450,9 @@ export const frenchCrmMessages = {
empty_list_hint: "Les tâches ajoutées à vos contacts apparaîtront ici.",
fields: {
due: "échéance",
+ due_date: "Date d'échéance",
description: "Description",
+ type: "Type",
},
filters: {
later: "Plus tard",
@@ -388,6 +465,17 @@ export const frenchCrmMessages = {
updated: "Tâche mise à jour",
name: "Tâche |||| Tâches",
forcedCaseName: "Tâche",
+ types: {
+ none: "Aucun",
+ email: "E-mail",
+ demo: "Démo",
+ lunch: "Déjeuner",
+ meeting: "Réunion",
+ follow_up: "Relance",
+ thank_you: "Remerciement",
+ ship: "Expédition",
+ call: "Appel",
+ },
},
theme: {
dark: "Thème sombre",
@@ -403,8 +491,14 @@ export const frenchCrmMessages = {
},
tags: {
name: "Étiquette |||| Étiquettes",
+ action: {
+ add: "Ajouter une étiquette",
+ create_new: "Créer une nouvelle étiquette",
+ },
dialog: {
color: "Couleur",
+ create_title: "Créer une nouvelle étiquette",
+ edit_title: "Modifier l'étiquette",
name_label: "Nom de l'étiquette",
name_placeholder: "Saisir le nom de l'étiquette",
},
diff --git a/src/components/atomic-crm/sales/SaleName.tsx b/src/components/atomic-crm/sales/SaleName.tsx
index 597c1710..bb313f16 100644
--- a/src/components/atomic-crm/sales/SaleName.tsx
+++ b/src/components/atomic-crm/sales/SaleName.tsx
@@ -1,13 +1,14 @@
-import { useGetIdentity, useRecordContext } from "ra-core";
+import { useGetIdentity, useRecordContext, useTranslate } from "ra-core";
import type { Sale } from "../types";
export const SaleName = ({ sale }: { sale?: Sale }) => {
const { identity, isPending } = useGetIdentity();
+ const translate = useTranslate();
const saleFromContext = useRecordContext<Sale>();
const finalSale = sale || saleFromContext;
if (isPending || !finalSale) return null;
return finalSale.id === identity?.id
- ? "You"
+ ? translate("crm.activity.you", { _: "You" })
: `${finalSale.first_name} ${finalSale.last_name}`;
};
diff --git a/src/components/atomic-crm/settings/SettingsPage.tsx b/src/components/atomic-crm/settings/SettingsPage.tsx
index 5028f1f9..b2948f09 100644
--- a/src/components/atomic-crm/settings/SettingsPage.tsx
+++ b/src/components/atomic-crm/settings/SettingsPage.tsx
@@ -25,6 +25,7 @@ import {
} from "../root/ConfigurationContext";
import { defaultConfiguration } from "../root/defaultConfiguration";
import { validateItemsInUse } from "./validateItemsInUse";
+import { getTranslatedDealStageLabel } from "../deals/getTranslatedDealStageLabel";
const SECTIONS = [
{
@@ -305,7 +306,8 @@ const SettingsFormFields = () => {
}
}}
>
- {stage.label || stage.value}
+ {getTranslatedDealStageLabel(stage, translate) ||
+ stage.value}
</Button>
);
},
diff --git a/src/components/atomic-crm/tags/TagCreateModal.tsx b/src/components/atomic-crm/tags/TagCreateModal.tsx
index 0583432e..de662303 100644
--- a/src/components/atomic-crm/tags/TagCreateModal.tsx
+++ b/src/components/atomic-crm/tags/TagCreateModal.tsx
@@ -1,4 +1,4 @@
-import { useCreate } from "ra-core";
+import { useCreate, useTranslate } from "ra-core";
import type { Tag } from "../types";
import { TagDialog } from "./TagDialog";
@@ -15,6 +15,7 @@ export function TagCreateModal({
onSuccess,
}: TagCreateModalProps) {
const [create] = useCreate<Tag>();
+ const translate = useTranslate();
const handleCreateTag = async (data: Pick<Tag, "name" | "color">) => {
await create(
@@ -31,7 +32,9 @@ export function TagCreateModal({
return (
<TagDialog
open={open}
- title="Create a new tag"
+ title={translate("crm.tags.dialog.create_title", {
+ _: "Create a new tag",
+ })}
onClose={onClose}
onSubmit={handleCreateTag}
/>
diff --git a/src/components/atomic-crm/tags/TagEditModal.tsx b/src/components/atomic-crm/tags/TagEditModal.tsx
index b591a703..92afc2a1 100644
--- a/src/components/atomic-crm/tags/TagEditModal.tsx
+++ b/src/components/atomic-crm/tags/TagEditModal.tsx
@@ -1,4 +1,4 @@
-import { useUpdate } from "ra-core";
+import { useTranslate, useUpdate } from "ra-core";
import type { Tag } from "../types";
import { TagDialog } from "./TagDialog";
@@ -17,6 +17,7 @@ export function TagEditModal({
onSuccess,
}: TagEditModalProps) {
const [update] = useUpdate<Tag>();
+ const translate = useTranslate();
const handleEditTag = async (data: Pick<Tag, "name" | "color">) => {
await update(
@@ -33,7 +34,7 @@ export function TagEditModal({
return (
<TagDialog
open={open}
- title="Edit tag"
+ title={translate("crm.tags.dialog.edit_title", { _: "Edit tag" })}
onClose={onClose}
onSubmit={handleEditTag}
tag={tag}
diff --git a/src/components/atomic-crm/tasks/AddTask.tsx b/src/components/atomic-crm/tasks/AddTask.tsx
index e747bab1..8625df40 100644
--- a/src/components/atomic-crm/tasks/AddTask.tsx
+++ b/src/components/atomic-crm/tasks/AddTask.tsx
@@ -104,7 +104,7 @@ export const AddTask = ({
<CreateBase
resource="tasks"
record={{
- type: "None",
+ type: "none",
contact_id: contact?.id,
due_date: new Date().toISOString(),
sales_id: identity.id,
diff --git a/src/components/atomic-crm/tasks/Task.tsx b/src/components/atomic-crm/tasks/Task.tsx
index f4ae0817..9248442b 100644
--- a/src/components/atomic-crm/tasks/Task.tsx
+++ b/src/components/atomic-crm/tasks/Task.tsx
@@ -20,6 +20,7 @@ import {
import { useConfigurationContext } from "../root/ConfigurationContext";
import type { Contact, Task as TData } from "../types";
+import { getTranslatedTaskTypeLabel } from "./getTranslatedTaskTypeLabel";
import { TaskEdit } from "./TaskEdit";
import { TaskEditSheet } from "./TaskEditSheet";
import { useIsMobile } from "@/hooks/use-mobile";
@@ -108,8 +109,14 @@ export const Task = ({
{task.type && task.type !== "none" && (
<>
<span className="font-semibold text-sm">
- {taskTypes.find((t) => t.value === task.type)?.label ??
- task.type}
+ {(() => {
+ const matchedTaskType = taskTypes.find(
+ (taskType) => taskType.value === task.type,
+ );
+ return matchedTaskType
+ ? getTranslatedTaskTypeLabel(matchedTaskType, translate)
+ : task.type;
+ })()}
</span>
&nbsp;
</>
diff --git a/src/components/atomic-crm/tasks/TaskCreateSheet.tsx b/src/components/atomic-crm/tasks/TaskCreateSheet.tsx
index eaa3d506..7f20c775 100644
--- a/src/components/atomic-crm/tasks/TaskCreateSheet.tsx
+++ b/src/components/atomic-crm/tasks/TaskCreateSheet.tsx
@@ -5,6 +5,7 @@ import {
useGetIdentity,
useGetOne,
useNotify,
+ useTranslate,
useUpdate,
} from "ra-core";
import { CreateSheet } from "../misc/CreateSheet";
@@ -23,6 +24,7 @@ export const TaskCreateSheet = ({
contact_id,
}: TaskCreateSheetProps) => {
const { identity } = useGetIdentity();
+ const translate = useTranslate();
const selectContact = contact_id == null;
const { data: contact } = useGetOne(
@@ -48,7 +50,9 @@ export const TaskCreateSheet = ({
data: { last_seen: new Date().toISOString() },
previousData: contact,
});
- notify("Task added");
+ notify("crm.tasks.added", {
+ messageArgs: { _: "Task added" },
+ });
// No redirect, only close the sheet
onOpenChange(false);
};
@@ -58,7 +62,11 @@ export const TaskCreateSheet = ({
resource="tasks"
title={
<h1 className="text-xl font-semibold truncate pr-10">
- {!selectContact ? "Create Task for " : "Create Task"}
+ {!selectContact
+ ? translate("crm.tasks.dialog.create_for", {
+ _: "Create a new task for ",
+ })
+ : translate("crm.tasks.action.create", { _: "Create task" })}
{!selectContact && (
<RecordRepresentation record={contact} resource="contacts" />
)}
@@ -66,7 +74,7 @@ export const TaskCreateSheet = ({
}
redirect={false}
record={{
- type: "None",
+ type: "none",
contact_id,
due_date: new Date().toISOString(),
sales_id: identity.id,
diff --git a/src/components/atomic-crm/tasks/TaskFormContent.tsx b/src/components/atomic-crm/tasks/TaskFormContent.tsx
index 9583e432..06d6d1fd 100644
--- a/src/components/atomic-crm/tasks/TaskFormContent.tsx
+++ b/src/components/atomic-crm/tasks/TaskFormContent.tsx
@@ -3,10 +3,11 @@ import { ReferenceInput } from "@/components/admin/reference-input";
import { SelectInput } from "@/components/admin/select-input";
import { TextInput } from "@/components/admin/text-input";
import { required, useTranslate } from "ra-core";
+import { DateTimeInput } from "@/components/admin";
import { contactOptionText } from "../misc/ContactOption";
import { useConfigurationContext } from "../root/ConfigurationContext";
-import { DateTimeInput } from "@/components/admin";
+import { getTranslatedTaskTypeLabel } from "./getTranslatedTaskTypeLabel";
export const TaskFormContent = ({
selectContact,
@@ -15,6 +16,10 @@ export const TaskFormContent = ({
}) => {
const { taskTypes } = useConfigurationContext();
const translate = useTranslate();
+ const translatedTaskTypes = taskTypes.map((taskType) => ({
+ ...taskType,
+ label: getTranslatedTaskTypeLabel(taskType, translate),
+ }));
return (
<div className="flex flex-col gap-4">
<TextInput
@@ -41,15 +46,18 @@ export const TaskFormContent = ({
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<DateTimeInput
source="due_date"
+ label="crm.tasks.fields.due_date"
helperText={false}
validate={required()}
/>
<SelectInput
source="type"
+ label="crm.tasks.fields.type"
validate={required()}
- choices={taskTypes}
+ choices={translatedTaskTypes}
optionText="label"
optionValue="value"
+ defaultValue="none"
helperText={false}
/>
</div>
diff --git a/src/components/atomic-crm/tasks/getTranslatedTaskTypeLabel.ts b/src/components/atomic-crm/tasks/getTranslatedTaskTypeLabel.ts
new file mode 100644
index 00000000..f9638396
--- /dev/null
+++ b/src/components/atomic-crm/tasks/getTranslatedTaskTypeLabel.ts
@@ -0,0 +1,30 @@
+type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
+
+const defaultTaskTypeLabels: Record<string, string> = {
+ none: "None",
+ email: "Email",
+ demo: "Demo",
+ lunch: "Lunch",
+ meeting: "Meeting",
+ "follow-up": "Follow-up",
+ "thank-you": "Thank you",
+ ship: "Ship",
+ call: "Call",
+};
+
+const getTaskTypeTranslationKey = (taskTypeValue: string) =>
+ `crm.tasks.types.${taskTypeValue.replaceAll("-", "_")}`;
+
+export const getTranslatedTaskTypeLabel = (
+ taskType: { value: string; label: string },
+ translate: TranslateFn,
+) => {
+ const defaultLabel = defaultTaskTypeLabels[taskType.value];
+ if (!defaultLabel || taskType.label !== defaultLabel) {
+ return taskType.label;
+ }
+
+ return translate(getTaskTypeTranslationKey(taskType.value), {
+ _: taskType.label,
+ });
+};