Sometimes, applications or websites we build need to support multiple languages. Lift supports this requirement by allowing us to localize templates, and offers a powerful yet simple way to choose which template to use when rendering the page.
In this recipe, we'll learn how to localize templates and texts that will be loaded dynamically for our applications or websites.
Create a new project and the following three bundle files in the
src/main/resources/i18n
folder:The
resources.properties
fileThe
resources_de.properties
fileThe
resources_fr_FR.properties
file
The
resources.properties
file will have the following content:menu.home=Home menu.static=Static dynamic.text=Some dynamic text welcome.text= Welcome to your project!
While the file
resources_de.properties
will have the content shown in the following code:menu.home=Zuhause menu.static=Statisch dynamic.text=einige dynamischen Text welcome.text= Willkommen in Ihrem Projekt!
And the file
resources_fr_FR.properties...