@boost/translate
Advanced tools
Comparing version 5.0.0-alpha.1 to 5.0.0-alpha.2
@@ -22,3 +22,3 @@ import { type InitOptions } from 'i18next'; | ||
*/ | ||
export declare function createTranslator(namespace: string[] | string, resourcePath: PortablePath | PortablePath[], options?: TranslatorOptions): Translator; | ||
export declare function createTranslator(namespace: string[] | string, resourcePath: PortablePath | PortablePath[], options?: TranslatorOptions): Promise<Translator>; | ||
//# sourceMappingURL=createTranslator.d.ts.map |
{ | ||
"name": "@boost/translate", | ||
"version": "5.0.0-alpha.1", | ||
"version": "5.0.0-alpha.2", | ||
"type": "module", | ||
@@ -35,4 +35,4 @@ "release": "1651512178249", | ||
"dependencies": { | ||
"@boost/common": "^5.0.0-alpha.1", | ||
"@boost/internal": "^5.0.0-alpha.1", | ||
"@boost/common": "^5.0.0-alpha.2", | ||
"@boost/internal": "^5.0.0-alpha.2", | ||
"i18next": "^23.8.2", | ||
@@ -59,3 +59,3 @@ "os-locale": "^6.0.2" | ||
}, | ||
"gitHead": "8fd0f41cca47f7b6ce605eaca5cb2b4932fc89a5" | ||
"gitHead": "60175188388d1667eb57d53e03b7bfefc092b67c" | ||
} |
@@ -13,3 +13,3 @@ # Translate - Boost | ||
const msg = createTranslator(['common', 'errors'], '../path/to/resources'); | ||
const msg = await createTranslator(['common', 'errors'], '../path/to/resources'); | ||
@@ -16,0 +16,0 @@ msg('common:welcome', { name: 'Boost' }); // Hello Boost! |
@@ -9,9 +9,2 @@ import { createInstance, type InitOptions } from 'i18next'; | ||
// istanbul ignore next | ||
function handleError(error: Error | null) { | ||
if (error) { | ||
throw error; | ||
} | ||
} | ||
export interface TranslatorOptions { | ||
@@ -36,7 +29,7 @@ /** Automatically detect the locale from the environment. Defaults to `true`. */ | ||
*/ | ||
export function createTranslator( | ||
export async function createTranslator( | ||
namespace: string[] | string, | ||
resourcePath: PortablePath | PortablePath[], | ||
options: TranslatorOptions = {}, | ||
): Translator { | ||
): Promise<Translator> { | ||
const { | ||
@@ -69,22 +62,19 @@ autoDetect = true, | ||
void translator.init( | ||
{ | ||
backend: { | ||
format: resourceFormat, | ||
paths: resourcePaths, | ||
}, | ||
cleanCode: true, | ||
debug: debugOpt, | ||
defaultNS: namespaces[0], | ||
fallbackLng: fallbackLocale, | ||
initImmediate: false, | ||
lng: locale, | ||
load: lookupType, | ||
lowerCaseLng: false, | ||
ns: namespaces, | ||
returnEmptyString: true, | ||
returnNull: true, | ||
await translator.init({ | ||
backend: { | ||
format: resourceFormat, | ||
paths: resourcePaths, | ||
}, | ||
handleError, | ||
); | ||
cleanCode: true, | ||
debug: debugOpt, | ||
defaultNS: namespaces[0], | ||
fallbackLng: fallbackLocale, | ||
initImmediate: false, | ||
lng: locale, | ||
load: lookupType, | ||
lowerCaseLng: false, | ||
ns: namespaces, | ||
returnEmptyString: true, | ||
returnNull: true, | ||
}); | ||
@@ -91,0 +81,0 @@ function msg( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
37442
613