> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spurtcommerce.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Localization

The Localization add-on provides language and currency localization capabilities for a SpurtCommerce storefront. It helps present translated content and formatted values according to the languages and currencies supported by the marketplace.

## Key Features

* Support multiple languages for storefront content.
* Support currency selection and conversion.
* Format numbers, dates, and currency values according to locale.
* Detect customer language automatically or allow manual selection.
* Display translated product descriptions and interface labels.
* Provide currency selection and conversion workflows.

## Package Structure

```text theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
Localization/
├── controllers/
├── migrations/
├── models/
├── repository/
└── service/
```

## How It Works

1. An administrator defines supported languages and the default locale.
2. Translated product descriptions and labels are maintained for the required languages.
3. The storefront determines the active language through configured detection rules or customer selection.
4. The selected locale controls translated content and formatting.
5. Currency selection and conversion use the configured currency settings and rates.

## Components

* Models represent language and currency localization data.
* Controllers expose localization management operations.
* Repositories access localization records.
* Services contain locale and currency operations.
* Migrations create the required database structures.

## Configuration

Configure the following settings after the add-on has been discovered and enabled. Only apply settings supported by the supplied package version.

* Set the default language and supported language list.
* Set the base currency and supported currencies.
* Configure language detection rules, such as browser-based, location-based, or manual selection.
* Set currency formatting and conversion behaviour.

## Installation (Pre-built Premium Add-on)

This add-on is delivered as a **pre-built JavaScript package** by SpurtCommerce. Install the supplied compiled files; **you do not need to run a TypeScript build**.

### Before you begin

* Confirm that the add-on package is intended for the SpurtCommerce version and edition installed in your project.
* Back up the application files and database before installing a new add-on or applying its migrations.
* Extract the supplied add-on archive. The package normally contains `index.js` (which exports the `spurtcommerceAddon` manifest), compiled folders such as `controllers/`, `models/`, `repositories/`, `services/`, `migrations/`, and may include an optional hook file and `package.json`.
* Work from the SpurtCommerce project root - the directory containing the application’s `main.js` and `package.json`.

### Step 1: Place the add-on in `add-ons/`

Create an `add-ons/` directory in the project root if it does not already exist. Copy the supplied add-on folder into it. Use the folder name provided with the add-on package and retain the supplied internal file structure.

There are two supported layouts.

**Layout A - compiled files directly inside the add-on folder**

```text theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
my-spurtcommerce-project/
├── add-ons/
│   └── <addon-name>/
│       ├── index.js
│       ├── controllers/
│       ├── models/
│       ├── repositories/
│       ├── services/
│       └── migrations/
├── main.js
└── package.json
```

**Layout B - keep the `dist/` directory inside the add-on folder**

```text theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
my-spurtcommerce-project/
├── add-ons/
│   └── <addon-name>/
│       ├── package.json
│       └── dist/
│           ├── index.js
│           ├── controllers/
│           ├── models/
│           ├── repositories/
│           ├── services/
│           └── migrations/
├── main.js
└── package.json
```

For Layout B, the add-on folder must contain a root-level `package.json` that points to the compiled entry file. For example:

```json theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
{
  "name": "<addon-name>",
  "version": "1.0.0",
  "main": "dist/index.js"
}
```

Alternatively, create `add-ons/<addon-name>/index.js` with this content:

```javascript theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
module.exports = require('./dist');
```

**Important:** The add-on registry does not discover a nested `dist/` directory as a package entry by itself. When retaining `dist/`, provide the root-level `package.json` or `index.js` entry point shown above.

### Step 2: Add add-on-specific environment settings

Check the add-on's configuration section and the README or handover notes included with the supplied package. If the add-on requires environment variables - for example, a Redis connection, socket port, payment gateway credentials, or an external service key - add the exact variables to the SpurtCommerce project's `.env` file.

Do not add placeholder values to production. Keep credentials private and do not commit real secrets to source control. If the add-on does not specify additional environment variables, no add-on-specific `.env` change is required.

### Step 3: Install only additional dependencies required by the add-on

