Language switching and choice persistence

Opublikowane
2008-06-10 07:12
Written by
shot - member of the CiviCRM community - view blog guidelines

As the Summer of Code coding phase got rolling, I started looking at the tasks I listed in my original description of the project.

The first task on the list was to make language switching in CiviCRM available to the users. This was introduced a list of links on the user’s dashboard. As CiviCRM currently has (granted – more or less advanced…) 32 localisations, it was essential that this list can be managed by the administrator of the site; this is now a part of the Administer CiviCRM → Global Settings → Localization admin screen.

The second task was to make the language selection permanent for a given user. Initially, I chose to use session variable to hold this information; unfortunately, this didn’t work so well, as the language got reset to the installation’s default on every logout.

As every CiviCRM user is also a contact in the given installation’s databse, the ideal solution would be to have the language selection be a setting associated with the contact; unfortunately, per-contact settings are not yet implemented in CiviCRM. Once they’re implemented, the language chosen by the user will be stored there; for now, a simple hack was implemented to store the preference as a year-long-valid cookie in the user’s browser.