1. How would you go about displaying French text?
You must create a new .properties
file. This file will be named application_fr.properties
. You can have access to the values in this file after a reload. Try this out, adjust the language settings of your browser and call the pages again.
2. How would you use text that spans multiple lines?
The properties files are built on a name-value schema. You cannot use a line break here directly. You can insert \n
, but it won’t be displayed in HTML. Instead of this, you can use HTML elements, for example,<br>
. But pay attention that you stay with HTML; it will become complex if you use XHTML. We will come across this in later chapters.
5. It was indicated in the chapter that English is the default language; is this correct? Swap the file names over: change
application.properties to application_de.properties
and vice versa. What happens now if you try to access the page using a preferred language that isn't supported?
application.properties
to
application_de.properties
Whichever language you set in the application.properties
file becomes the default language. This can be done using the file without a language extension (that is, without a language code in the name, like application_de.properties
). It will be used if no other suitable file is found, for example, for a Spanish visitor.