[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [699] branches/1.2



Revision: 699
          http://svn.sourceforge.net/ledger-smb/?rev=699&view=rev
Author:   tetragon
Date:     2006-11-27 17:21:21 -0800 (Mon, 27 Nov 2006)

Log Message:
-----------
Updating Danish locale with Num2text rules from Mads Kiilerich

Modified Paths:
--------------
    branches/1.2/LedgerSMB/Num2text.pm
    branches/1.2/locale/po/da.po

Modified: branches/1.2/LedgerSMB/Num2text.pm
===================================================================
--- branches/1.2/LedgerSMB/Num2text.pm	2006-11-28 01:19:22 UTC (rev 698)
+++ branches/1.2/LedgerSMB/Num2text.pm	2006-11-28 01:21:21 UTC (rev 699)
@@ -31,6 +31,14 @@
 #
 #=====================================================================
 
+# The conversion routines can be tested with for example:
+# perl <<EOF
+#   use LedgerSMB::CP; 
+#   my $c = CP->new('da'); 
+#   $c->init; 
+#   for(0 .. 202, 999 .. 1002, 1999 .. 2002, 999999 .. 1000002, 999999999 .. 1000000002) 
+#     {print $_.":".$c->num2text($_)."\n";};'
+# EOF
 
 sub init {
 	my $self = shift;
@@ -38,7 +46,7 @@
 	my $langtag = substr($locale->language_tag, 0, 2);
 	$self->{'numrules'} = 'en';
 	$self->{'numrules'} = $langtag if 
-		grep {/$langtag/} (qw/ca de es et fr hu it nl ru/);
+		grep {/$langtag/} (qw/ca de es et fr hu it nl ru da/);
 	$self->{'numrules'} = 'es' if $self->{'numrules'} eq 'ca';
 	$self->{'numrules'} = 'de' if $self->{'numrules'} eq 'ru';
 
@@ -106,6 +114,7 @@
 	return $self->num2text_et($amount) if $self->{'numrules'} eq 'et';
 	return $self->num2text_fr($amount) if $self->{'numrules'} eq 'fr';
 	return $self->num2text_it($amount) if $self->{'numrules'} eq 'it';
+	return $self->num2text_da($amount) if $self->{'numrules'} eq 'da';
 	return $self->num2text_en($amount);
 }
 
@@ -929,5 +938,90 @@
 }
 
 
+# A special (swedish-like) spelling of danish check numbers
+sub num2text_da {
+	my ($self, $amount) = @_;
+
+	# Handle 0
+	return $self->{numbername}{0} unless $amount;
+
+	# List of collected digits
+	my @textnumber = ();
+
+	# split amount into chunks of 3
+	my @num = reverse split //, abs($amount);
+	my @numblock = ();
+	my @a = ();
+	while (@num) {
+		@a = ();
+		for (1 .. 3) {
+			push @a, shift @num;
+		}
+		push @numblock, join / /, reverse @a;
+	}
+	
+	my $i;
+	my $bigplural;
+	while (@numblock) {
+		$i = $#numblock;
+		$numblock[$i] *= 1;
+		
+		if ($numblock[$i] == 0) {
+			pop @numblock;
+			next;
+		}
+
+		# Plural suffix "er" for million and up, not for tusinde
+		$bigpluralsuffix = "";
+		$bigpluralsuffix = "er" if ($i > 1 && $numblock[$i] > 1);
+	 
+		if ($numblock[$i] > 99) {
+		        @num = split //, $numblock[$i];
+
+			# the one from hundreds
+		        push @textnumber, $self->{numbername}{$num[0]};
+		 
+			# add hundred designation
+			push @textnumber, $self->{numbername}{100};
+
+			# reduce numblock
+			$numblock[$i] -= $num[0] * 100;
+		}
+
+		if ($numblock[$i] > 9) {
+		        @num = split //, $numblock[$i];
+
+			# the one from tens
+			push @textnumber, $self->{numbername}{$num[0]};
+		 
+			# add ten designation
+			push @textnumber, $self->{numbername}{10};
+
+			# reduce numblock
+			$numblock[$i] -= $num[0] * 10;
+		}
+		
+		if ($numblock[$i] > 0) {
+			# the ones left in the block
+		        if($numblock[$i] == 1 && $i != 1) {
+			    push @textnumber, $self->{numbername}{'1o'}; # Special case for "Et" tusinde
+			} else {
+			    push @textnumber, $self->{numbername}{$numblock[$i]};
+			}
+		}
+		
+		# add thousand, million, etc
+		if ($i) {
+			$amount = 10**($i * 3);
+			push @textnumber, $self->{numbername}{$amount}.$bigpluralsuffix;
+		}
+		
+		pop @numblock;
+	}
+
+	join '', @textnumber;
+
+}
+
 1;
 

Modified: branches/1.2/locale/po/da.po
===================================================================
--- branches/1.2/locale/po/da.po	2006-11-28 01:19:22 UTC (rev 698)
+++ branches/1.2/locale/po/da.po	2006-11-28 01:21:21 UTC (rev 699)
@@ -30,7 +30,7 @@
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "POT-Creation-Date: \n"
-"PO-Revision-Date: 2006-11-22 01:23+0100\n"
+"PO-Revision-Date: 2006-11-27 23:20+0100\n"
 "Last-Translator: Mads Kiilerich <..hidden..>\n"
 "Language-Team: \n"
 
@@ -1847,7 +1847,7 @@
 msgstr "PÃ lager"
 
 msgid "One"
-msgstr "En"
+msgstr "Et"
 
 msgid "One-o"
 msgstr "En"
@@ -2694,7 +2694,7 @@
 msgstr "Dette er fÃrste gang der logges pà LedgerSMB. SÃt venligst en administrativ adgangskode"
 
 msgid "Thousand"
-msgstr "Tusind"
+msgstr "Tusinde"
 
 msgid "Three"
 msgstr "Tre"


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.