Package APIs

@i18n-micro/devtools-ui

Exported API of @i18n-micro/devtools-ui, generated from the source.

DevTools UI and Vite plugin for Nuxt I18n Micro.

Entry points: @i18n-micro/devtools-ui, @i18n-micro/devtools-ui/bridge, @i18n-micro/devtools-ui/bridge/create, @i18n-micro/devtools-ui/vite.

@i18n-micro/devtools-ui

Components

I18nDevToolsElement

const I18nDevToolsElement: VueElementConstructor

Functions

createBridge

Create a universal bridge for DevTools communication This bridge works with any framework by using an adapter pattern

function createBridge(options: CreateBridgeOptions): I18nDevToolsBridge

See CreateBridgeOptions · I18nDevToolsBridge

createRpcClient

function createRpcClient(): I18nDevToolsBridge

See I18nDevToolsBridge

register

Register the i18n-devtools-ui custom element This should be called once before using the element

function register(): void

setupRpcHost

Connects an iframe to an existing Bridge.

function setupRpcHost(iframeWindow: Window, bridge: I18nDevToolsBridge): () => void
iframeWindow
Window required
reference to iframe window (contentWindow)
bridge
I18nDevToolsBridge required
local bridge implementation (adapter to Nuxt/Astro RPC)

Returns — cleanup function

See I18nDevToolsBridge

Types

BridgeAdapter

Adapter interface for accessing i18n instance data Each framework package will implement this adapter for their specific i18n instance

interface BridgeAdapter
getRouteCache
() => Record<string, TranslationContent> required
Get translations cache Keys are in format "locale:routeName" (e.g., "en:index", "en:home")
addTranslations
(locale: string, content: TranslationContent, merge: boolean) => void required
Add or update translations for a locale
addRouteTranslations
(locale: string, routeName: string, content: TranslationContent, merge: boolean) => void required
Add or update route-specific translations
subscribe
(callback: () => void) => () => void required
Subscribe to changes in translations
getCurrentLocale
() => string
Get current locale (optional)
getFallbackLocale
() => string
Get fallback locale (optional)

CreateBridgeOptions

interface CreateBridgeOptions
adapter
BridgeAdapter required
locales
Locale[]
defaultLocale
string
translationDir
string
base
string
The dev server's API base, the plugin's base option (default '/__i18n_api').

I18nDevToolsBridge

Bridge interface for communication between DevTools UI and framework-specific RPC This abstraction allows the UI to work with both Nuxt and Astro DevTools

interface I18nDevToolsBridge
getLocalesAndTranslations
() => Promise<LocaleData> required
Get all locales and their translation files
getConfigs
() => Promise<ModuleOptions> required
Get i18n module configuration
saveTranslation
(filePath: string, content: TranslationContent) => Promise<void> required
Save translation content to a file
onLocalesUpdate
(callback: (data: LocaleData) => void) => () => void required
Subscribe to locale updates from the server

JsonRpcEvent

interface JsonRpcEvent
jsonrpc
'2.0' required
method
string required
params
unknown

JsonRpcRequest

interface JsonRpcRequest
jsonrpc
'2.0' required
id
string required
method
string required
params
unknown

JsonRpcResponse

interface JsonRpcResponse
jsonrpc
'2.0' required
id
string required
result
unknown
error
{ code: number; message: string; data?: unknown; }

JSONValue

type JSONValue = string | null | number | boolean | {
  [key: string]: JSONValue;
}

LocaleData

type LocaleData = Record<string, TranslationContent>

See TranslationContent

TranslationContent

interface TranslationContent
[key: string]
JSONValue

TreeNode

interface TreeNode
name
string required
fullPath
string required
isFile
boolean required
children
TreeNode[] required

@i18n-micro/devtools-ui/bridge

Also exports, as @i18n-micro/devtools-ui does: I18nDevToolsBridge · JSONValue · LocaleData · TranslationContent.

Constants

BRIDGE_INTERFACE_MODULE

Runtime marker so the bridge types entry can be published as a JS module.

const BRIDGE_INTERFACE_MODULE: true

@i18n-micro/devtools-ui/bridge/create

Also exports, as @i18n-micro/devtools-ui does: createBridge · BridgeAdapter · CreateBridgeOptions.

@i18n-micro/devtools-ui/vite

Functions

i18nDevToolsIntegration

The devtools as an Astro integration: an app in the dev toolbar (Astro has no transformIndexHtml, so the plugin's button never shows there).

function i18nDevToolsIntegration(
  options?: Omit<DevToolsPluginOptions, 'injectButton'>,
): { … }
name
string required
hooks
{ 'astro:config:setup': ({ command, updateConfig, addDevToolbarApp }: ToolbarSetup) => void; } required

See DevToolsPluginOptions

i18nDevToolsPlugin

function i18nDevToolsPlugin(options?: DevToolsPluginOptions): PluginOption

See DevToolsPluginOptions

Types

DevToolsPluginOptions

interface DevToolsPluginOptions
base
string
translationDir
string
defaultLocale
string
Reported by /config. Default: the first locale file in translationDir.
fallbackLocale
string
Reported by /config. Default: defaultLocale.
injectButton
boolean

Generated from the TypeScript sources and their JSDoc by pnpm run docs:generate. Back to all packages · Integration guides