qnguyen has asked for the wisdom of the Perl Monks concerning the following question:
Here is an example of my test2.txt file:#!/usr/bin/perl use warnings; use strict; ## LAN filename for translation my $filetwo="test2.txt"; ## Translated debug file my $fileout="out.txt"; my $linein; my $englishword; my $spanishword; my %langhash; my @arrayin; ## Open Lan file to read in the English and Spanish words open (FILEIN2, $filetwo) or die "Can't open debug file to be translat +ed.\n";; open (FILEOUT, ">$fileout") or die "Can't open output file.\n";; ## Go through each line and replace while ($linein = <FILEIN2>) { chomp $linein; @arrayin = split /:/, $linein; ##creates an array with + split function using : as separator if (exists $arrayin[0] && $arrayin[0] eq "Default") { $englishword = $arrayin[1]; } if (exists $arrayin[0] && $arrayin[0] eq "Spanish_LatinAmerica +n|es_MX") { $spanishword = $arrayin[1]; } if (exists $arrayin[0] && $arrayin[0] eq "Spanish_LatinAmerica +n|es_MX") { $langhash{$spanishword} = $englishword; } } ## while (($spanishword, $englishword) = each %langhash){ ##Pr +int entire hash tableS ## print "$englishword => $spanishword\n"; ## } close(FILEIN2); close(FILEOUT); ##while (($spanishword, $englishword) = each %langhash){ ##Print en +tire hash tableS ## print "$englishword => $spanishword\n"; ## print "$langhash{$spanishword}\n"; ## } $spanishword = &trim (" Espere para verificar el estado del operador +. "); if (exists $langhash{$spanishword}){ print "$langhash{$spanishword}\n"; } else { print "No match\n"; } sub trim { for (my $s = $_[0]) { s/^\s+//; s/\s+$//; return $_; } }
Comment:No Translation Needed Default:digit incorrect. Translate: FALSE Spanish_LatinAmerican|es_MX:dígito verificador incorrecto. Comment: This message is spoken to an operator when the "release licen +se" voice command is used. The message confirms to the operator that +the license was released. Default:Say ready. Translate: FALSE Spanish_LatinAmerican|es_MX:listo. Comment: This message is spoken to an operator when the "release licen +se" voice command is used. The message confirms to the operator that +the license was released. Default:Reverse Translate: FALSE Spanish_LatinAmerican|es_MX:Forward Comment: The task is telling the operator that they specified an incor +rect location. Default: Incorrect location. Spanish_LatinAmerican|es_MX: Ubicación incorrecta. Comment: Tells the operator that the operator status is being checked. Default: Please wait to check operator status Spanish_LatinAmerican|es_MX: Espere para verificar el estado del opera +dor.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Still having problems with spanish characters
by almut (Canon) on Sep 28, 2007 at 17:58 UTC | |
|
Re: Still having problems with spanish characters
by Anonymous Monk on Sep 28, 2007 at 20:15 UTC | |
by almut (Canon) on Sep 28, 2007 at 20:36 UTC | |
by Anonymous Monk on Sep 29, 2007 at 00:55 UTC | |
|
Re: Still having problems with spanish characters
by graff (Chancellor) on Sep 29, 2007 at 14:43 UTC | |
by almut (Canon) on Sep 29, 2007 at 16:58 UTC | |
by graff (Chancellor) on Sep 29, 2007 at 17:15 UTC |