Open
Description
In https://github.com/projectfluent/fluent.js/wiki/React-Tutorial, I had to make the following adjustments to the final generateBundles
function to get it to compile:
Current:
// Generate bundles for each locale.
async function generateBundles() {
return languages.map(locale => {
const translations = await getMessages(locale);
const bundle = new FluentBundle(locale);
bundle.addMessages(translations);
return bundle;
});
}
Fixed:
// Generate bundles for each locale.
async function generateBundles() {
return languages.map(async (locale) => {
const translations = await getMessages(locale);
const bundle = new FluentBundle(locale);
bundle.addResource(new FluentResource(translations));
return bundle;
});
}
At first I was getting Unexpected reserved word 'await'
for getMessages; I fixed that by marking the map call as async. I then had to update addMessages
to addResource
because addMessages
doesn't exist.