Difference between #10 and #11 of
How to add a DropDown Language Picker (i18n) to the Menu

Revision #11 has been created by JQL on Dec 5, 2023, 6:26:27 PM with the memo:

Added the Github repository
« previous (#10) next (#12) »

Changes

Title changed

How to add a DropDown Language Picker (i18n) to the Menu

Category unchanged

How-tos

Yii version unchanged

2.0

Tags unchanged

i18n,AJAX,bootstrap,internationalization,bootstrap menu

Content changed

# How To Add Internationalisation to the NavBar Menu in Yii2 Yii comes with internationalisation (i18n) "out of the box". There are instructions in the manual as to how to configure Yii to use i18n, but little information all in one place on how to fully integrate it into the bootstrap menu. This document attempts to remedy that. The Github repository also contains the language flags, some country flags, a list of languages codes and their language names and a list of the languages Yii recognises "out of the box". A video will be posted on YouTube soon.
 
 
[i18ntutorial on Github](https://github.com/JQL/i18ntutorial)
 
 
---
 
 
Ensure that your system is set up to use i18n. From the Yii2 Manual:

> Yii uses the `PHP intl` extension to provide most of its I18N features, such as the date and number formatting of the `yii\i18n\Formatter` class and the message formatting using `yii\i18n\MessageFormatter`. Both classes provide a fallback mechanism when the intl extension is not installed. However, the fallback implementation only works well for English target language. So it is highly recommended that you install `intl` when I18N is needed.
[...]
The images should be 25px wide by 15px high. The images **must have** the same name as the language key in the language array in params.php. For example: `fr.png` or `en-US.png`. If the images are not of type ".png" change the code in part **b.** below to the correct file extension.

Place the images in a the directory `/
public_htmlweb/images/flags/`.

**b.** Alter the code in `/views/layouts/main.php` so that the code for the "NavBar" reads as follows:

```php
<header id="header">
[...]
1 0
1 follower
Viewed: 70 345 times
Version: 2.0
Category: How-tos
Written by: JQL
Last updated by: JQL
Created on: Nov 24, 2023
Last updated: 11 months ago
Update Article

Revisions

View all history