sub get_translation_dir { my $lang = shift; # have we encountered this before? return $vars{"translation_dir_$lang"} if $vars{"translation_dir_$lang"}; # I think languages are sent as semicolon-seperated values, e.g. # en;en-US for someone who only speaks English ... or # fr;fr-FR;en-FR;en for someone who prefers French, but will accept English. # modify if that's wrong. my @choices = split /;/, $lang; for (@choices) { # have we seen this one before? return $vars{"translation_dir_$lang"} = $vars{"translation_dir_$_"} if $vars{"translation_dir_$_"}; # no? Do we have such a translation? if ( -d "$vars{root_dir}/$_" ) { # save it to the cache, and return. return $vars{"translation_dir_$lang"} = $vars{"translation_dir_$_"} = "$vars{root_dir}/$_"; } } # if we get this far, try no language. return get_translation_dir(''); }