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:
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
See all 25 lines
Setting the source locale
By default, the source locale is en (English). Change it using the source_locale() method:
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:
# Enable translation (default is True)
aflow.translation_enabled( True )
# Disable translation
aflow.translation_enabled( False )
See all 5 lines
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:
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
See all 58 lines
Next steps
After you configure target locales in your agentic workflow code:
Import the agentic workflow into watsonx Orchestrate.
Export translations to a CSV file.
Add translations to the CSV file.
Import translations back into the agentic workflow.
For details on managing translations, see Managing translations .