Translation Module

In this section of the documentation, you will find resources to learn more about the Translation Module and how to use it in your application.

Looking for no-code docs? Refer to the Medusa Admin User Guide to learn how to manage translations in the dashboard.

Medusa has translation features available out-of-the-box through the Translation Module. A module is a standalone package that provides features for a single domain. Each of Medusa's commerce features is provided in Commerce Modules, such as the Translation Module.

Note: Refer to the Module Isolation guide to learn more about why modules are isolated.

Translation Features#


Configure Translation Module#

The Translation Module is currently behind a feature flag. To use it in your Medusa application, add it to the modules array and enable the translation feature flag.

In your medusa-config.ts file, add the Translation Module to the modules array and enable the translation feature flag:

medusa-config.ts
1module.exports = defineConfig({2  // ...3  modules: [4    // other modules...5    {6      resolve: "@medusajs/medusa/translation",7    },8  ],9  featureFlags: {10    translation: true,11  },12})

Then, run the following command to make the necessary database changes for the Translation Module:

Terminal
npx medusa db:migrate

You can then use the Translation Module in your Medusa application.


How to Use the Translation Module#

In your Medusa application, you build flows around Commerce Modules. A flow is built as a Workflow, which is a special function composed of a series of steps that guarantees data consistency and a reliable rollback mechanism.

You can build custom workflows and steps. You can also re-use Medusa's workflows and steps, which are provided by the @medusajs/medusa/core-flows package.

For example:

src/workflows/create-translation.ts
1import { 2  createWorkflow, 3  WorkflowResponse,4  createStep,5  StepResponse,6} from "@medusajs/framework/workflows-sdk"7import { Modules } from "@medusajs/framework/utils"8
9const createTranslationStep = createStep(10  "create-translation",11  async ({}, { container }) => {12    const translationModuleService = container.resolve(Modules.TRANSLATION)13
14    const translation = await translationModuleService.createTranslations({15      reference_id: "product_123",16      reference: "product",17      locale_code: "fr-FR",18      translations: {19        title: "Produit Exemple",20        description: "Ceci est une description en français.",21      },22    })23
24    return new StepResponse({ translation }, translation.id)25  },26  async (translationId, { container }) => {27    const translationModuleService = container.resolve(Modules.TRANSLATION)28
29    await translationModuleService.deleteTranslations([translationId])30  }31)32
33export const createTranslationWorkflow = createWorkflow(34  "create-translation",35  () => {36    const { translation } = createTranslationStep()37
38    return new WorkflowResponse({39      translation,40    })41  }42)

You can then execute the workflow in your custom API routes, scheduled jobs, or subscribers:

Refer to the Workflows documentation to learn more.


Supported Module Translations#

The Translation Module currently supports translations for the following data models:

Data Model

Translatable Fields

CustomerGroup (Customer Module) (+v2.12.4)

name

Product (Product Module)

  • title
  • description
  • material
  • subtitle

ProductCategory (Product Module)

  • name
  • description

ProductCollection (Product Module)

title

ProductOption (Product Module)

title

ProductOptionValue (Product Module)

value

ProductTag (Product Module)

value

ProductType (Product Module)

value

ProductVariant (Product Module)

  • title
  • material

Region (Region Module) (+v2.12.4)

name

ShippingOption (Fulfillment Module) (+v2.12.4)

name

ShippingOptionType (Fulfillment Module) (+v2.12.4)

  • label
  • description

TaxRate (Tax Module) (+v2.12.4)

name

Future versions of the Translation Module will include support for all Commerce Modules.


Was this page helpful?
Ask Anything
Ask any questions about Medusa. Get help with your development.
You can also use the Medusa MCP server in Cursor, VSCode, etc...
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break