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 Language Config

From Leeroopedia


Knowledge Sources
Domains Frontend, Internationalization, Locale Management
Last Updated 2026-02-08 00:00 GMT

Overview

Core internationalization configuration module that defines supported locales, locale mapping utilities, documentation language resolution, and system notice translations.

Description

The Language Config module is the central i18n configuration hub for the Dify frontend. It imports the raw language catalog from languages.ts and provides:

  • LanguagesSupported -- A filtered array of locale codes from the language catalog where supported: true, serving as the canonical list of available locales.
  • Locale type -- A TypeScript union type of all supported locale codes, including legacy underscore-separated variants (ja_JP, zh_Hans, en_US).
  • I18nText type -- A Record type mapping each supported locale to a string, used for typing inline translation objects.
  • getLanguage -- Converts hyphenated locale codes to underscore format for compatibility.
  • getDocLanguage -- Maps locale codes to documentation site language codes (zh, ja, en).
  • getPricingPageLanguage -- Maps locales to pricing page language suffixes.
  • localeMap -- A comprehensive mapping of locale codes (including legacy variants) to short language codes used by external services.
  • NOTICE_I18N -- Pre-translated system maintenance notice content (title, description, link) for all supported languages.

Usage

Import from this module whenever you need the list of supported locales, need to resolve a locale to a documentation or external service language code, or need to display the system maintenance notice.

Code Reference

Source Location

Signature

export type Item = { value: number | string, name: string, example: string }
export type I18nText = Record<typeof LanguagesSupported[number], string>
export type Locale = 'ja_JP' | 'zh_Hans' | 'en_US' | (typeof languages[number])['value']

export const languages: typeof data.languages
export const LanguagesSupported: Locale[]
export const localeMap: Record<Locale, string>

export const getLanguage: (locale: Locale) => Locale
export const getDocLanguage: (locale: string) => DocLanguage
export const getPricingPageLanguage: (locale: string) => string

export const NOTICE_I18N: {
  title: Record<string, string>
  desc: Record<string, string>
  href: string
}

Import

import {
  LanguagesSupported,
  getLanguage,
  getDocLanguage,
  localeMap,
  NOTICE_I18N,
} from '@/i18n-config/language'
import type { Locale, I18nText } from '@/i18n-config/language'

I/O Contract

Inputs

Name Type Required Description
locale string Yes A locale code to convert or look up

Outputs

Name Type Description
LanguagesSupported Locale[] Array of all supported locale codes
Locale (getLanguage) Locale Underscore-separated locale code
DocLanguage 'ja' | 'en' Documentation site language code
string (getPricingPageLanguage) string Pricing page language suffix or empty string
localeMap value string Short language code for external services

Usage Examples

import { LanguagesSupported, getDocLanguage, localeMap, NOTICE_I18N } from '@/i18n-config/language'
import type { Locale, I18nText } from '@/i18n-config/language'

// Check if a locale is supported
const isSupported = LanguagesSupported.includes('ja-JP')

// Resolve doc language
const docLang = getDocLanguage('zh-Hans') // 'zh'

// Use locale map
const shortCode = localeMap['fr-FR'] // 'fr'

// Display maintenance notice
const currentLocale = 'en_US'
const noticeTitle = NOTICE_I18N.title[currentLocale]
const noticeDesc = NOTICE_I18N.desc[currentLocale]

// Type an i18n text object
const myText: I18nText = {
  'en-US': 'Hello',
  'zh-Hans': '你好',
  // ... all supported locales
}

Related Pages

Page Connections

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