Permalink
Browse files

Grammar and punctuation fixes (#36)

Summary:
In the docs files, there were quite a few missing points of punctuation. I took the liberty to add necessary punctuation as well as a missing "the" in one file.
Pull Request resolved: #36

Differential Revision: D13622881

fbshipit-source-id: 80cd30da63cda3fa16ab594c5968122762c270e1
  • Loading branch information...
ethanmnrd authored and facebook-github-bot committed Jan 10, 2019
1 parent 05e88f6 commit 1e1cb5f2f42145b995a7a4cc59e8bb483d6c83a7
@@ -37,7 +37,7 @@ FBT works by transforming your `<fbt>` and `fbt(...)` constructs via
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
at runtime.

## Full documentation
https://facebookincubator.github.io/fbt
@@ -5,7 +5,7 @@ sidebar_label: Introduction
---
The fbt framework has two (mostly) equivalent APIs: A declarative JSX-style `<fbt>` tag API and a "vanilla" or "functional" `fbt(...)` API that more closely resembles standard JavaScript. In general, you can compose your translatable text in either format. As the following example illustrates, the child of the `<fbt>` tag shows up as the first argument to `fbt` and any attributes show up in the optional third argument parameter. The `desc` (text description) argument is the exception to this rule because it is a *required* parameter and attribute in `fbt(...)` and `<fbt>` respectively.

Let's start with a simple example
Let's start with a simple example:

## JSX `<fbt />` API
```
@@ -46,7 +46,7 @@ Defaults for the above optional attributes may be provided in the
docblock with the `@fbt` pragma. It uses a straight `JSON.parse` to
interpret this, so you'll have to make sure your object is parseable. (i.e. keys should be wrapped in `"double quotes"`)

E.g
E.g.
```
/**
* @fbt {"author": "me", "project": "awesome sauce"}
@@ -21,7 +21,7 @@ the `fbt(...)` API** </span>
</fbt>
```

When extracted for translation, the result is
When extracted for translation, the result is:

```
{
@@ -56,7 +56,7 @@ When extracted for translation, the result is
```

Notice the description for "vacation" is auto-generated with an `"In
the phrase: ..."` prefix. Additionally we use a convention of an `=`
the phrase: ..."` prefix. Additionally, we use a convention of an `=`
prefix in the interpolation `{=awesome vacation}` to signal to the
translator that this exact word or phrase goes in the associated outer
sentence.
@@ -31,7 +31,7 @@ The enum-manifest should be a `"JSON.parseable"` mapping from all known enums in
},
}
```
We've provided `manifest.js` as an easy way to generate this manifest from a given source tree
We've provided `manifest.js` as an easy way to generate this manifest from a given source tree.

`collectFbts.js` will output a JSON object in the following format:

@@ -62,7 +62,7 @@ We've provided `manifest.js` as an easy way to generate this manifest from a giv
`phrases` here represents all the *source* information we need to
process and produce an `fbt._(...)` callsite's final payload. When
combined with corresponding translations to each `hashToText` entry we
can produce the translated payloads `fbt._()` expects
can produce the translated payloads `fbt._()` expects.

When it comes to moving from source text to translations, what is most
pertinent is the `hashToText` payload containing all relevant texts
@@ -75,7 +75,7 @@ In the FBT framework, there are 2 main places we uses hashes for
identification: **text** and **fbt callsite**. The `hashToText` mapping
above represents the hash (using whichever algorithm was chosen in
`collectFbt`) of the **text** and its **description**. This is used
when *building* the translated payloads
when *building* the translated payloads.

The hash of the callsite (defaulting to `jenkins` hash) is used to
look up the payload in `FbtTranslations`. This is basically the hash of
@@ -3,4 +3,4 @@ id: doc4
title: API
---

The FBT API is comprised of a top-level `fbt(...)` call or `<fbt>...</fbt>` instance with a handful of fbt constructs that can be used to alter the text generated
The FBT API is comprised of a top-level `fbt(...)` call or `<fbt>...</fbt>` instance with a handful of fbt constructs that can be used to alter the text generated.
@@ -7,7 +7,7 @@ sidebar_label: Enumerations
Enumerations eliminate a lot of UI code duplication while enabling accurate translations. `<fbt:enum>` and `fbt.enum` both provide the ability to add your ad-hoc or pre-defined and shared enumerations.

## Adhoc enums
Adhoc enums can be provided inline to the `enum-range` attribute or as the second parameter to `fbt.enum`
Adhoc enums can be provided inline to the `enum-range` attribute or as the second parameter to `fbt.enum`.
### Enum map
```
<fbt desc="buy prompt">
@@ -33,7 +33,7 @@ fbt(
```

### Shorthand array (keys = values)
The shorthand array adhoc enum functions as though you had a `{value: value}` map
The shorthand array adhoc enum functions as though you had a `{value: value}` map.
```
<fbt desc="buy prompt">
Buy a new
@@ -69,7 +69,7 @@ All the above examples [extract](collection.md) the same 4 separate strings for
## Shared enums
If you need to use same enum multiple times, you can use a pre-defined
If you need to use the same enum multiple times, you can use a pre-defined
enum. These enums need to be able to be `"JSON.stringifiable"` and
should have simple key/value structures. They also require a separate
build step to generate an enum-manifest and source manifest that makes
@@ -16,13 +16,13 @@ Interpolation of dynamic text and other markup is accomplished in the FBT framew
fbt('Hello, ' + fbt.param('name', person.getName()), 'param example')
```

These both [extract](collection.md) to the same following text
These both [extract](collection.md) to the same following text:

```
"Hello, {name}"
```

Tokens are delimited with the braces above and translations are expected to keep the same total token *count* and same token *names* for any given `fbt` callsite
Tokens are delimited with the braces above and translations are expected to keep the same total token *count* and same token *names* for any given `fbt` callsite.

### Required attributes
* **name** `string`: Name of the token
File renamed without changes.
@@ -8,4 +8,4 @@ sidebar_label: On i18n standards
Facebook uses a `xx_XX` format for representing locales like: `en_US`, `jp_JP`, etc. We're actively working on separating our `language` + `country` combinations internally, and where we go from there as far as standards go is unknown. BUT if you'd like to help support `bcp-47` standards or similar, you are very welcome to contribute!

## CLDR
We generate all our number variation data found in our `IntlNumberTypes` internals from [CLDR (Unicode Common Locale Data Repository)](http://cldr.unicode.org/)
We generate all our number variation data found in our `IntlNumberTypes` internals from [CLDR (Unicode Common Locale Data Repository)](http://cldr.unicode.org/).
@@ -6,7 +6,7 @@ sidebar_label: Babel Transforms
The fbt comes with 2 babel transforms.

## babel-plugin-fbt
The first is the `babel-plugin-fbt`. Internally it firsts transforms `<fbt>` instances into their `fbt(...)` equivalent. After which it turns all `fbt(...)` calls into `fbt._(...)` calls with an intermediary payload as the first argument, and the runtime arguments to be passed in.
The first is the `babel-plugin-fbt`. Internally, it firsts transforms `<fbt>` instances into their `fbt(...)` equivalent. After which, it turns all `fbt(...)` calls into `fbt._(...)` calls with an intermediary payload as the first argument, and the runtime arguments to be passed in.

## babel-plugin-fbt-runtime
This transform takes the intermediary payload and turns it into the object that the `fbt._(...)` runtime expects.
@@ -43,6 +43,6 @@ You can override this behavior in `fbt:param` by setting the
string in the replacement.

You can override this in `fbt.plural` [by providing the `value`
option](plurals#optional-arguments)
option](plurals#optional-arguments).


0 comments on commit 1e1cb5f

Please sign in to comment.