Skip to main content
Configure target locales in your agentic workflow to specify which languages it supports. Use Python APIs in your agentic workflow code to configure these settings. Use the target_locales() method on your agentic workflow to specify which languages it supports:
Python
from ibm_watsonx_orchestrate.flow_builder.flows import Flow, flow, START, END
from ibm_watsonx_orchestrate.flow_builder.types import UserFieldKind

@flow(
    name="multilingual_flow",
    description="A flow with multi-language support"
)
def build_multilingual_flow(aflow: Flow = None) -> Flow:
    # Define user activities
    user_flow = aflow.userflow()
    user_node = user_flow.field(
        direction="input",
        name="user_name",
        display_name="Enter your name",
        kind=UserFieldKind.Text
    )
    
    user_flow.edge(START, user_node)
    user_flow.edge(user_node, END)
    
    # Configure target locales for translation
    aflow.target_locales(["fr", "es", "de", "ja"])
    
    aflow.sequence(START, user_flow, END)
    return aflow

Setting the source locale

By default, the source locale is en (English). Change it using the source_locale() method:
Python
aflow.source_locale("fr")  # Set French as source language
aflow.target_locales(["en", "es", "de"])  # Translate to English, Spanish, German

Enabling or disabling translation

Enable or disable translation support explicitly:
Python
# Enable translation (default is True)
aflow.translation_enabled(True)

# Disable translation
aflow.translation_enabled(False)
When you disable translation, the system ignores the target_locales() configuration and applies no translations.

Complete example

The following example shows a customer feedback form with multi-language support:
Python
from ibm_watsonx_orchestrate.flow_builder.flows import Flow, flow, START, END
from ibm_watsonx_orchestrate.flow_builder.types import UserFieldKind

@flow(
    name="customer_feedback_form",
    description="Collect customer feedback in multiple languages"
)
def build_feedback_flow(aflow: Flow = None) -> Flow:
    # Create user flow with form
    user_flow = aflow.userflow()
    
    feedback_form = user_flow.form(
        name="feedback_form",
        display_name="Customer Feedback",
        instructions="Please share your experience with us",
        submit_button_label="Submit Feedback",
        cancel_button_label="Cancel"
    )
    
    # Add form fields
    feedback_form.text_input_field(
        name="customer_name",
        label="Your Name",
        required=True,
        placeholder_text="Enter your full name",
        help_text="We need your name to follow up on your feedback"
    )
    
    feedback_form.text_input_field(
        name="feedback",
        label="Your Feedback",
        required=True,
        single_line=False,
        placeholder_text="Tell us about your experience",
        help_text="Please provide detailed feedback"
    )
    
    feedback_form.choice_input_field(
        name="rating",
        label="Overall Rating",
        required=True,
        choices=[
            {"label": "Excellent", "value": "5"},
            {"label": "Good", "value": "4"},
            {"label": "Average", "value": "3"},
            {"label": "Poor", "value": "2"},
            {"label": "Very Poor", "value": "1"}
        ]
    )
    
    user_flow.edge(START, feedback_form)
    user_flow.edge(feedback_form, END)
    
    # Configure multi-language support
    aflow.target_locales(["fr", "es", "de", "ja"])
    
    aflow.sequence(START, user_flow, END)
    return aflow

Next steps

After you configure target locales in your agentic workflow code:
  1. Import the agentic workflow into watsonx Orchestrate.
  2. Export translations to a CSV file.
  3. Add translations to the CSV file.
  4. Import translations back into the agentic workflow.
For details on managing translations, see Managing translations.