Auto-parameterization
What is Auto Parameterization?
The basics
<fbt>
will automatically wrap any non-fbt children in the top-level
<fbt>
as though they were written with an <fbt:param>
with a
name
attribute containing the child's text. It will pull any child
text into the parameter name, including those of recursive structures.
- JSX fbt syntax:
- Function syntax:
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 adding an equal sign (=
)
prefix in the interpolation {=awesome vacation}
to signal to the
translator that this exact word or phrase goes in the associated outer
sentence.
Furthermore, we provide a mapping {<childIndex>: <parentIndex>}
in
the collection output childParentMappings
. At Meta, we use
these to display all relevant inner and outer strings when translating
any given piece of text. We recommend you do the same in whatever
translation framework you use. Context is crucial for accurate
translations.
Advanced scenario: string with nested fbt constructs
You can still use fbt constructs that produce multiple strings (e.g. <fbt:pronoun>
) and expect the Auto Parameterization to work.
Example with fbt:pronoun and fbt:plural
Top-level strings
Top-level strings are build from the combination of all text sub-groups:
Extracted top-level strings by string variation criteria:
- Female:
- Single:
"{=She} uploaded {=one photo} that you haven't seen yet."
- Plural:
"{=She} uploaded {=[number] photos} that you haven't seen yet."
- Single:
- Male:
- Single:
"{=He} uploaded {=one photo} that you haven't seen yet."
- Plural:
"{=He} uploaded {=[number] photos} that you haven't seen yet."
- Single:
- Unknown:
- Single:
"{=They} uploaded {=one photo} that you haven't seen yet."
- Plural:
"{=They} uploaded {=[number] photos} that you haven't seen yet."
- Single:
NOTE: all these strings have the same description: "advanced rich content example"
Combinations of nested strings
Texts and descriptions of nested strings will have the relevant gender/number variations as well:
Child-to-parent phrase mapping:
It's generally useful to submit translation requests containing strings that are closely related. It helps improve translation consistency (tone, vocabulary, etc...) since the same translator can work on the same bundle of strings all at once.
To support this use case, as part of the fbt-collect
output, we expose the relationship between each parent/child string
in the childParentMappings
property.
For each mapping entry:
- the key represents the index of the child phrase
- the value represents the index of the parent phrase