Through Transifex’s integration with Braze, 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 to pull translations back into Braze. To do this:
From the left navigation, head to Manage Settings under SETTINGS.
Go to the Connected Content tab and click +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 now, the integration does not support pushing 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!
Getting translations into Braze
This example code snippet utilizes the Transifex resource translation API and the user’s language
attribute. Based on your needs, you can then loop through the string objects and pull in the relevant content using the following Liquid:
{% assign organization = "<organization_name>" %}
{% assign project = "<project_name>" %}
{% assign resource = "<resource_name>" %}
{% assign source_string = "string" %}
{% assign source_hash = source_string | md5 %}
{% assign language = "<langua>" %}
{% if {{${language}}} == "en" or {{${language}}} == "it" or {{${language}}} == "de" or {{${language}}} == "another_language_you_support" %}
{% connected_content
https://rest.api.transifex.com/resource_translations/o:{{organization}}:p:{{project}}:r:{{resource}}:s:{{source_hash}}:l:{{language}}
:method GET
:headers {
"Authorization": "Bearer <transifex_bearer_token>",
"Integration": "Braze"
}
:accept application/vnd.api+json
:save strings
%}
{% endif %}
{% if {{strings}} != null and {{strings.data[0].attributes.strings.other}} != "" and {{${language}}} != null %}
{{strings.data[0].attributes.strings.other}}
{% 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 that says
Your source content
A Transifex organization with the slug my_org
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
Your project and resource slugs can be found in your browser's URL bar after selecting a resource in Transifex. The URL follows this structure:
For example, if your Transifex project is located at https://app.transifex.com/my_org/braze/pushnotification/
, the project_name
will be “braze” and the resource_name
will be “pushnotification”.
Then your tweaked snippet would look like this:
{% assign organization = "my_org" %}
{% assign project = "braze" %}
{% assign resource = "pushnotification" %}
{% assign source_string = "string" %}
{% assign source_hash = source_string | md5 %}
{% assign language = "de" %}
{% if {{${language}}} == "en" or {{${language}}} == "it" or {{${language}}} == "es" or {{${language}}} == "another_language_you_support" %}
{% connected_content
https://rest.api.transifex.com/resource_translations/o:{{organization}}:p:{{project}}:r:{{resource}}:s:{{source_hash}}:l:{{language}}
:method GET
:headers {
"Authorization": "Bearer <transifex_bearer_token>",
"Integration": "Braze"
}
:accept application/vnd.api+json
:save strings
%}
{% endif %}
{% if {{strings}} != null and {{strings.data[0].attributes.strings.other}} != "" and {{${language}}} != null %}
{{strings.data[0].attributes.strings.other}}
{% else %}
{% abort_message('null or blank') %}
{% endif %}
Using the snippet
Once you've tweaked the snippet, you can paste it into fields you want to be translated, such as the campaign title and message body.
{% assign organization = "my_org" %}
{% assign project = "braze" %}
{% assign resource = "pushnotification" %}
{% assign source_string = "string" %}
{% assign source_hash = source_string | md5 %}
{% assign language = "de" %}
{% if {{${language}}} == "en" or {{${language}}} == "it" or {{${language}}} == "es" or {{${language}}} == "another_language_you_support" %}
{% connected_content
https://rest.api.transifex.com/resource_translations/o:{{organization}}:p:{{project}}:r:{{resource}}:s:{{source_hash}}:l:{{language}}
:method GET
:headers {
"Authorization": "Bearer <transifex_bearer_token>",
"Integration": "Braze"
}
:accept application/vnd.api+json
:save strings
%}
And that's it! Now, you can continue setting up your campaign.
Your next campaign
Let's say you've run one campaign and are ready to run another. 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 use the same project, resource, and target languages as before for the new campaign.
{% assign key = "Campaign 2 source string" %}
From here, you'll be able to use the snippet like before.
💡Tip
Looking for more help? Get support from our Transifex Community Forum!
Find answers or post to get help from Transifex Support and our Community.