Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langgenius Dify I18n Resources

From Leeroopedia
Knowledge Sources
Domains Frontend, Internationalization
Last Updated 2026-02-12 07:00 GMT

Overview

Namespace registry that imports all English (en-US) translation JSON files and derives the canonical namespace list and types for the Dify i18n system.

Description

This module serves as the central namespace definition for Dify's internationalization infrastructure. It statically imports all 30 translation JSON files from the i18n/en-US/ directory and assembles them into a single resources object keyed by camelCase namespace names. From this object, the module derives several critical exports:

  • Resources -- A type representing the full shape of all translation namespaces and their keys, inferred directly from the imported JSON modules.
  • namespaces -- An array of all namespace names in camelCase format (e.g., 'appDebug', 'datasetCreation', 'workflow'), extracted using ObjectKeys.
  • Namespace -- A union type of all namespace name strings, derived from the namespaces array.
  • namespacesInFileName -- An array of all namespace names converted to kebab-case (e.g., 'app-debug', 'dataset-creation', 'workflow'), matching the actual JSON file names on disk.
  • NamespaceInFileName -- A union type of all kebab-case namespace name strings.

The resources object itself is kept module-private (not exported) and is used only for type inference. The kebab-case conversion uses the string-ts library's kebabCase function.

Usage

Use this module whenever you need to reference the list of available i18n namespaces, either at runtime (for dynamic loading) or at the type level (for type-safe namespace parameters). It is consumed by the client.ts, server.ts, and settings.ts modules to configure i18next namespace loading.

Code Reference

Source Location

Signature

export type Resources = typeof resources

export const namespaces: (keyof typeof resources)[]
export type Namespace = typeof namespaces[number]

export const namespacesInFileName: string[]
export type NamespaceInFileName = typeof namespacesInFileName[number]

Import

import type { Resources, Namespace, NamespaceInFileName } from '@/i18n-config/resources'
import { namespaces, namespacesInFileName } from '@/i18n-config/resources'

I/O Contract

Inputs

Name Type Required Description
(none) -- -- This module has no function inputs; it exports static constants and types derived from imported JSON files.

Outputs

Name Type Description
namespaces Array<Namespace> Array of 30 camelCase namespace names (e.g., 'app', 'appDebug', 'common').
namespacesInFileName Array<NamespaceInFileName> Array of 30 kebab-case namespace names matching JSON file names (e.g., 'app', 'app-debug', 'common').
Resources (type) typeof resources Type representing all namespace objects and their translation keys.
Namespace (type) string union Union of all camelCase namespace name literals.
NamespaceInFileName (type) string union Union of all kebab-case namespace name literals.

Registered Namespaces

The following 30 namespaces are registered in the module:

camelCase (Namespace) kebab-case (NamespaceInFileName) JSON Source File
app app app.json
appAnnotation app-annotation app-annotation.json
appApi app-api app-api.json
appDebug app-debug app-debug.json
appLog app-log app-log.json
appOverview app-overview app-overview.json
billing billing billing.json
common common common.json
custom custom custom.json
dataset dataset dataset.json
datasetCreation dataset-creation dataset-creation.json
datasetDocuments dataset-documents dataset-documents.json
datasetHitTesting dataset-hit-testing dataset-hit-testing.json
datasetPipeline dataset-pipeline dataset-pipeline.json
datasetSettings dataset-settings dataset-settings.json
education education education.json
explore explore explore.json
layout layout layout.json
login login login.json
oauth oauth oauth.json
pipeline pipeline pipeline.json
plugin plugin plugin.json
pluginTags plugin-tags plugin-tags.json
pluginTrigger plugin-trigger plugin-trigger.json
register register register.json
runLog run-log run-log.json
share share share.json
time time time.json
tools tools tools.json
workflow workflow workflow.json

Usage Examples

Iterating Over Namespaces

import { namespaces, namespacesInFileName } from '@/i18n-config/resources'

// Log all namespace names
namespaces.forEach((ns, i) => {
  console.log(`${ns} -> ${namespacesInFileName[i]}`)
})
// app -> app
// appAnnotation -> app-annotation
// appApi -> app-api
// ...

Type-Safe Namespace Parameter

import type { Namespace } from '@/i18n-config/resources'

function loadTranslation(ns: Namespace) {
  // TypeScript enforces that ns must be one of the 30 registered namespaces
  return import(`../i18n/en-US/${ns}.json`)
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment