Table of Contents


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:

  1. From the left navigation, head to Manage App Group under APP SETTINGS.

  2. Go to the Connected Content tab and click on +Add Credential near the top right corner.

  3. In the popup modal, give your credential a name. We suggest using something simple like Transifex. Then enter either your Transifex username/password or api/API token. Hit Save after you’ve filled in all the information.

    appboy-new-credential.png#asset:4032


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:

  1. Open up a new file in a text editor such as Atom.

  2. 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"
    }

  3. Save the file as a JSON file with the extension .json.

  4. 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>" }
: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 which 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 the URL bar of your browser after you've selected a resource in Transifex. The URL follows this structure:


For example, if your Transifex project is located at https://www.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>" }
: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 translated; for example, the title and message body of a campaign.

Imagen.png#asset:10141

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:

  1. 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"
    }

  2. Update your existing source file in Transifex. You can learn how to do this in this article.

  3. ​​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.

back to top


Continue Reading

Content Management

Design

Development

Help Center

Notifications

Translations

Did this answer your question?