#####################################
# This is a language translation file
# T|-|Is iS 4 laNgUaGE tRAnsLAti()N F3y3lE
#
# This is a good example of using a subroutine to handle translations.
#
# Program:                   album
# Created:                   Thu Dec  7 04:36:18 2006
# Language code:             l33t
# Language:                  l33t h4xor!!!
# Charset:                   iso-8859-1
# Language: (English)        Leet Hacker
#####################################

sub language_info {
	return {
		language_code => 'l33t',
		language => 'l33t h4xor!!!',
		language_english => 'Leet Hacker',
		album_version	=> "4.00",
		language_version => 1,
		charset => "iso-8859-1",
		translators => [		# List of:  ["name","email/url"],
			[ "David Ljung Madison", "http://GetDave.com/" ],
			# Anthony Mitchell wrote a story which listed most l33t-speak
			[ "Thanks: A.M.", "http://www.ecommercetimes.com/story/47607.html" ],
			[ "Thanks: Brendan Gregg", "http://brendangregg.com/index.html" ],
		],
	};
}

# First option listed is preferred, but '****' means no preferred translation
my %conv = (
		a	=> [qw( 4       /\\ @ /-\\ ^ ä ª aye )],
		b => [qw( 8       6 |3 ß P> |: )],
		c => [qw( \(      [ ¢ < )],
		d => [qw( |\)     o| [\) I> |> þ )],
		e => [qw( ****    3 & £ ë [-  ê |=- )],
		f => [qw( ****    |= ph |\# )],
		g => [qw( ****    6 & \(_+ 9 C- gee \(, )],
		h => [qw( |-|     \# /-/ [-] {=} <~> ]~[ }{ ]-[ ? }-{ )],
		i => [qw( 1       ! | & eye 3y3 ï ][ ¡ )],
		j => [qw( ****    ,| _| ; _\) )],
		k => [qw( |<      X |{ ]{ }< |\( )],
		l => [qw( 7       1 1_ | |_ \# l )],
		m => [qw( /\\/\   nn //. ^^ |v| [V] {V} |\\/| \(u\) []V[] \(V\) )],
		n => [qw( |\\|    // ^/ /\\/ [\\]  <\\> {\\} []\\[] n /V  )],
		o => [qw( \(\)    0 ?p  * ö )],
		p => [qw( ****    ph |^ |* |o |^\(o\) |> |" 9 []D |? |7 )],
		q => [qw( ****    9 \(,\) <| ^\(o\)| ¶ O_ )],
		r => [qw( ****    ® |2 P\\ |? |^ lz [z 12 |2  )],
		s => [qw( ****    5 $ z § ehs )],
		t => [qw( +       7 -|- 1 '][' )],
		u => [qw( ****    \(_\) |_| µ v ü )],
		v => [qw( ****    \\/ )],
		w => [qw( ****    \\/\\/ vv '// \\^/ \(n\) \\V/ \\// \\X/ )],
		x => [qw( ><      × + ecks \)\(  )],
		y => [qw( ****    Y '/ `/ V/ \\-/ j ¥ % )],
		z => [qw( ****    2 z ~\\_ ~/_ )],
	);

# 66% chance of conversion
my %word = (
	root => 'w00t',
	the => 	'teh',
	from =>	'frm',
	at =>	'@',
	);

# Do a conversion
# Make sure to *not* convert things like [_1]
sub l33t {
	my ($opt, $line) = @_;

	# Word replacements
	foreach my $word ( keys %word ) {
		$line =~ s/\b$word\b/int(rand(3))==0?$word:$word{$word}/ieg;
	}

	# Some multi-char replacements
	$line =~ s/ct/int(rand(2))?"k":"ct"/ieg;
	$line =~ s/ck/int(rand(2))?"x":"ck"/ieg;
	# beginning of word "f" -> "ph"
	$line =~ s/\bf/int(rand(2))?"ph":"f"/eg;
	# End of word 'ed' -> 'd'
	$line =~ s/ed\b/int(rand(2))?"ed":"d"/eg;
	# 'and' sound -> &
	$line =~ s/(and|anned|ant)/int(rand(3))?'&':$1/eg;

	my @line = split(//,$line);
	for (my $i=0; $i<=$#line; $i++) {
		# Uppercase sometimes
		$line[$i] = uc($line[$i]) if !int(rand(2));

		my $ch = lc($line[$i]);
		if ($conv{$ch}) {
			my @alts = @{$conv{$ch}};
			my $choose = int(rand(2)) ? 0 : int(rand($#alts+1));
			my $new = $alts[$choose];
			$new =~ s/(\[|\])/~$1/g;	# [ and ] have to be ~[ and ~]
			$line[$i] = $new unless int(rand(3)) || $new eq '****';
		}
	}

	# Exclamation points
	if (int(rand(3))==0 && $line =~ /\S/) {
		push(@line, '!'x (2+int(rand(5))));
		push(@line, '1'x int(rand(3)));
	}

	# Woot!
	push(@line," w00t!!") if int(rand(14))==0;

	join('',@line);
}

# Translations go here
sub language {
	return {
		'_' => \&l33t,	# Catch-all for all translations
	};
}

# Language file must return:
1;
