User:3247's Image Wizard/Scripts/mk iso639.pl
From Wikimedia Commons, the free media repository
#!/usr/bin/perl
open FILES, ">files.txt";
sub width ($) {
my $w = 0; my($l,$r) = (0,0);
foreach my $l (split //, $_[0]) {
$w++ if $l =~ m/[mw]/;
$w-- if $l =~ m/[fijlt]/;
$w+=2;
}
$l = 1 if $_[0] =~ m/^[bhkj]/;
$r = 1 if $_[0] =~ m/[gql]$/;
$w += .5 if $l && $r;
return ($w, $l ? ($r ? 0 : 5) : ($r ? -5 : 0));
}
foreach(@ARGV) {
my $f = lc $_; my $F = uc $f;
open FILE, ">ISO 639-1 Icon $f.svg";
print FILE '<?xml version="1.0" encoding="UTF-8" standalone="no"?>',"\n";
print FILE '<svg xmlns="http://www.w3.org/2000/svg" width="400" height="180">',"\n";
print FILE '<path fill="#0000C8" d="M21.394289 0a200 200 0 0 0 0 180L67.712434 180a160 160 0 0 1 0 -180ZM330.228757 0a160 160 0 0 1 0 180L378.605711 180a200 200 0 0 0 0 -180Z" />',"\n";
print FILE '<path fill="navy" d="M87.754733 15a135 135 0 0 0 0 150L119.532615 165a119 119 0 0 1 0 -150ZM280.467385 15a110 110 0 0 1 0 150L312.245267 165a135 135 0 0 0 0 -150Z" />',"\n";
my ($w,$s) = width $f; $w = 4 if $w <= 4;
printf FILE '<text x="%d" y="141" font-size="150" fill="navy" font-family="Helvetica,Arial,sans-serif" font-weight="bold"', (200 + $s) * $w / 4;
printf FILE ' transform="scale(%01.2f 1)"', 4/$w if $w > 4;
print FILE ' text-anchor="middle">', $f, '</text>',"\n";
print FILE '</svg>',"\n";
print FILES ">ISO 639 Icon $f.svg\n";
print FILES "{{Information\n";
print FILES "|Description = {{en|Language icon for ISO 631 language code '''$F'''}}\n";
print FILES "|Date = {{subst:CURRENTYEAR}}-{{subst:CURRENTMONTH}}-{{subst:CURRENTDAY2}}\n";
print FILES "|Source = created with [[:User:3247's Image Wizard/Scripts/mk_iso639.pl|mk_iso639.pl]]\n";
print FILES "|Permission = see below\n";
print FILES "|Author = Claus Färber ([[User:3247|]]); based on bitmap by [[User:Nataraja|Nataraja]] and SVG by [[user:Shazz|Shazz]]\n";
print FILES "}}\n\n";
print FILES "==License==\n";
print FILES "{{GFDL}}\n";
print FILES "[[Category:Icons ISO 639|$f]]\n";
}
| If this file is eligible for relicensing, it may also be used under the Creative Commons Attribution-ShareAlike 3.0 license. The relicensing status of this image has not yet been reviewed. You can help. Català | Česky | Deutsch | English | Español | Eesti | Français | עברית | Hrvatski | Italiano | 日本語 | 한국어 | Lietuvių | Македонски | Occitan | Português | Română | Русский | Svenska | ไทย | +/− |