1#!/usr/local/bin/perl 2 3# Copyright (C) 2000-2019 The Xastir Group 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License 7# as published by the Free Software Foundation; either version 2 8# of the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 18# 02111-1307, USA. 19# 20# Look at the README for more information on the program. 21 22 23# Run it like this: 24# 25# cd xastir/config 26# ../scripts/langMuppetsChef.pl -split <language-English.sys >language-MuppetsChef.sys 27# or 28# ../scripts/langMuppetsChef.pl <some-input-file >some-output-file 29# 30# "-split": Translate 2nd part of line only (Xastir language file). 31# Without it: Translate entire text. 32 33 34# Regex strings derived from: 35# http://www.siafoo.net/snippet/133 36# http://www.faqs.org/docs/diveintopython/dialect_divein.html 37# http://dougal.gunters.org/blog/2004/08/30/text-filter-suite 38 39 40# Check whether we're translating an Xastir language file or plain 41# text: 42# "-split" present: Translate the 2nd piece of each line. 43# "-split" absent: Translate the entire text. 44my $a; 45if ($#ARGV < 0) { $a = ""; } 46else { $a = shift; } 47$do_split = 0; 48if (length($a) > 0 && $a =~ m/-split/) { 49 $do_split = 1; 50} 51 52# Add these two lines to show that we translated the file. 53print "# language-MuppetsChef.sys, translated from language-English.sys\n"; 54print "# Please do not edit this derived file.\n"; 55 56while ( <> ) { 57 58 # Skip other comment lines 59 if (m/^#/) { 60 next; 61 } 62 63 if ($do_split) { 64 # Split each incoming line by the '|' character 65 @pieces = split /\|/; 66 67 # Translate the second portion of each line only 68 $_ = $pieces[1]; 69 } 70 71 s/An/Un/g; 72 s/an/un/g; 73 s/Au/Oo/g; 74 s/au/oo/g; 75 s/a\b/e/g; 76 s/A\b/E/g; 77 s/en\b/ee/g; 78 s/\bew/oo/g; 79 s/\be\b/e-a/g; 80 s/\be/i/g; 81 s/\bE/I/g; 82 s/\bf/ff/g; 83 s/\bir/ur/g; 84 s/(\w*?)i(\w*?)$/$1ee$2/g; 85 s/\bow/oo/g; 86 s/\bo/oo/g; 87 s/\bO/Oo/g; 88 s/the/zee/g; 89 s/The/Zee/g; 90 s/th\b/t/g; 91 s/\btion/shun/g; 92 s/\bu/oo/g; 93 s/\bU/Oo/g; 94 s/v/f/g; 95 s/V/F/g; 96 s/w/w/g; 97 s/W/W/g; 98 s/([a-z])[.]/$&. Bork Bork Bork!/g; 99 100 # From the text-filter-suite: 101 s/(\w)ew/$1oo/g; 102 s/(\w)ow/$1oo/g; 103 s/(\W)o/$1oo/g; 104 s/(\W)O/$1Oo/g; 105 s/(\w)u/$1oo/g; 106 s/(\w)U/$1Oo/g; 107 s/a(\w)/e$1/g; 108 s/A(\w)/E$1/g; 109 s/en(\W)/ee$1/g; 110 s/(\w)e(\W)/$1e-a$2/g; 111 s/(\W)e/$1i/g; 112 s/(\W)E/$1I/g; 113 s/(\w)f/$1ff/g; 114 s/(\w)ir/$1ur/g; 115 s/([a-m])i/$1ee/g; 116 s/([A-M])i/$1EE/g; 117 s/(\w)o/$1u/g; 118 s/the/zee/g; 119 s/The/Zee/g; 120 s/th(\W)/t$1/g; 121 s/(\w)tion/$1shun/g; 122 s/v/f/g; 123 s/V/F/g; 124 s/w/v/g; 125 s/W/V/g; 126 s/f{2,}/ff/g; 127 s/o{2,}/oo/g; 128 s/e{2,}/ee/g; 129# s/([\.!\?])\s*(</[^>]+>)?\s*$/$1 Bork Bork Bork!$2/g; 130 131 if ($do_split) { 132 # Combine the line again for output to STDOUT 133 $pieces[1] = $_; 134 print join '|', @pieces; 135 } 136 else { 137 print; 138 } 139} 140 141 142