Switching languages

In the past two recipes, we have changed a standard application so that it can be translated and we performed the translation itself. In this recipe, we will add something that will make switching between languages much easier for users.

Getting ready

To start this recipe, we will need an application that has been translated like the application we created in the past two recipes.

How to do it...

The best place to create a language switch is a place that is visible at all times. In this case, we will use the navigation bar. Since this bar is in the header of our application, it is visible on all pages; ideal for our purposes.

  1. Navigate to the Shared Components.
  2. In the Navigation Section find the Navigation Bar Entries and click it.
  3. There should already be an entry called Logout in place.
  4. Click the Create button.
  5. Confirm that the option From Scratch is selected and click Next.
  6. Select Navigation to URL and click Next.
  7. Enter English as the Entry Label and click Next.
  8. In the next page, enter the following for the properties:
    • Target is a: Page in this application
    • Page: &APP_PAGE_ID. (do not forget the dot at the end)
    • Request: LANG
    • Set these items: FSP_LANGUAGE_PREFERENCE
    • With these values: en
    How to do it...
  9. Click Next.
  10. Click Create.

We have now created a link in the navigation bar that will direct users to the English part of the application. To create a link to the Dutch version of the application, repeat these steps but change the Entry Label to 'Nederlands' and set With these values to nl instead of en.

Remember to run the XLIFF translation steps again to make sure the new text is available in both languages.

When we now run the application, we can see that two entries are available in the navigation bar.

How to do it...

Clicking on Nederlands will show the application in Dutch and clicking on English will change it back to the English language.

How to do it...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.129.90