#!/usr/bin/perl opendir(Dir, "Resources") || die "Can't open Resources directory: $!\n"; @files = grep(/edustrings/,readdir(Dir)); closedir(Dir); open ($outfile, '>', "language.js") or die $!; print($outfile "language = {\n"); foreach $file (@files) { $lang = $file; $lang =~ s/edustrings.//; $lang =~ s/.json//; print($outfile " $lang : {\n"); open my $info, "Resources/$file" or die "Could not open $file: $!"; while( my $line = <$info>) { chomp($line); if ( $line =~ /name": "(.*)",$/) { print($outfile " $1 : {"); } if ( $line =~ /value": "(.*)",$/) { print($outfile "$line\n"); } if ( $line =~ /value": "(.*)"$/) #if there is no comment { print($outfile "$line\n },\n"); } if ( $line =~ /comment": "(.*)"$/) { print($outfile " $line\n },\n"); } } print($outfile " },\n"); #End the language file; } print($outfile "];\n"); #End the language variable definition close($outfile);