mirror of
https://github.com/wassname/talk.git
synced 2026-07-10 18:48:37 +08:00
Integrate actual translations into integration tests
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { FluentBundle } from "fluent/compat";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
// These locale prefixes are always loaded.
|
||||
const commonPrefixes = ["common", "framework"];
|
||||
|
||||
function createFluentBundle(
|
||||
target: string,
|
||||
pathToLocale: string
|
||||
): FluentBundle {
|
||||
const bundle = new FluentBundle("en-US");
|
||||
const files = fs.readdirSync(pathToLocale);
|
||||
const prefixes = commonPrefixes.concat(target);
|
||||
files.forEach(f => {
|
||||
prefixes.forEach(prefix => {
|
||||
if (f.startsWith(prefix)) {
|
||||
bundle.addMessages(
|
||||
fs.readFileSync(path.resolve(pathToLocale, f)).toString()
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
return bundle;
|
||||
}
|
||||
|
||||
export default createFluentBundle;
|
||||
@@ -2,3 +2,5 @@ export {
|
||||
default as createRelayEnvironment,
|
||||
CreateRelayEnvironmentParams,
|
||||
} from "./createRelayEnvironment";
|
||||
|
||||
export { default as createFluentBundle } from "./createFluentBundle";
|
||||
|
||||
Reference in New Issue
Block a user