This loader is for webpack and loads translation files for project Fluent. It have very simple and naive realization, but works well.
npm install --save @fluent/bundle project-fluent-loader
yarn add @fluent/bundle project-fluent-loader
default extension for project-fluent files is .ftl
. I recommend to use it. In this case we need to add only loader to webpack config to work with this kind of files:
/** @file webpack.config.js */
module.exports = {
module: {
rules: [
{
test: /\.ftl$/,
loader: 'project-fluent-loader'
}
]
}
};
Importing file returns default instanced of FluentResource from @fluent/bundle
:
/** @file translation.ts */
import enGB from './en-GB.ftl';
export const l10n = new ReactLocalization();
l10n.addBundle(enGB);
Just add "project-fluent-loader"
to #compilerOptions.lib
array in your tsconfig.json
config:
{
"compilerOptions": {
"lib": [
"project-fluent-loader"
]
}
}
Or if you prefer to use different file format use declaration from this file.