The SpurtCommerce application already provides its core dependencies, such as TypeORM, `routing-controllers`, and `typedi`. Install an additional third-party package only when it is explicitly listed as a requirement in the supplied add-on documentation or package manifest.

Run any required command from the project root:

```bash theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
npm install <package-name>
```

Do not reinstall the SpurtCommerce core dependencies or run a build for the pre-built add-on. The package handover notes should identify any additional dependency that is required.

### Step 4: Start or restart SpurtCommerce

Start the application using the normal command for your project. For example:

```bash theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
node main.js
```

or:

```bash theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
npm start
```

If the server is already running, restart it after copying the add-on files or changing `.env` values. No manual edits to `main.js` or SpurtCommerce core loader files are required when the project has the supported add-on registry.

### Step 5: Allow the core loaders to register the add-on

During startup, SpurtCommerce performs the add-on integration through its loader lifecycle:

1. **Discovery (`addonRegistry`):** Scans the `add-ons/` directory, loads the add-on entry file, and validates/caches its `spurtcommerceAddon` manifest.
2. **Database and migrations (`typeormLoader`):** Registers the add-on's TypeORM entities and migrations, runs the migrations, seeds the add-on's plugin record where defined, and calls `manifest.initialize(dataSource)` when provided.
3. **Plugin registration (`pluginLoader`):** Registers the add-on's `pluginName` in the application’s plugin module.
4. **API routes (`expressLoader`):** Mounts the add-on's store, vendor, and admin controllers under the `/api/*` route space.
5. **Hooks (`HookUtil`):** Registers the event hooks included with the add-on so relevant core events can invoke them.

This is performed by the host application at startup. Do not manually run the add-on migrations or register controllers/entities in core files unless the add-on's own handover guide specifically requires an exception.

### Step 6: Verify add-on discovery and activation

After startup, check the application console for a discovery message similar to:

```text theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
[AddonRegistry] Discovered local add-on: <AddonPluginName> (<addon-name>)
```

Then verify that the plugin record is enabled. You can check the Plugins area in the Admin application or query the database:

```sql theme={"theme":{"light":"github-dark-default","dark":"github-light-default"}}
SELECT id, plugin_name, slug_name, plugin_status
FROM plugins
WHERE slug_name = '<addon-slug>';
```

Confirm that `plugin_status` is `1`. If the add-on is disabled, enable it through the Admin application where supported, or follow your platform’s plugin administration procedure.

Finally, test the add-on's documented API routes and its corresponding Admin, Vendor, or Store workflow. Test in a development or staging environment before enabling the add-on for production users.

### Installation troubleshooting

| Symptom | Likely cause | What to check |
| - | - | - |
| Add-on is not discovered | Entry file is missing, folder is misplaced, or nested `dist/` has no root entry point | Confirm `add-ons/<addon-name>/index.js`, or add the root `package.json` with `main: "dist/index.js"` / root shim as shown above |
| API returns `404` | Server was not restarted, controllers were not loaded, or package entry file was not found | Restart the server and check the `[AddonRegistry] Discovered local add-on` log |
| API returns `403` or plugin is unavailable | Plugin record is disabled | Check `plugin_status` and enable the add-on in Admin where available |
| Startup reports a missing module | An add-on-specific third-party dependency is not installed | Install the missing package in the project root only after confirming it is required by the add-on |
| Migration or database error | Host database configuration is invalid, migration failed, or the add-on is not compatible with the project version | Review startup logs, confirm the target SpurtCommerce version, back up the database, and contact SpurtCommerce support with the error details |

> **Version and delivery note:** Premium add-ons are supplied as compiled packages for a compatible SpurtCommerce release. Use the package delivered for your project version. Do not substitute source-build instructions, rename internal files, or mix compiled packages from different releases unless SpurtCommerce confirms compatibility.

## Operational Notes

Prepare translations for all content that must appear in each language. Validate date, number, and currency formatting for target locales and confirm fallback behaviour when a translation is missing.

## Summary

The Localization add-on extends SpurtCommerce with the capabilities described above. It is delivered as a compiled premium package and is loaded by the SpurtCommerce add-on registry when installed according to the steps above.

