[Home]WikiPatches/UILanguageSelection

UseModWiki | WikiPatches | RecentChanges | Preferences

Add something like this to the end of your config script (or where you are loading the language), listing all the languages you wish to support. It will read the Accept-Language header from your browser and use the first translation found in the list (discarding any q-values, so if the entries are not ordered by preference, it might pick the wrong one).

{
  my %languages = (
    'sv' => 'swedish.pl', 
    'no' => 'norwegian.pl',
    'nb' => 'norwegian.pl',
    # Add more languages here
    'en' => 'NONE',
  );
  if (defined $ENV{'HTTP_ACCEPT_LANGUAGE'})
  {
    my $language = '';
    LANGUAGE: foreach $token (split /,/, $ENV{'HTTP_ACCEPT_LANGUAGE'})
    {
      my ($lang, undef) = split /;/, $token, 2;
      if ($lang =~ /^([a-z][a-z])/i)
      {
        my $l = lc($1);
        if (defined $languages{$l})
        {
          $language = $languages{$l};
          last LANGUAGE;
        }
       }
    }
    if ($language ne '')
    {
      do $language unless $language eq 'NONE'; 
    }
  } 
}

Search for CategoryTranslation to find current UseMod translations.


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited October 29, 2007 7:19 pm by MarkusLude (diff)
Search: