web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Add icon to Change lan...
Power Pages
Answered

Add icon to Change language of power portals from English to arabic

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello, I want to add icon to change language of power portals application when icon click on home page for specific login user instead of changing language from user profile form in power portals

Categories:
I have the same question (0)
  • Verified answer
    gcmfaizan Profile Picture
    1,022 on at

    Hi @Anonymous ,

     

    It sounds like you want to implement a feature in your Power Portals application that allows a specific logged-in user to change the language by clicking an icon on the home page, rather than going through the user profile form. This involves customizing the user experience in Power Portals. Here's a general approach you can follow:

    • Set up a custom entity in Power Apps portal to store language configurations (code and display name).
    • Edit the home page to add a language icon or button using HTML or Liquid templating.
    • Use JavaScript or Liquid templating to fetch the logged-in user's language preferences.
    • When the icon is clicked, show a dropdown or list of language options from the Language Configuration Entity.
    • Handle language changes by updating the user's language preference in the backend or custom entity.
    • Use Liquid templating or JavaScript to dynamically adjust the content on the home page based on the selected language.
    • Store the user's language preference for persistence across sessions using methods like cookies, browser local storage, or backend storage.

    I can provide you with a basic outline of the code you might use for this scenario.

    Add Language Icon to Home Page:

    <!-- Add this HTML code to your home page template -->
    <div id="language-selector">
     <button id="language-icon">🌐</button>
     <ul id="language-options" style="display: none;">
     <!-- Dynamically populate language options using Liquid or JavaScript -->
     <li><a href="#" data-language="en">English</a></li>
     <li><a href="#" data-language="fr">Français</a></li>
     <!-- Add more language options as needed -->
     </ul>
    </div>

    JavaScript Logic:

    // Add this JavaScript code to handle language selection
    document.addEventListener("DOMContentLoaded", function() {
     const languageIcon = document.getElementById("language-icon");
     const languageOptions = document.getElementById("language-options");
    
     languageIcon.addEventListener("click", function() {
     languageOptions.style.display = "block";
     });
    
     languageOptions.addEventListener("click", function(event) {
     const selectedLanguage = event.target.getAttribute("data-language");
     // Call a function to change user's language preference
     updateUserLanguage(selectedLanguage);
     languageOptions.style.display = "none";
     });
    });
    
    function updateUserLanguage(languageCode) {
     // Use Power Portals API or custom backend logic to update user's language preference
     // You'll need to pass the user's ID or unique identifier along with the new language code
    }

    Liquid Templating for Dynamic Content:

    <!-- Use Liquid templating to display content based on selected language -->
    <div>
     {% if user.language == 'en' %}
     <p>Welcome to our website!</p>
     {% elsif user.language == 'fr' %}
     <p>Bienvenue sur notre site web !</p>
     {% endif %}
    </div>

     

    I hope it helps you. Please mark my post as solution to help others. And give a thumbs up.

    Thanks,

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
sannavajjala87 Profile Picture

sannavajjala87 38 Super User 2026 Season 1

#2
Valantis Profile Picture

Valantis 24

#3
Haque Profile Picture

Haque 16

Last 30 days Overall leaderboard