Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
commit
03634b1ca3
11340 files changed
+3442369
No files matched your search
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Resolve a Bot Mode message key against the plugin's own `en` bundle.
|
||||
*
|
||||
* Tests that render Bot Mode components stub `usePluginI18n` with this instead
|
||||
* of registering the bundle for real: registration normally happens in
|
||||
* `ctx.register`, and the registry lives behind an app-internal module a plugin
|
||||
* (or its tests) may not import.
|
||||
*/
|
||||
|
||||
import { BOTS_LOCALES } from './i18n'
|
||||
|
||||
export function translateBots(key: string, ...args: unknown[]): string {
|
||||
const value = key
|
||||
.split('.')
|
||||
.reduce<unknown>(
|
||||
(node, part) => (node && typeof node === 'object' ? (node as Record<string, unknown>)[part] : undefined),
|
||||
BOTS_LOCALES.en
|
||||
)
|
||||
|
||||
if (typeof value === 'function') {
|
||||
return String((value as (...params: unknown[]) => string)(...args))
|
||||
}
|
||||
|
||||
return typeof value === 'string' ? value : key
|
||||
}
|
||||
Reference in new issue
Block a user