Budou extension for Grow.
Installs a filter into the Jinja2 environment that uses the Google Cloud
Natural Language API to analyze text and insert <span>
tags into HTML for
intelligent word wrapping. The filter only activates when a page is being
rendered in a supported language. Supported language identifiers:
- ja
- ko
- zh
- zh_Hans
- zh_Hant
For more information on Budou, see the
google/budou
repository.
NOTE: Budou requires authentication to the Google Cloud Natural Language API. You will have to authorize Grow to access this API, or use a service account on a Google Cloud project where the API is enabled.
- Create an
extensions.txt
file within your pod. - Add to the file:
git+git://github.com/grow/grow-ext-budou
- Ensure
.gitignore
containsextensions
. - Run
grow install
. - Add the following section to
podspec.yaml
:
extensions:
jinja2:
- extensions.budou_ext.BudouExtension
# Append the budou filter.
{{_("I will eat rice at Roppongi Hills.")|budou}}
# Outputs the following HTML.
<span class="ww">六本木</span><span class="ww">ヒルズに</span><span
class="ww">います。</span>
Budou works by wrapping elements that should not be wrapped in a
<span class="ww">
element. Add the following CSS to prevent these
elements from wrapping.
.ww {
display: inline-block;
}