In this episode, we're adding the language selector UI to our app, letting users pick their preferred language! We start off by figuring out where to place the selector—in this case, right next to the settings dropdown in the authenticated layout, so it pops up everywhere for logged-in users.
We go ahead and build a simple <select>
HTML element, not worrying too much about appearance for now (feel free to style it later). Then, we loop through the available languages and create an option for each one, making sure that the currently active language is selected by default (thanks to the locale that's globally available in the app's config).
Along the way, we update our backend and global tests to make sure that the correct language/locale is being shared with all pages and components. We also show how changing the default locale updates the selected option in the dropdown, so it's always in sync.
By the end, our language selector is fully dynamic and aware of the current selection—setting the stage to actually handle changing the language later on!