Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
Add a manifest generator for OSS
Browse files Browse the repository at this point in the history
Summary: Give OSS a script to generate enum and src manifests for `JSFbtTableBuilder`

Differential Revision: D13538875

fbshipit-source-id: a514acaf0e80bacbfba08265e8c3a622574fe9d6
  • Loading branch information
John Watson authored and facebook-github-bot committed Dec 22, 2018
1 parent d8813e1 commit 958d62e
Show file tree
Hide file tree
Showing 13 changed files with 8,335 additions and 35 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
node_modules/*
yarn.lock
yarn-error.log

demo-app/yarn-error.log
demo-app/yarn.lock
demo-app/.enum_manifest.json
demo-app/.src_manifest.json
demo-app/node_modules/*
demo-app/output
demo-app/source_strings.json
demo-app/src/translatedFbts.json
demo-app/node_modules/*
demo-app/yarn-error.log
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to **fbt**x
# Contributing to **fbt**
We want to make contributing to this project as easy and transparent as
possible.

Expand Down
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,45 @@ FBT is an internationalization framework designed to be both intuitive and power
[See here](https://github.com/facebook/fbt)

## Requirements
* [node]()
* yarn
* babel
* [node](https://nodejs.org/)
* [yarn](https://yarnpkg.com/)
* [babel](https://babeljs.io/)

## Building fbt
...
```
git clone [email protected]:facebook/fbt.git;
cd fbt;
yarn install;
```

## Installing fbt
We have plans to make the transform and runtime installable as an npm package. Until then,
See how to use the source directly with Babel and Webpack in our demo-app:

## Installing __________
```
git clone [email protected]:facebook/fbt.git;
cd fbt/demo-app;
cd demo-app; # from fbt repo
yarn install;
yarn manifest;
yarn collect-fbts;
yarn translate-fbts;
yarn start;
```


## How fbt works
## How FBT works
FBT works by transforming your `<fbt>` and `fbt(...)` constructs in
Babel plugins. These plugins serve to extact strings from source and
lookup translate payloads generated at build-time.
Babel plugins. These plugins serve to extract strings from source and
lookup translate payloads generated at build-time. FBT creates tables
of all possible variations for the given fbt phrase and accesses this
at runtime

## Full documentation
https://facebook.github.io/fbt

## Join the __________ community
## Join the fbt community
* Website: https://facebook.github.io/fbt
* Facebook page: m.me/sjtbf
* Slack: https://fbtjs.slack.com
See the CONTRIBUTING file for how to help out.

## License
fbt is MIT licensed, as found in the LICENSE file.
FBT is MIT licensed, as found in the LICENSE file.
7 changes: 5 additions & 2 deletions demo-app/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Babel/Webpack/React OSS FBT Demo

* `yarn install` to pull in dependencies down
* `yarn build` to generate static files in `./output/`.
* `yarn start` to run a local server with hot reloading.
* `yarn manifest` to generate enum and source manifests
* `yarn collect-fbts` to collect FBT translatable texts
* `yarn translate-fbts` to generate translatedFbts.js from translation_input.json
* `yarn build` to generate static files in `./output/`.
* The commands above are required to run this step
* `yarn start` to run a local server with hot reloading.
* `yarn test ./src` to run unit tests.

9 changes: 0 additions & 9 deletions demo-app/enum-manifest.json

This file was deleted.

4 changes: 3 additions & 1 deletion demo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
"license": "MIT",
"scripts": {
"build": "babel-node ../node_modules/webpack/bin/webpack",
"collect-fbts": "babel-node ../transform/babel-plugin-fbt/bin/collectFBT --json-input < src-manifest.json > source_strings.json",
"manifest": "babel-node ../transform/babel-plugin-fbt/bin/manifest --src src",
"collect-fbts": "babel-node ../transform/babel-plugin-fbt/bin/collectFBT --json-input < .src_manifest.json > source_strings.json",
"translate-fbts": "babel-node ../transform/babel-plugin-fbt/bin/translate.js --jenkins < ./translation_input.json > src/translatedFbts.json",
"clean-fbts": "rm .enum_manifest.json .src_manifest.json source_strings.json src/translatedFbts.json 2&> /dev/null || exit 0",
"start": "babel-node ../node_modules/webpack-dev-server/bin/webpack-dev-server --open",
"test": "babel-node ../node_modules/jest/bin/jest --config ./jest.config.json"
},
Expand Down
1 change: 0 additions & 1 deletion demo-app/src-manifest.json

This file was deleted.

2 changes: 1 addition & 1 deletion demo-app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = {
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-transform-flow-strip-types',
['../transform/babel-plugin-fbt/index.js', {
fbtEnumManifest: require('./enum-manifest.json')
fbtEnumManifest: require('./.enum_manifest.json')
}],
'../transform/babel-plugin-fbt-runtime/index.js',
]
Expand Down
Loading

0 comments on commit 958d62e

Please sign in to comment.