Translation Codes
  • 11 Sep 2024
  • 5 minute read
  • Dark
    Light
  • PDF

Translation Codes

  • Dark
    Light
  • PDF

Article summary

Translation codes change a text value to a different text value, either between systems or within Slate. For example, a translation code on a field can translate its value from a short code to a longer code.

Common use cases for translation codes include:

  • Changing a program name to an application deadline

  • Changing a major to a college

  • Grouping or converting GPAs

  • Changing subject lines in mailings

  • Values in scheduled exports (via queries)

  • Discount codes in forms

You can configure up to five export values for each translation code, which can be selected from on the receiving end of the translation. This lets you re-use the same translation code for multiple processes.

Creating a translation code

Translation codes are grouped together under a translation key.

To create a translation key:

  1. From the main navigation, select Database.

  2. Under Automations, select Translation Codes.

  3. Select New Key.

  4. Configure the following settings:

    • Key: Keys are used for describing and grouping Translation Codes together. Each key must be lower case and include no spaces. Translation Codes that share the same key must have the same value type.

    • Type: Determines what type of data the Translation Code expects for input.

      • String: any text string of characters

      • Real Number: numbers that include decimals

      • Integer: whole numbers without decimals

      • Date: a date value

      • DateTime: a timestamp that includes date and time

    • Default Export Value (1-5): Enter up to five values to which should be translated-to in the event that there is no input value. For example, No rating, or Invalid date.

  5. Select Save.

You are redirected to the Translation Codes page for the key you just created.

To create translation codes:

  1. Select New Code.

  2. Configure the following settings:

    • Status: Active

    • Value: The input value

      • String values must match exactly for a translation to occur

      • This option appears only for string value types

    • Minimum/Maximum Value: The minimum/maximum possible input field value

      • Appears for all non-string value types

      • Values are inclusive (treated as ≤ and ≥ operators)

    • Export Values (1-5): The new values to which the input values are translated

  3. Select Save.

Create as many code as is necessary for your process.

Importing translation codes

Import translation codes in batch by adding the Translation Code Import source format to your database from the Source Format Library.

Example: Primary citizenship → Country code

Translation codes can translate the value of query exports.

For example, in a scheduled export query to another system, you may want primary citizenship information (country of origin) to appear as a particular country code.

Save time: upload translation codes in bulk with the Translation Code Import source format.

In a query, create an export. In this example, we select Citizenship (Primary). The Edit Part popup appears.

Configure the following settings:

  • Export Value: Translation Code

  • Translation Key: Select your translation key from the list. In this example, we select country_code.

  • Translation Value: Select the translation export value that fits your situation. If you have more than one translation value, reference your list of translation values for this key in Database > Translation Keys.

  • Null Value: If you didn’t set a default value for the translation key and nothing matches your translation codes, Slate defaults to Null (empty). You can configure a Null value here to provide a default value for just this export.

Select Preview Results to see the translated value:

Example: Date range → Season

You can translate date ranges to season export values.

Example: GPA → Rating

You can use translation codes to assign GPA ranges to your own rating scale.

Minimum and maximum values are inclusive. Say you enter 1.5 as the minimum and 3.49 as the maximum. All values starting at and including 1.5 up to and including 3.49 would qualify for the code that translates to 1 and Needs Improvement.

This example also uses a default export value to capture values that do not fall into the above range.

A default export value also works with the string data type.

Example: Calculations in forms

Translation codes can be used in form fields with calculations.

📝 Make sure you have a field to store the translated value.

Add a form field for the input value

Create a form field to accept the input value from the user. In this example, the user enters their GPA in a text field.

Copy the export key value, in this case sys:school:gpa, as we’ll need it later. Save the field.

Add the Translation element from the form palette

Select the Translation element from the form builder palette.

In the Edit Field popup, configure the following settings:

  • Status: Active

  • Label: Enter a name for internal use

  • Script Key: Enter a unique key to be referenced by a calculated field on the form, which we’ll create next. In this example, we enter rating.

  • Translation: Select the translation code to use. In this example, rating.

  • Translation Export: Select an export value from your possible translations.

Save the element.

Add a hidden field with a calculation to translate the input value

Add another field. Configure the following settings:

  • Label: Tell internal users that this field is a destination for translation

  • System Field: Select the field that represents the value to be translated to. In this case, our Rating field.

  • Calculation Formula: Enter translate("<SCRIPT KEY>",@<EXPORT KEY>), where:

    • <SCRIPT KEY> is the script key from the Translate element. In our case, rating.

    • <EXPORT KEY> is the export key of the input field we created earlier. In our case, sys:school:gpa.

  • Options: Select Hidden / accessible through script

Save the field.

Additional configurations to the calculation formula

  • A form can have multiple Translation elements.

    • If you want to use the same translation code and export value more than once, you can reference the same translation element multiple times.

    • Multiple translation elements must be included in the form when using different export values for a single translation code. For example, Export Value 1 for one translation and Export Value 2 for another.

  • If a string value is being translated, append _text to the export key in the calculation formula, as in translate("<SCRIPT KEY>", @<EXPORT_KEY>_text)

  • For translating form fields with the export key, such as reader_rating, the calculation formula should contain that key, as in: translate("rating_number", @reader_rating).

  • Translation codes can also be included in math calculations, like this example: 5 * (translate("rating_number", @reader_rating) + @extra_rating)

Test the form

Make a test submission on the form. Then, make a Quick Query for the target export on the test record to see whether the value has indeed been translated.


Was this article helpful?