@kylexd/remote-i18n-kit
v0.0.3
Published
Remote i18n runtime and locale sync utilities.
Readme
@kylexd/remote-i18n-kit
Overview
Remote locale loading and locale file tooling package.
The runtime entry handles remote message loading, merging, and cache access. The node entry provides scripts for local locale files and generated outputs.
Install
npm install @kylexd/remote-i18n-kitExports
Runtime entry:
createRemoteI18nLoadercreateLangCachemergeLocaleMessagesnormalizeRemoteMessages
Runtime options include locale range controls such as cacheLocales, requestLocales, and mergeLocales.
Node entry:
syncRemoteLocalesfindEmptyLocalesloadLocaleJsonByLocaleswriteLocaleJsonByLocalesgenerateLocaleExcelcreateLocaleRowswriteLocaleOutput
Basic usage
import { createRemoteI18nLoader } from '@kylexd/remote-i18n-kit'
const loader = createRemoteI18nLoader({
locales,
namespace,
requestRemoteMessages,
})const loader = createRemoteI18nLoader({
locales,
namespace,
requestRemoteMessages,
requestLocales: () => [currentLocale],
mergeLocales: () => [currentLocale],
})import { syncRemoteLocales } from '@kylexd/remote-i18n-kit/node'
await syncRemoteLocales({
locales,
namespace,
apiUrl,
localeDir,
outputDir,
excelColumns,
timeoutMs: 30000,
validateResponse(response) {
if (!response.ok) throw new Error(`Remote locale request failed: ${response.status}`)
},
})Build
npm run buildNotes
- The runtime entry is intended for browser code.
- The node entry is intended for file and output generation scripts.
- Locale keys, namespaces, cache keys, and output columns are provided by the host project.
- Runtime locale ranges default to
localesunless configured by the host project. - Node remote requests accept
requestInit,headers,timeoutMs,validateResponse, andfetchImplfor projects that need axios-like timeout, header, or response validation behavior.
License
UNLICENSED
