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).
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.
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).
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.
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.
Each user can set the preferred language in Your settings. This overrides the site wide default language.
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.
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.
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.
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.