Transifex

  • Documentation
  • Integrations
  • Appboy

Appboy

Through Transifex’s integration with Appboy, you can pull translations from Transifex into Appboy directly and launch multilingual engagement campaigns.

Setting up a project in Transifex

Before you can start translating, you'll first need a project in Transifex for storing your Appboy content and translations. To create a project, head to your Transifex Dashboard and click Create new project. Then follow the steps on the page to create your project.

When creating the project, be sure to:

  1. Choose File-based Project when picking a project type.
  2. Select source and target languages that are supported by Appboy (ISO 639-1 two letter codes).

Connecting your Transifex account to Appboy

You’ll need to connect your Transifex account to Appboy in order to be able to pull translations back into Appboy. 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 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 Appboy 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 Appboy

Once your translations are complete, you can pull them back into Appboy 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 appboy
  • 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 Appboy 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 will follow this structure:

https://www.transifex.com/<organization_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 = "appboy" %}
{% 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.

appboy-message-field.png#asset:4062

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.

CONTINUE READING