## API Endpoints

The endpoint definitions below are derived from the supplied controller files. All routes are mounted under the SpurtCommerce `/api` prefix. Each entry describes the operation and lists the path, query, body, or file inputs identified by the controller annotations.

**Controller routes documented:** 27.

### Admin API

#### WidgetTranslationController

### `GET /api/widget-translation/widget`

**Definition:** Retrieves the widget Language List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Query | `count` | number | As defined by the controller | count |
| Query | `keyword` | string | As defined by the controller | keyword |
| Query | `limit` | number | As defined by the controller | limit |
| Query | `offset` | number | As defined by the controller | offset |

### `GET /api/widget-translation/widget/:id`

**Definition:** Retrieves the widget Language Detail.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |

### `POST /api/widget-translation/widget/:id`

**Definition:** Creates widget Language.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `languageId` | Number | As defined by the controller | languageId |
| Body | `widgetDescription` | String | As defined by the controller | widgetDescription |
| Body | `widgetLongTitle` | String | As defined by the controller | widgetLongTitle |
| Body | `widgetTitle` | String | As defined by the controller | widgetTitle |

**Request model:** `CreateWidgetTranslationRequest` is used by the controller for payload validation.

### Vendor API

#### BlogCategoryTranslationController

### `POST /api/vendor-blog-category-translation/blog-category/:id`

**Definition:** Creates blog Category Translation.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `description` | String | As defined by the controller | description |
| Body | `languageId` | Number | As defined by the controller | language id |

**Request model:** `BlogCategoryTranslationRequest` is used by the controller for payload validation.

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `add-blogs-localization`.

### `GET /api/vendor-blog-category-translation/blog-category`

**Definition:** Retrieves the blog Category Translation List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `add-blogs-localization`.

### `GET /api/vendor-blog-category-translation/blog-category/:id`

**Definition:** Retrieves the blog Category Translation Detail.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `add-blogs-localization`.

#### CategoryTranslationController

### `POST /api/category/:categoryId/category-translation`

**Definition:** Creates category.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `categoryId` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `categoryTranslation` | Array | As defined by the controller | Defined by the controller request contract. |
| Body | `id` | Number | As defined by the controller | CategoryId |

**Request model:** `CategoryTranslationRequest` is used by the controller for payload validation.

**Headers:** The controller documentation lists `Authorization`.

### `GET /api/category/:categoryId/category-translation`

**Definition:** Retrieves the category List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `categoryId` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `id` | Number | As defined by the controller | CategoryId |

**Headers:** The controller documentation lists `Authorization`.

### `GET /api/category/category-translation`

**Definition:** Returns the category translation records for the vendor, with pagination and optional keyword filtering.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Query | `count` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `keyword` | string | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `limit` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `offset` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |

**Authorization:** The controller applies the `vendor` access context.

#### PageGroupTranslationController

### `POST /api/page-group-translation/page-group/:id`

**Definition:** Creates page Group Translation.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `languageId` | Number | As defined by the controller | language id |

**Request model:** `CreatePageGroupTranslationDTO` is used by the controller for payload validation.

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `localization-page-group`.

### `GET /api/page-group-translation/page-group`

**Definition:** Retrieves the page Group Translation List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Query | `count` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `keyword` | string | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `limit` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `offset` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `localization-page-group`.

### `GET /api/page-group-translation/page-group/:id`

**Definition:** Retrieves the page Group Translation Detail.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `localization-page-group`.

#### PageTranslationController

### `POST /api/page-translation/page/:id`

**Definition:** Creates page Translation.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `content` | String | As defined by the controller | content |
| Body | `languageId` | Number | As defined by the controller | language id |

**Request model:** `CreatePageTranslationDTO` is used by the controller for payload validation.

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `localization-pages`.

### `GET /api/page-translation/page`

**Definition:** Retrieves the page Translation List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Query | `count` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `keyword` | string | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `limit` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `offset` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `localization-pages`.

### `GET /api/page-translation/page/:id`

