b1fca01996-11-12Per Hedbor /* Bugs by: Per */
2f2cc71997-08-19Per Hedbor /* * name = "Swedish language plugin "; * doc = "Handles the conversion of numbers and dates to Swedish. You have to restart the server for updates to take effect."; */
b1fca01996-11-12Per Hedbor 
bacc0c2000-01-17Martin Nilsson inherit "abstract.pike";
b1fca01996-11-12Per Hedbor 
0917d32013-03-04Anders Johansson constant cvs_version = "$Id$";
ced8b32000-01-26Martin Nilsson constant _id = ({ "sv", "swedish", "svenska" });
bacc0c2000-01-17Martin Nilsson constant _aliases = ({ "sv", "se", "sve", "swe", "swedish", "svenska" }); constant months = ({ "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december" }); constant days = ({ "söndag","måndag","tisdag","onsdag", "torsdag","fredag", "lördag" });
e0c79f2016-08-22Jonas Walldén constant implode_conjunction = "och";
d103152000-09-09Martin Nilsson constant languages=([ "cat":"katalanska", "ces":"tjeckiska", "nld":"nederländska", "fin":"finska", "fra":"franska", "deu":"tyska", "eng":"engelska", "spa":"spanska", "hrv":"kroatiska", "hun":"ungerska", "ita":"italienska", "jpn":"japanska", "mri":"maori", "nor":"norska", "pol":"polska", "por":"portugisiska", "rus":"ryska", "sin":"slovenska", "slk":"slovakiska", "srp":"serbiska", "swe":"svenska"
bacc0c2000-01-17Martin Nilsson ]);
b1fca01996-11-12Per Hedbor  string ordered(int i) {
d058041997-09-16Henrik Grubbström (Grubba)  if (((< 1,2 >)[i%10]) && (!(< 11,12 >)[i%100])) { return i + ":a"; } return i + ":e";
b1fca01996-11-12Per Hedbor }
bacc0c2000-01-17Martin Nilsson string date(int timestamp, mapping|void m)
b1fca01996-11-12Per Hedbor { mapping t1=localtime(timestamp); mapping t2=localtime(time(0)); if(!m) m=([]); if(!(m["full"] || m["date"] || m["time"])) { if(t1["yday"] == t2["yday"] && t1["year"] == t2["year"]) return "i dag, klockan " + ctime(timestamp)[11..15];
bacc0c2000-01-17Martin Nilsson 
b1fca01996-11-12Per Hedbor  if(t1["yday"] == t2["yday"]-1 && t1["year"] == t2["year"]) return "i går, klockan " + ctime(timestamp)[11..15];
bacc0c2000-01-17Martin Nilsson 
b1fca01996-11-12Per Hedbor  if(t1["yday"] == t2["yday"]+1 && t1["year"] == t2["year"]) return "i morgon, vid " + ctime(timestamp)[11..15];
bacc0c2000-01-17Martin Nilsson 
b1fca01996-11-12Per Hedbor  if(t1["year"] != t2["year"]) return month(t1["mon"]+1) + " " + (t1["year"]+1900); else return "den " + t1["mday"] + " " + month(t1["mon"]+1); } if(m["full"])
bacc0c2000-01-17Martin Nilsson  return sprintf("%s, den %s %s %d",
b1fca01996-11-12Per Hedbor  ctime(timestamp)[11..15],
5e84cf2004-07-28 Erik Dahl  (string) t1["mday"],
54af481997-01-09Janne K Edelman  month(t1["mon"]+1), t1["year"]+1900);
b1fca01996-11-12Per Hedbor  if(m["date"])
5e84cf2004-07-28 Erik Dahl  return sprintf("den %s %s %d", (string)t1["mday"],
54af481997-01-09Janne K Edelman  month(t1["mon"]+1), t1["year"]+1900);
b1fca01996-11-12Per Hedbor  if(m["time"]) return ctime(timestamp)[11..15]; }
9ad6e71997-01-27Henrik Grubbström (Grubba) string _number(int num)
b1fca01996-11-12Per Hedbor { switch(num) { case 0: return "";
37b7a22001-10-01Martin Nilsson  case 1: return "ett";
b1fca01996-11-12Per Hedbor  case 2: return "två"; case 3: return "tre"; case 4: return "fyra"; case 5: return "fem"; case 6: return "sex"; case 7: return "sju"; case 8: return "åtta"; case 9: return "nio"; case 10: return "tio"; case 11: return "elva"; case 12: return "tolv"; case 13: return "tretton"; case 14: return "fjorton"; case 15: return "femton"; case 16: return "sexton"; case 17: return "sjutton"; case 18: return "arton"; case 19: return "nitton"; case 20: return "tjugo"; case 30: return "trettio"; case 40: return "fyrtio"; case 50: return "femtio"; case 60: return "sextio"; case 70: return "sjuttio"; case 80: return "åttio"; case 90: return "nittio";
bacc0c2000-01-17Martin Nilsson  case 21..29: case 31..39: case 41..49: case 51..59: case 61..69: case 71..79:
b1fca01996-11-12Per Hedbor  case 81..89: case 91..99:
14179b1997-01-29Per Hedbor  return _number((num/10)*10)+_number(num%10); case 100..999: return _number(num/100)+"hundra"+_number(num%100);
4c3b251997-01-28Per Hedbor  case 1000..1999:
6bbef81997-08-22Niels Möller  return _number(num/1000)+"tusen"+_number(num%1000);
14179b1997-01-29Per Hedbor  case 2000..999999: return _number(num/1000)+"tusen"+_number(num%1000);
bacc0c2000-01-17Martin Nilsson  case 1000000..1999999:
14179b1997-01-29Per Hedbor  return "en miljon"+_number(num%1000000);
bacc0c2000-01-17Martin Nilsson  case 2000000..999999999:
14179b1997-01-29Per Hedbor  return _number(num/1000000)+"miljoner"+_number(num%1000000);
b1fca01996-11-12Per Hedbor  default: return "många"; } }
9ad6e71997-01-27Henrik Grubbström (Grubba) string number(int num) { if (num<0) { return("minus "+_number(-num)); } if (num) { return(_number(num)); } else { return("noll"); } }
8514832000-11-27Per Hedbor 
e0c79f2016-08-22Jonas Walldén 
fc40392008-08-15Martin Stjernholm protected void create()
8514832000-11-27Per Hedbor { roxen.dump( __FILE__ ); }