Braze (Appboy)
Through Transifex’s integration with Braze (formerly Appboy), you can pull translations from Transifex into Braze directly and launch multilingual engagement campaigns.
Connecting your Transifex account to Braze
You’ll need to connect your Transifex account to Braze in order to be able to pull translations back into Braze. To do this:
-
From the left navigation, head to Manage App Group under APP SETTINGS.
-
Go to the Connected Content tab and click on +Add Credential near the top right corner.
-
In the popup modal, give your credential a name. We suggest using something simple like
Transifex
. Then enter either your Transifex username/password orapi
/API token. Hit Save after you’ve filled in all the information.
Adding content to Transifex
For the time being, the integration does not support pushing of content from Braze to Transifex. You’ll have to manually create a JSON file with the content you want to translate and upload it to Transifex. Here's how you can do this:
-
Open up a new file in a text editor such as Atom.Â
-
Type in your source content following the structure in the example below. Be sure to include the source content on both sides of the colon, since the key and value are identical in the source language.
{ "Your source content":"Your source content", "Another source string":"Another source string" }
-
Save the file as a JSON file with the extension
.json
. -
Head to the project you created earlier in Transifex and upload your file as a
Key-value JSON
file.
Now your content is ready to be translated! We won't go into the various way you can translate your content in this article, but you can learn more about the available options here.
Getting translations into Braze
Once your translations are complete, you can pull them back into Braze using a modified version of the snippet below. The snippet might look a little daunting but we'll go over what to tweak and where to put it.
{% assign key = "<Insert Source String Here>" %}
{% assign context = "<Insert Context Here (Optional)>" %}
{% assign source_string = key | append: ':' | append: context %}
{% assign project = "<Insert Project Slug Here>" %}
{% assign resource = "<Insert Resource Slug Here" %}
{% assign source_hash = source_string | md5 %}
{% if {{${language}}} == "en" or {{${language}}} == "it" or {{${language}}} == "de" or {{${language}}} == "another_language_you_support" %}
{% connected_content https://www.transifex.com/api/2/project/{{project}}/resource/{{resource}}/translation/{{${language}}}/string/{{source_hash}}/ :basic_auth <Insert Credential Name Here> :save strings %}
{% endif %}
{% if {{strings}} != null and {{strings.translation}} != "" and {{${language}}} != null %}
{{strings.translation}}
{% else %}
{% abort_message('null or blank') %}
{% endif %}
Tweaking the snippet
Let's say you've followed the previous steps in the guide and now have the following:
- A string in the JSONÂ file you uploaded which saysÂ
Your source content
- A Transifex project with the slugÂ
braze
- A resource with the slugÂ
pushnotification
- English as your source language and German (de) and French (fr) as your target languages
- A connected content credential in Braze called
Transifex
Your project and resource slugs can be found in the URL bar of your browser after you've selected a resource in Transifex. The URL follows this structure:
https://www.transifex.com/org_slug/project_slug/resource_slug/
Then your tweaked snippet would look like this:
{% assign key = "Your source content" %}
{% assign context = "context" %}
{% assign source_string = key | append: ':' | append: context %}
{% assign project = "braze" %}
{% assign resource = "pushnotification" %}
{% assign source_hash = source_string | md5 %}
{% if {{${language}}} == "en" or {{${language}}} == "de" or {{${language}}} == "fr" %}
{% connected_content https://www.transifex.com/api/2/project/{{project}}/resource/{{resource}}/translation/{{${language}}}/string/{{source_hash}}/ :basic_auth Transifex :save strings %}
{% endif %}
{% if {{strings}} != null and {{strings.translation}} != "" and {{${language}}} != null %}
{{strings.translation}}
{% else %}
{% abort_message('null or blank') %}
{% endif %}
Note that tweaks were only made in Lines 1, 2, 4, 5, 7, and 8, not counting the line break. And changes to Line 2 are optional.
Using the snippet
Once you've tweaked the snippet, you can paste it into fields you want translated; for example, the title and message body of a campaign.
And that's it! Now you can continue setting up your campaign.
Your next campaign
Let's say you've ran one campaign and now you're ready to run another one.Â
Instead of repeating all of the steps above, you only need to do a few things:
-
Add your new content as additional lines in your source JSON file:
{ "Your source content":"Your source content", "Another source string":"Another source string", "Campaign 2 source string":"Campaign 2 source string" }
-
Update your existing source file in Transifex. You can learn how to do this in this article.
-
​​Update Line 1 of the snippet with the updated source string. Everything else in the snippet can remain the same if you’re using the same project, resource, and target languages as before for the new campaign.
{% assign key = "Campaign 2 source string" %}
From here, you can use the snippet like before.