Gallery2:Language Settings - Gallery Codex
Personal tools

Gallery2:Language Settings

From Gallery Codex

Language Settings in Gallery 2

The preferred language can be set per session, per user, as a site default and you can change it also with a override with a request parameter.

NOTE: This article describes the behavior in Gallery 2.1. Gallery 2.0/2.0.1/2.0.2 have a slightly different behavior (e.g. set the default language to None if you want the browser language preference check in Gallery 2.0).

Priority - Which setting is valid when?

This should be the priority, meaning that 1. will override 2-6 and 4 will override 5, 6 if 1-3 is not set, etc.

  1. g2_language=languageCode in request string
  2. activeLanguage from embedding application (only applicable to Embedded G2)
  3. Active language of the current session
  4. Preferred language of the current user
  5. (Optional) Preferred language specified by the browser of the user
  6. Site wide default language for G2

Usually, you don't use g2_language overrides in URLs. And new visitors of your website don't have an active language yet and they they are not logged in as user yet. Thus, Gallery 2 will default to the preferred language specified in site admin.

If you enable the browser language preference check in site admin, it will use the language specified by the browser of the visitors. And if the language preference specified by the browser is not available in your Gallery installation, it will default to Gallery default language (the one defined in site admin).

What does "Preferred Language" mean?

If the Gallery 2 translation for a specific language is 100% complete (that is, if all strings in Gallery 2 have been translated in this language), the complete Gallery 2 experience will be translated into this language if this language is chosen.

If a translation is not 100% complete, all non-translated strings can't be translated and you will see a mix of English and your preferred language.

Overview over the 6 Language Settings

Site wide default language for G2

You can set the site wide default language for G2 in site admin -> General. See Requirements. It will be used for all users, unless you enable the browser language preference check. If so, it will use this default as fallback if the browser preference is not available.

This default can always be overriden in the user preferences of each user and also with the language selector block if you choose to show the block.

Preferred language of the current user

Each user can set the preferred language in Your settings. This overrides the site wide default language.

Active language of the current session

After visiting the first page of your G2, G2 stores some data for this visitor, to keep track of the user's preferences etc. It also stores the preferred language for this user.

All users, including anonymous visitors (guests) can choose their preferred language in G2 if you add the language selector block to the sidebar. You can dot that in site admin -> Themes -> Matrix (or whatever your active theme name is).

The active language of the current session overrides a user's preferred language and the site wide default language.

Preferred language specified by the browser

Browsers like Internet Explorer, Firefox, Opera, and pretty much every other browser give the webserver a hint what language the user might expect. Usually, if you use MS Windows in your language rather than in English, then Internet Explorer will also include the language code for your language in all requests to Gallery 2. Similarely, if you downloaded Firefox for your language, then it will tell Gallery 2 that you expect websites in this language. If you're using Firefox in English but would rather prefer another language, you can change this in the Firefox options.

If the browser language preference check is enabled in site admin, Gallery 2 will detect this preferred language as specified by the browser (the HTTP_ACCEPT_LANGUAGE header). If any language listed in HTTP_ACCEPT_LANGUAGE is available in Gallery 2, it will use it. Else, it will fall back to the Gallery 2 default language.

activeLanguage from GalleryEmbed::init() (Embedded G2)

If Gallery 2 is embedded in another application through the GalleryEmbed API, then the embedding application can specify the active language for the current user/session in the call to G2. This language setting will set the session language in G2.

g2_language=languageCode in request string

If you want to add links to your G2 that already default to different languages, you can add the g2_language=languageCode parameter to the link. E.g. on your entry page, you could have a French flag linking to your Gallery 2 with main.php?g2_language=fr and a British/American flag which uses the link main.php?g2_language=en .

This will override any other language preference.

Requirements

  • Your PHP needs to have gettext support built-in and loaded.
  • Your system/server must have the locales (=~ translations into your languages) installed. See: FAQ: I changed the language but nothing happens, what's wrong?
  • You do not need the multilang module. The multilanguage module can be used to translate the content, your album and image titles, descriptions etc. The built-in G2 translation translates the menus, the user interface, the welcome / confirmation emails, but G2 can't translate the titles that you entered without the multilanguage module.

TODO

  • Downloadable Language Packs / Define in Site admin which languages should be available to the users