Permanently storing your language setting

In the last chapter, we added a language switcher to our tutorial application, allowing you to switch to the desired language. While that’s great, any reasonable program will store your language setting so that you have to select the language only once at the very first use of the program. In the next lesson, we will implement this behavior for our application, too. Once we are finished, our browser application will store your language setting in its local storage and will recall these setting on each startup.


Source code
If you didn’t author or didn’t keep the Language switcher project explained in the previous chapter, you may download the sources of this project and use this a starting base to follow the instructions given below.

Preparing data storage on the device

  • From the gallery templates window (Alt+1) with folder Chora opened (key C), drag an instance of the annotation group icon Annotation Group to the component’s canvas. Place the element on the canvas and rename the property Caption of the element to Device interface using the inspector window. Resize the note group so that it will cover the two existing elements on the canvas. Move the two elements DeviceClass and Device down so that they don’t hide the caption any more.

  • Drag another instance of the annotation group icon Annotation Group to the component’s canvas. Place the element underneath the previously inserted note group and rename the property Caption of the newly inserted element to Enumerations using the inspector window.

  • From the gallery templates window to the left (Alt+1), drag the element enum icon Enum inside the Chora folder over to the canvas and place it inside the recently inserted note group Enumerations. Rename the enumeration to Language.

  • Double click on the newly inserted enumeration:icons/EnumIcon.png[enum icon]. Inside the composer window, a new tab Device::Language appears which shows the three items of the enumeration.


Source code
If you encountered difficulties and didn’t succeed when following the instructions given above, you may download the project sources of the finalized example on how to permanently store the language settings on your device.