Ask AI
Skip to main content

Route to language page

Function: Route to language page

Redirect a user to the same page with a different language in your application. This action is useful when you want to allow users to switch the language of the content they are viewing without navigating to an entirely different section of your application.

Input

  • Language (STRING): The specific language code (e.g., "en" for English, "fr" for French, "es" for Spanish) you want to switch the current page to. This is the primary language the action will try to find.
  • Default Language (STRING): An optional fallback language code. If the platform cannot find a version of the current page for the specified "Language", it will try to redirect to this default language instead. If this is also not found, an error will be displayed.

Output

This action does not produce a direct output value that can be stored in a variable. Its primary function is to perform a redirect, changing the page the user is currently viewing.

Execution Flow

Real-Life Examples

Example 1: Switching to a specific language

A user is viewing a product page in English and clicks a "View in French" button.

  • Inputs:
    • Language: "fr"
    • Default Language: (empty)
  • Result: The application finds the French version of the current product page and redirects the user to it, displaying all content in French.

Example 2: Falling back to a default language

A user's browser is set to German, and your application attempts to load a page in German. However, your application only has English and Spanish translations for that page.

  • Inputs:
    • Language: "de"
    • Default Language: "en"
  • Result: The application first tries to find the German version of the page. Since it doesn't exist, it falls back to the "Default Language" ("en"). The user is then redirected to the English version of the page.

Example 3: Language not found with no fallback

A user tries to switch to a language that is not supported by your application, and no default fallback language has been configured.

  • Inputs:
    • Language: "jp"
    • Default Language: (empty)
  • Result: The application attempts to find the Japanese version of the page. As it doesn't exist and no default language is provided, an error message is displayed to the user (e.g., "Page not available in Japanese"), and the user remains on the current page in its original language.