How to Translate a Private Application with Weglot

In this article, you will learn how to use Weglot for a private web application (like a SaaS), allowing the language to be saved as a user preference instead of using a language-specific URL.


How It works

In most cases, Weglot serves translated pages via different URLs using subdirectories. For example:

  • Original page: https://www.example.com/about
  • French version: https://www.example.com/fr/about

However, for SaaS applications and other private tools, you may prefer to switch languages based on user preferences—without changing the URL.

Popular applications like Notion, Stripe, Facebook, and X (formerly Twitter) use this method, storing language preferences in user profiles.

Stripe user profile page : selecting a language

This guide will show you how to configure Weglot to work similarly.

Prerequisites

To achieve this, you'll need to store the language preferences for each user on your side.

Follow these steps:

  1. Add a language preference to user profiles:

    Create a new property (such as a database column) in your user table to save the selected language.

  2. Implement a language switcher:

    Add a language dropdown on your user/profile page, or anywhere appropriate for users to select their preferred language.

  3. Set the response header:

    After the user selects a language, add the language code (a 2-letter code) to all HTTP response header. The header you need to add is: Weglot-Language-Preference

Here’s an example of what this header should look like in Chrome Developer Tools (Network tab):


Installation

Once your web application includes the Weglot-Language-Preference header, you can proceed with the Weglot installation.

  1. Follow standard Weglot subdirectory integration:

    Install Weglot as you would for any other site, using "Subdirectory" integration

  2. Verify language subdirectories:

    After installation, check that your translations appear on subdirectories URLs (e.g., /fr/ for French).

  3. Contact support:
    • Reach out to our support team at support@weglot.com to activate the mode for Private Application
    • Once activated, Weglot will use the Weglot-Language-Preference header instead of relying on the URL for language detection.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us