File tree Expand file tree Collapse file tree 18 files changed +142
-69
lines changed
link-modules/src/definitions/readonly Expand file tree Collapse file tree 18 files changed +142
-69
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @medusajs/medusa " : patch
3+ " @medusajs/translation " : patch
4+ ---
5+
6+ feat(): Add product type and collection translation support
Original file line number Diff line number Diff line change 44 MedusaResponse ,
55} from "@medusajs/framework/http"
66import { refetchCollection } from "../helpers"
7+ import { applyTranslations } from "@medusajs/framework/utils"
78
89export const GET = async (
910 req : AuthenticatedMedusaRequest < HttpTypes . SelectParams > ,
@@ -15,5 +16,11 @@ export const GET = async (
1516 req . queryConfig . fields
1617 )
1718
19+ await applyTranslations ( {
20+ localeCode : req . locale ,
21+ objects : [ collection ] ,
22+ container : req . scope ,
23+ } )
24+
1825 res . status ( 200 ) . json ( { collection } )
1926}
Original file line number Diff line number Diff line change 55} from "@medusajs/framework/http"
66
77import {
8+ applyTranslations ,
89 ContainerRegistrationKeys ,
910 remoteQueryObjectFromString ,
1011} from "@medusajs/framework/utils"
@@ -26,6 +27,12 @@ export const GET = async (
2627
2728 const { rows : collections , metadata } = await remoteQuery ( query )
2829
30+ await applyTranslations ( {
31+ localeCode : req . locale ,
32+ objects : collections ,
33+ container : req . scope ,
34+ } )
35+
2936 res . json ( {
3037 collections,
3138 count : metadata . count ,
Original file line number Diff line number Diff line change 11import { StoreProductCategoryResponse } from "@medusajs/framework/types"
2- import { MedusaError } from "@medusajs/framework/utils"
2+ import { applyTranslations , MedusaError } from "@medusajs/framework/utils"
33import {
44 AuthenticatedMedusaRequest ,
55 MedusaResponse ,
@@ -24,5 +24,12 @@ export const GET = async (
2424 `Product category with id: ${ req . params . id } was not found`
2525 )
2626 }
27+
28+ await applyTranslations ( {
29+ localeCode : req . locale ,
30+ objects : [ category ] ,
31+ container : req . scope ,
32+ } )
33+
2734 res . json ( { product_category : category } )
2835}
Original file line number Diff line number Diff line change 1+ import {
2+ AuthenticatedMedusaRequest ,
3+ MedusaResponse ,
4+ } from "@medusajs/framework/http"
15import {
26 StoreProductCategoryListParams ,
37 StoreProductCategoryListResponse ,
48} from "@medusajs/framework/types"
5- import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
69import {
7- AuthenticatedMedusaRequest ,
8- MedusaResponse ,
9- } from "@medusajs/framework/http "
10+ applyTranslations ,
11+ ContainerRegistrationKeys ,
12+ } from "@medusajs/framework/utils "
1013
1114export const GET = async (
1215 req : AuthenticatedMedusaRequest < StoreProductCategoryListParams > ,
@@ -21,6 +24,12 @@ export const GET = async (
2124 pagination : req . queryConfig . pagination ,
2225 } )
2326
27+ await applyTranslations ( {
28+ localeCode : req . locale ,
29+ objects : product_categories ,
30+ container : req . scope ,
31+ } )
32+
2433 res . json ( {
2534 product_categories,
2635 count : metadata ! . count ,
Original file line number Diff line number Diff line change 11import { StoreProductTagResponse } from "@medusajs/framework/types"
22import {
3+ applyTranslations ,
34 ContainerRegistrationKeys ,
45 MedusaError ,
56} from "@medusajs/framework/utils"
@@ -30,5 +31,14 @@ export const GET = async (
3031 `Product tag with id: ${ req . params . id } was not found`
3132 )
3233 }
33- res . json ( { product_tag : data [ 0 ] } )
34+
35+ const productTag = data [ 0 ]
36+
37+ await applyTranslations ( {
38+ localeCode : req . locale ,
39+ objects : [ productTag ] ,
40+ container : req . scope ,
41+ } )
42+
43+ res . json ( { product_tag : productTag } )
3444}
Original file line number Diff line number Diff line change 11import { HttpTypes } from "@medusajs/framework/types"
2- import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
2+ import {
3+ applyTranslations ,
4+ ContainerRegistrationKeys ,
5+ } from "@medusajs/framework/utils"
36import {
47 AuthenticatedMedusaRequest ,
58 MedusaResponse ,
@@ -18,6 +21,12 @@ export const GET = async (
1821 fields : req . queryConfig . fields ,
1922 } )
2023
24+ await applyTranslations ( {
25+ localeCode : req . locale ,
26+ objects : product_tags ,
27+ container : req . scope ,
28+ } )
29+
2130 res . json ( {
2231 product_tags,
2332 count : metadata ?. count ?? 0 ,
Original file line number Diff line number Diff line change 11import { StoreProductTypeResponse } from "@medusajs/framework/types"
22import {
3+ applyTranslations ,
34 ContainerRegistrationKeys ,
45 MedusaError ,
56} from "@medusajs/framework/utils"
@@ -30,5 +31,14 @@ export const GET = async (
3031 `Product type with id: ${ req . params . id } was not found`
3132 )
3233 }
33- res . json ( { product_type : data [ 0 ] } )
34+
35+ const productType = data [ 0 ]
36+
37+ await applyTranslations ( {
38+ localeCode : req . locale ,
39+ objects : [ productType ] ,
40+ container : req . scope ,
41+ } )
42+
43+ res . json ( { product_type : productType } )
3444}
Original file line number Diff line number Diff line change 11import { HttpTypes } from "@medusajs/framework/types"
2- import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
2+ import {
3+ applyTranslations ,
4+ ContainerRegistrationKeys ,
5+ } from "@medusajs/framework/utils"
36import {
47 AuthenticatedMedusaRequest ,
58 MedusaResponse ,
@@ -18,6 +21,12 @@ export const GET = async (
1821 fields : req . queryConfig . fields ,
1922 } )
2023
24+ await applyTranslations ( {
25+ localeCode : req . locale ,
26+ objects : product_types ,
27+ container : req . scope ,
28+ } )
29+
2130 res . json ( {
2231 product_types,
2332 count : metadata ?. count ?? 0 ,
Original file line number Diff line number Diff line change 44} from "@medusajs/framework/http"
55import { HttpTypes , QueryContextType } from "@medusajs/framework/types"
66import {
7+ applyTranslations ,
78 ContainerRegistrationKeys ,
89 MedusaError ,
910 QueryContext ,
@@ -60,6 +61,12 @@ export const GET = async (
6061 )
6162 }
6263
64+ await applyTranslations ( {
65+ localeCode : req . locale ,
66+ objects : [ variant ] ,
67+ container : req . scope ,
68+ } )
69+
6370 if ( withInventoryQuantity ) {
6471 await wrapVariantsWithInventoryQuantityForSalesChannel ( req , [ variant ] )
6572 }
You can’t perform that action at this time.
0 commit comments