When building applications, even small details—like letting users save their language preference—can make a big difference in personalization and usability. Recently, I built a simple Proof of Concept (POC) in Power Apps to demonstrate how this can be done with Power Apps’ SaveData()
and LoadData()
functions.
Here’s a step-by-step breakdown of the process and code.
The Problem
In many applications, users need to see content in their preferred language. While Power Apps doesn’t yet support advanced localization features, we can get creative. Using local storage, we can save users’ language preferences on their devices, creating a smooth and tailored experience.
Setting Up the Language Preference Feature
The app consists of a few simple components: a dropdown to select language, labels to show the saved preference, and buttons to save and clear the preference.
Code Walkthrough
1. Load Saved Language on Start
In the App.OnStart
property, we use LoadData
to check if there’s a previously saved language preference. If it exists, it loads into a collection _colLangPreference
:
LoadData(_colLangPreference, "languagePreference");
2. Language Preference Screen
In the screen Scr_LanguagePreference, I included the following elements:
- Display Saved Language: A label (
lblSelectedLanguagePreference
) displays the user’s saved preference, or “None” if no preference exists:
lblSelectedLanguagePreference.Text = "Preference saved in cookie - " & Coalesce(First(_colLangPreference).Value, "None")
- Default Language Label: Another label (lblDefaultLanguagePreference) shows a default language:
lblDefaultLanguagePreference.Text = "Default Language - French"
- Clear Button: Clears the language preference and local storage when clicked:
icnClearLangPref.OnSelect = Clear(_colLangPreference); ClearData("languagePreference"); Notify("Language Preference cleared.", NotificationType.Success);
- Save Button: Saves the selected language preference to local storage:
icnSaveLangPref.OnSelect = ClearCollect(_colLangPreference, ddLanguage.Selected.Value); SaveData(_colLangPreference, "languagePreference"); Notify("Language Preference saved.", NotificationType.Success);
- Language Dropdown: Provides options for language selection:
ddLanguage.Items = ["English", "French", "Spanish", "Hindi"]
The Result
The app now remembers the user’s preferred language selection, so when they return, they don’t need to reset it. This approach enhances usability, provides a tailored experience, and supports offline use.
Conclusion
Adding a personal touch to applications often increases engagement and satisfaction. This POC in Power Apps showcases a simple way to personalize user experience with minimal code. As app developers, we should continuously look for ways to make our applications more intuitive, user-centric, and accessible.
Some other use cases
- User Onboarding Progress Tracking
- Temporary Form Data for Long Forms
- User Preferences for Personalization
- Caching Frequently Used Data for Improved App Performance