**Definition:** Retrieves the page Translation Detail.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `localization-pages`.

#### ProductTranslationController

### `POST /api/product/:productId/product-translation`

**Definition:** Creates product Translation.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `productId` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `id` | Number | As defined by the controller | product id (Required) |
| Body | `languageId` | Number | As defined by the controller | language id (Required) |

**Request model:** `ProductTranslationRequest` is used by the controller for payload validation.

**Headers:** The controller documentation lists `Authorization`.

### `GET /api/product/:productId/product-translation`

**Definition:** Retrieves the product Translation List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `productId` | number | As defined by the controller | Identifies the resource in the route. |

**Headers:** The controller documentation lists `Authorization`.

### `GET /api/product/product-translation`

**Definition:** Retrieves the product Translation List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Query | `count` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `keyword` | string | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `limit` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `offset` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `sku` | string | As defined by the controller | Filter, pagination, or lookup value read from the query string. |

**Headers:** The controller documentation lists `Authorization`.

#### VendorBlogTranslationController

### `POST /api/vendor-blog-translation/blog/:id`

**Definition:** Creates blog Translation.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `description` | String | As defined by the controller | description |
| Body | `languageId` | Number | As defined by the controller | language id |

**Request model:** `CreateBlogTranslationRequest` is used by the controller for payload validation.

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `add-blogs-localization`.

### `GET /api/vendor-blog-translation/blog`

**Definition:** Retrieves the blog Translation List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Query | `count` | number | As defined by the controller | count |
| Query | `keyword` | string | As defined by the controller | keyword |
| Query | `limit` | number | As defined by the controller | limit |
| Query | `offset` | number | As defined by the controller | offset |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `add-blogs-localization`.

### `GET /api/vendor-blog-translation/blog/:id`

**Definition:** Retrieves the blog Translation Detail.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `add-blogs-localization`.

#### VendorProductTranslationController

### `POST /api/vendor-product-translation/:productId/product-translation`

**Definition:** Creates vendor-Product Translation.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `productId` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `id` | Number | As defined by the controller | product id (Required) |
| Body | `languageId` | Number | As defined by the controller | language id (Required) |

**Request model:** `VendorProductTranslationRequest` is used by the controller for payload validation.

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `edit-localization`.

### `GET /api/vendor-product-translation/product-translation`

**Definition:** Retrieves the vendor Product Translation List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Query | `count` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `keyword` | string | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `limit` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `offset` | number | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `productName` | string | As defined by the controller | Filter, pagination, or lookup value read from the query string. |
| Query | `sku` | string | As defined by the controller | Filter, pagination, or lookup value read from the query string. |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `list-localization`.

### `GET /api/vendor-product-translation/:productId/product-translation`

**Definition:** Retrieves the vendor Product Translation Detail.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `productId` | number | As defined by the controller | Identifies the resource in the route. |

**Authorization:** The controller applies the `vendor` access context and the following permission scope: `list-localization`.

#### VendorWidgetTranslationController

### `GET /api/vendor-widget-translation/widget`

**Definition:** Retrieves the widget Language List.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Query | `count` | number | As defined by the controller | count |
| Query | `keyword` | string | As defined by the controller | keyword |
| Query | `limit` | number | As defined by the controller | limit |
| Query | `offset` | number | As defined by the controller | offset |

### `GET /api/vendor-widget-translation/widget/:id`

**Definition:** Retrieves the widget Language Detail.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |

### `POST /api/vendor-widget-translation/widget/:id`

**Definition:** Creates widget Language.

**Inputs**

| Location | Parameter | Type | Requirement | Description |
| - | - | - | - | - |
| Path | `id` | number | As defined by the controller | Identifies the resource in the route. |
| Body | `languageId` | Number | As defined by the controller | languageId |
| Body | `widgetDescription` | String | As defined by the controller | widgetDescription |
| Body | `widgetLongTitle` | String | As defined by the controller | widgetLongTitle |
| Body | `widgetTitle` | String | As defined by the controller | widgetTitle |

**Request model:** `CreateWidgetTranslationRequest` is used by the controller for payload validation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.