##// END OF EJS Templates
typescript strict mode...
typescript strict mode Added TAP traits, TAP text writer

File last commit:

r0:8e944df97a68 default
r1:b6ccfccf314f default
Show More
i18n.ts
28 lines | 848 B | video/mp2t | TypeScriptLexer
cin
Initial commit, copied files related to .tsx scripts support.
r0 import { MapOf } from "@implab/core-amd/interfaces";
import { NlsBundle } from "./NlsBundle";
import { isPromise } from "@implab/core-amd/safe";
export function bundle<T extends object>(nls: T, locales?: MapOf<any>) {
const nlsBundle = new NlsBundle(nls, locales);
const fn = (locale?: string) => {
const result = nlsBundle.getLocale(locale);
if (isPromise(result))
throw new Error(`The bundle '${locale}' isn't loaded`);
else
return result;
};
fn.define = (pack: Partial<T>) => pack;
fn.default = nlsBundle.default;
fn.load = async (id: string, require: Require, cb: { (): void; error: (arg0: any) => void; }) => {
try {
await nlsBundle.getLocale(id);
cb();
} catch (e) {
cb.error(e);
}
};
return fn;
}