11import type { ComboboxProps } from "@carbon/form" ;
22import { CreatableCombobox } from "@carbon/form" ;
33import { useDisclosure , useMount } from "@carbon/react" ;
4+ import { useLingui } from "@lingui/react/macro" ;
45import { useMemo , useRef , useState } from "react" ;
56import { useFetcher } from "react-router" ;
67import { useRouteData } from "~/hooks" ;
@@ -10,6 +11,7 @@ import type {
1011} from "~/modules/items" ;
1112import UnitOfMeasureForm from "~/modules/items/ui/UnitOfMeasure/UnitOfMeasureForm" ;
1213import { path } from "~/utils/path" ;
14+ import { translateSeedDisplayName } from "~/utils/seedDataDisplayName" ;
1315import { Enumerable } from "../Enumerable" ;
1416
1517type UnitOfMeasureSelectProps = Omit < ComboboxProps , "options" | "inline" > & {
@@ -28,6 +30,7 @@ const UnitOfMeasurePreview = (
2830} ;
2931
3032const UnitOfMeasure = ( props : UnitOfMeasureSelectProps ) => {
33+ const { t } = useLingui ( ) ;
3134 const options = useUnitOfMeasure ( ) ;
3235
3336 const newUnitOfMeasureModal = useDisclosure ( ) ;
@@ -41,7 +44,7 @@ const UnitOfMeasure = (props: UnitOfMeasureSelectProps) => {
4144 options = { options }
4245 { ...props }
4346 inline = { props . inline ? UnitOfMeasurePreview : undefined }
44- label = { props ?. label ?? " Unit of Measure" }
47+ label = { props ?. label ?? t ` Unit of Measure` }
4548 onCreateOption = { ( option ) => {
4649 newUnitOfMeasureModal . onOpen ( ) ;
4750 setCreated ( option ) ;
@@ -70,6 +73,7 @@ UnitOfMeasure.displayName = "UnitOfMeasure";
7073export default UnitOfMeasure ;
7174
7275export const useUnitOfMeasure = ( ) => {
76+ const { i18n } = useLingui ( ) ;
7377 const uomFetcher =
7478 useFetcher < Awaited < ReturnType < typeof getUnitOfMeasuresList > > > ( ) ;
7579
@@ -91,12 +95,13 @@ export const useUnitOfMeasure = () => {
9195
9296 return dataSource . map ( ( c ) => ( {
9397 value : c . code ,
94- label : c . name
98+ label : translateSeedDisplayName ( c . name , i18n )
9599 } ) ) ;
96100 } , [
97101 hasSharedPartData ,
98102 sharedPartData ?. unitOfMeasures ,
99- uomFetcher . data ?. data
103+ uomFetcher . data ?. data ,
104+ i18n
100105 ] ) ;
101106
102107 return options ;
0 commit comments