0.0.2 • Published 4 years ago

fluent-typescript-loader v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

fluent-typescript-loader

Webpack loader to create TypeScript declarations for Fluent files

Fluent is a Mozilla's programming language for natural-sounding translations. And fluent-typescript-loader is a Webpack Loader to automatically generate type definitions for its mensagens.

:warning: It's a working in project project! At this moment, you should not use it on production!

How to use

You could check a complete example on /example folder.

Step by step:

1 - Add fluent-typescript-loader on your project:

> npm install fluent-typescript-loader --save-dev
- or -
> yarn add fluent-typescript-loader --dev

2 - Add this step on your webpack config:

{
  test: /\.ftl$/,
  use: {
    loader: 'fluent-typescript-loader',
  },
},

:warning: If you are using others loaders on .ftl files, you should add the fluent-typescript-loader step on last!

3 - Add someone on your TS files:

import '../assets/locales/pt-br/translations.ftl'

4 - And finally, add a cast on FluentBundle call:

const bundle = new FluentBundle('pt-br') as FluentBundleTyped

Finish! Now you have amazing types on your translations messages 🎉

With thanks

This package borrows heavily from css-modules-typescript-loader.

0.0.2

4 years ago

0.0.1

4 years ago