Provide a language switcher

You can provide API Portal in multiple languages, and enable your API consumers from different countries to change languages using a language switcher.

To enable a language switcher, you need to have a main menu for each language you are providing (including one for English), and an additional main menu for all languages. Similarly, you need to have template styles for each language (including one for English), and an additional template style for all languages. The process is as follows:

  1. Install new languages
  2. Create main menus
  3. Create page template styles
  4. Enable the language switcher

Install new languages

To install new languages, follow these steps:

  1. Log in to Joomla! Admin Interface (JAI).
  2. In the JAI top navigation bar, click Extensions > Language(s).
  3. Install language
  4. Click Install Languages.
  5. Find and select the language to install, and click Install.
  1. In the JAI left navigation bar, click Language(s) > Content Languages.
  2. Set the Status of the new language to Published.

Create main menus

To enable a language switcher, you need to have a main menu for each language you are providing (including one for English), and an additional main menu for all languages. The process is as follows:

  1. Create a main menu for all languages
  2. Change the language of the original main menu to English
  3. Create a main menu for the new language
  4. Rename the original main menu

After following this process you will have the following main menus:

  • Main menu - All
  • Main menu - FR
  • Main menu - EN

Create a main menu for all languages

First, create a main menu that will be the default main menu for all languages. This main menu will have only one menu item.

  1. In the JAI top navigation bar, click Menus > Manage > Add New Menu.
  2. In Title, enter the title to be shown in drop-down lists (for example, Main menu - All).
  3. On the Menu Details tab, in Menu Type, enter a system identifier for the new main menu (for example, mainmenuall).
  4. Click Save & Close.
  5. To add a menu item to this main menu, click Menus > Main menu - All > Add New Menu Item.
  6. Add menu item for Main menu -All
  7. Click Save & Close.

Change the language of the original main menu to English

Next, change the language of the original main menu items from All to English:

  1. In the JAI top navigation bar, click Menus and select Main Menu.
  2. To change the language of all the menu items at once, click the Check All Items check box and click Batch.
  3. In Set Language, select English.
  4. Click Process.
  5. In the JAI top navigation bar, click Menus and select Main Menu.
  6. To set the default home page, click the star in the row for the Home menu item.

Create a main menu for the new language

Next, create a main menu for each new language and clone the menu items from the main menu. Follow these steps:

  1. In the JAI top navigation bar, click Menus > Manage > Add New Menu.
  2. In Title, enter the title to be shown in drop-down lists (for example, Main menu - FR).
  3. On the Menu Details tab, in Menu Type, enter a system identifier for the new main menu (for example, mainmenufr).
  4. Click Save & Close.
  5. In the JAI top navigation bar, click Menus and select Main Menu.
  6. To clone all the menu items at once, click the Check All Items check box and click Batch.
  7. In Set Language, select the correct content language (for example, French (FR)).
  8. In To Move or Copy, locate the correct main menu for the language and select Add to this menu.
  9. Select Copy to make a copy of the menu items.
  10. Click Process.
  11. In the JAI top navigation bar, click Menus and select the main menu you cloned the menu items to (for example, Main menu - FR).
  12. To set the default home page, click the star in the row for the Home menu item.

Rename the original main menu

Next, rename the original main menu:

  1. In the JAI top navigation bar, click Menus > Manage.
  2. Select the row for the main menu and click Edit.
  3. Change the Title to Main menu - EN.
  4. Click Save & Close.

Create page template styles

To enable a language switcher, you need to have template styles for each language you are providing (including one for English), and an additional template style for all languages. The process is as follows:

  1. Duplicate the template style for the new language
  2. Duplicate the template style for all languages
  3. Update the original template style for English

By default, API Portal uses the Purity III template style. After following this process you will have the following template styles:

  • purity_III - Default - English
  • purity_III - Default - French
  • purity_III - Default - All

Duplicate the template style for the new language

  1. In the JAI left navigation bar, click Templates > Styles.
  2. Joomla Templates Styles
  3. Click your template style (for example, purity_III - Default) to open it.
  4. Click the arrow next to the Save button at the top left of the window, and select Save as Copy.
  5. Edit the Style Name to indicate the language (for example, purity_III - Default - French).
  6. Select the respective language as the Default. This sets this template as the default for pages using the selected language.
  7. Click the Navigation tab, and change the Menu to the correct main menu for the language.
  8. Click the Assignment tab, and assign the menu items from the correct language to the template. To select or deselect all menu items, click the toggle button next to the main menu title.
  9. Click Save and click Close to close the template style.

Duplicate the template style for all languages

Next, repeat steps 2 to 8 of Duplicate the template style for the new language to duplicate the template style for all languages (for example , purity_III - Default - All).

Update the original template style for English

Next, edit the original template style for the English language:

  1. Click your template style (for example, purity_III - Default) to open it.
  2. Edit the Style Name to indicate the English language (for example, purity_III - Default - English).
  3. Select English as the Default. This sets this template as the default for pages using the English language.
  4. Click the Navigation tab, and change the Menu to Main menu - EN.
  5. Click the Assignment tab, and assign the menu items from the English language to the template. To select or deselect all menu items, click the toggle button next to the main menu title.
  6. Click Save and click Close to close the template style.

Enable the language switcher

To enable the language switcher, complete the following steps:

  1. In the JAI top navigation bar, click Extensions > Modules and click New.
  2. Click Language Switcher.
  3. Enter a Title and for Position select Purity iii > Footer 1.
  4. Click Save & Close.
  5. In the JAI top navigation bar, click Extensions > Plugins, and ensure the System - Language Filter plugin is enabled.
  6. Click the System - Language Filter plugin to open it.
  7. Set Automatic Language Change to No.
  8. Click Save & Close.

The language switcher is now available on the footer of each API Portal page. For example:

Language switcher on footer

Related Links