From 44e5388c0ed36b9391d93a28aa275fc1e4533403 Mon Sep 17 00:00:00 2001 From: rajon Date: Fri, 12 Feb 2021 01:28:21 +0100 Subject: [PATCH] Add Polish to options --- custom.html | 3 +- lang/pl.json | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++ virtualsky.js | 97 ++++++++++++++-------------- 3 files changed, 225 insertions(+), 49 deletions(-) create mode 100644 lang/pl.json diff --git a/custom.html b/custom.html index b43a58c..f0cc7a1 100644 --- a/custom.html +++ b/custom.html @@ -190,8 +190,9 @@

Customize

+ - only set this if you have to explicitly specify a language. + only set this if you have to explicitly specify a language.
diff --git a/lang/pl.json b/lang/pl.json new file mode 100644 index 0000000..4136be0 --- /dev/null +++ b/lang/pl.json @@ -0,0 +1,174 @@ +{ + "title": "VirtualSky", + "language": { + "code": "pl", + "name": "Polski", + "alignment": "left", + "translator": "raajon" + }, + "constellations": { + "And": "Andromeda", + "Ant": "Pompa", + "Aps": "Ptak Rajski", + "Aqr": "Wodnik", + "Aql": "Orzeł", + "Ara": "Ołtarz", + "Ari": "Baran", + "Aur": "Woźnica", + "Boo": "Wolarz", + "Cae": "Rylec", + "Cam": "Żyrafa(Wielbłąd)", + "Cnc": "Rak", + "CVn": "Psy Gończe", + "CMa": "Wielki Pies", + "CMi": "Mały Pies", + "Cap": "Koziorożec", + "Car": "Kil", + "Cas": "Kasjopeja", + "Cen": "Centaur", + "Cep": "Cefeusz", + "Cet": "Wieloryb", + "Cha": "Kameleon", + "Cir": "Cyrkiel", + "Col": "Gołąb", + "Com": "Warkocz Bereniki", + "CrA": "Korona Południowa", + "CrB": "Korona Północna", + "Crv": "Kruk", + "Crt": "Puchar", + "Cru": "Krzyż Południa", + "Cyg": "Łabędź", + "Del": "Delfin", + "Dor": "Złota Ryba", + "Dra": "Smok", + "Equ": "Źrebię", + "Eri": "Erydan", + "For": "Piec", + "Gem": "Bliźnięta", + "Gru": "Żuraw", + "Her": "Herkules", + "Hor": "Zegar", + "Hya": "Hydra", + "Hyi": "Wąż Wodny", + "Ind": "Indianin", + "Lac": "Jaszczurka", + "Leo": "Lew", + "LMi": "Mały Lew", + "Lep": "Zając", + "Lib": "Waga", + "Lup": "Wilk", + "Lyn": "Ryś", + "Lyr": "Lutnia", + "Men": "Góra Stołowa", + "Mic": "Mikroskop", + "Mon": "Jednorożec", + "Mus": "Mucha", + "Nor": "Węgielnica", + "Oct": "Oktant", + "Oph": "Wężownik", + "Ori": "Orion", + "Pav": "Paw", + "Peg": "Pegaz", + "Per": "Perseusz", + "Phe": "Feniks", + "Pic": "Malarz", + "Psc": "Ryby", + "PsA": "Ryba Południowa", + "Pup": "Rufa", + "Pyx": "Kompas", + "Ret": "Sieć", + "Sge": "Strzała", + "Sgr": "Strzelec", + "Sco": "Skorpion", + "Scl": "Rzeźbiarz", + "Sct": "Tarcza Sobieskiego", + "Ser": "Wąż", + "Sex": "Sekstant", + "Tau": "Byk", + "Tel": "Luneta", + "Tri": "Trójkąt", + "TrA": "Trójkąt Południowy", + "Tuc": "Tukan", + "UMa": "Wielka Niedźwiedzica", + "UMi": "Mała Niedźwiedzica", + "Vel": "Żagiel", + "Vir": "Panna", + "Vol": "Ryba Latająca", + "Vul": "Lisek" + }, + "planets": { + "Me": "Merkury", + "V": "Wenus", + "Ma": "Mars", + "J": "Jowisz", + "S": "Saturn", + "U": "Uran", + "N": "Neptun" + }, + "sun":"Słońce", + "moon":"Księżyc", + "date": "Data & Czas", + "datechange": "Zmień datę / godzinę (wyświetlane w Twoim czasie lokalnym)", + "close": "close", + "position": "Szerokość & Długość", + "positionchange": "Zmień długość/szerokość", + "N": "Pn", + "E": "Wsch.", + "S": "Pd", + "W": "Zach.", + "keyboard": "Skróty klawiszy:", + "fast": "prześpiesz czas", + "stop": "ustaw stopę czasową na zero", + "slow": "zwolnij czas", + "reset": "ustaw bieżący czas", + "cardinal": "przełączaj kierunki", + "stars": "gwiazdy", + "starlabels": "nazwy gwiazd", + "neg": "odwróć kolory", + "atmos": "atmosfera", + "ground": "ziemia", + "az": "linie siatki Az / El", + "eq": "linie siatki Ra / Dec", + "gal": "linie siatki galaktyki", + "galaxy": "halo galaktyki", + "ec": "linie siatki ekiptyki", + "meridian": "linie siatki południków", + "con": "konstelacje", + "conbound": "granice konstelacji", + "names": "nazwy konstelacji", + "sol": "Słońce / Księżyc", + "sollabels": "ektykiety planet + Słóńce i Księżyc", + "orbits": "orbity planet", + "projection":"projekcja", + "meteorshowers":"roje meteorów", + "addday": "dodaj dzień", + "subtractday": "odejmij dzień", + "addweek": "dodaj tydzień", + "subtractweek": "odejmij tydzień", + "azleft": "przekręć w lewo", + "azright": "przekręc w prawo", + "magup": "zwiększ limit magnitudy", + "magdown": "zmniejsz limit magnitudy", + "left" : "←", + "right" : "→", + "up": "↑", + "down": "↓", + "power": "Powered by LCO", + "projections": { + "polar": "Odwzorowanie Polarne", + "fisheye": "Odwzorowanie Rybie Oko", + "ortho": "Odwzorowanie prostokątne", + "stereo": "Odwzorowanie Stereograficzne", + "lambert": "Odwzorowanie Lamberta", + "gnomic": "Odwzorowanie gnomiczne", + "equirectangular": "Odwzorowanie walcowe", + "mollweide": "Odwzorowanie Mollweidego", + "planechart": "Odwzorowanie mapy samolotowej" + }, + "starnames":{ + "7588":"Achernar","11767":"Polarna","21421":"Aldebaran","24436":"Rigel","24608":"Kapella","27989":"Betelgeza", + "30438":"Kanopus","32349":"Syriusz","33579":"Adara","37279":"Procjon","37826":"Polluks","49669":"Regulus","62434":"Mimosa", + "65378":"Mizar","65474":"Spica","68702":"Hadar","69673":"Arktur","71683":"Alpha Centauri A","80763":"Antares","85927":"Shaula", + "91262":"Wega","97649":"Altair","102098":"Deneb","113368":"Fomalhaut" + } +} diff --git a/virtualsky.js b/virtualsky.js index 7458844..766dbcb 100644 --- a/virtualsky.js +++ b/virtualsky.js @@ -5,7 +5,7 @@ */ /* USAGE: See http://slowe.github.io/VirtualSky/ - + OPTIONS (default values in brackets): id ('starmap') - The ID for the HTML element where you want the sky inserted projection ('polar') - The projection type as 'polar', 'stereo', 'lambert', 'equirectangular', or 'ortho' @@ -224,7 +224,7 @@ window.fullScreenApi = fullScreenApi; /*! VirtualSky */ function VirtualSky(input){ - this.version = "0.7.6"; + this.version = "0.7.7"; this.ie = false; this.excanvas = (typeof G_vmlCanvasManager != 'undefined') ? true : false; @@ -464,7 +464,7 @@ function VirtualSky(input){ // Should we show things below the horizon? if(this.ground && coords[0] < -1e-6) return {x:-1, y:-1, el:coords[0]*this.r2d}; - + // number of pixels per degree in the map scale = this.tall/this.fov; @@ -475,7 +475,7 @@ function VirtualSky(input){ dA = ra-this.ra_off; dA = inrangeAz(dA); - + A = cd*Math.cos(dA); F = scale*this.r2d/(sd0*sd + A*cd0); @@ -632,7 +632,7 @@ function VirtualSky(input){ atmos: false } }; - + // Data for stars < mag 4.5 or that are a vertex for a constellation line - 20 kB [id, mag, right ascension, declination] // index with Hipparcos number this.stars = this.convertStarsToRadians([[677,2.1,2.097,29.09],[746,2.3,2.295,59.15],[765,3.9,2.353,-45.75], @@ -835,7 +835,7 @@ function VirtualSky(input){ // Data for star names to display (if showstarlabels is set to true) - indexed by Hipparcos number this.starnames = {}; - + // Add the stars to the lookup this.lookup.star = []; for(i = 0; i < this.stars.length; i++) this.lookup.star.push({'ra':this.stars[i][2],'dec':this.stars[i][3],'label':this.stars[i][0],'mag':this.stars[i][1]}); @@ -916,6 +916,7 @@ function VirtualSky(input){ 'gl': { "language": {"name": "Galego","alignment": "left" } }, 'it': { "language": {"name": "Italiano","alignment": "left" } }, 'nl': { "language": {"name": "Nederlands","alignment": "left" } }, + 'pl': { "language": {"name": "Polski","alignment": "left" } }, 'pt': { "language": {"name": "Português","alignment": "left" } }, }; // The contents of the language will be loaded from the JSON language file this.lang = this.langs.en; // default @@ -987,7 +988,7 @@ VirtualSky.prototype.init = function(d){ if(!d) return this; var q = location.search; var key,val,i; - + if(q && q != '#'){ var bits = q.replace(/^\?|\&$/g,'').split('&'); // remove the leading ? and trailing & for(i = 0; i < bits.length ; i++){ @@ -1006,8 +1007,8 @@ VirtualSky.prototype.init = function(d){ var b = "boolean"; var o = "object"; var f = "function"; - - + + // Overwrite defaults with variables passed to the function // directly mapped variables var pairs = { @@ -1047,7 +1048,7 @@ VirtualSky.prototype.init = function(d){ for(key in pairs) if(is(d[key], pairs[key])) this[key] = d[key]; - + // Undirectly paired values if(is(d.projection,s)) this.selectProjection(d.projection); if(is(d.constellations,b)) this.constellation.lines = d.constellations; @@ -1130,8 +1131,8 @@ VirtualSky.prototype.loadLanguage = function(l,fn,fromquerystring){ }, function(data){ }, function(e){ - // If we tried to load the short version of the language and it failed, - // default to English (unless we were trying to get English in which + // If we tried to load the short version of the language and it failed, + // default to English (unless we were trying to get English in which // case something is very wrong). if(l!="en") this.loadLanguage('en',fn); } @@ -1251,7 +1252,7 @@ VirtualSky.prototype.loadJSON = function(file,callback,complete,error){ if(typeof file!=="string") return this; var dt = file.match(/\.json$/i) ? "json" : "script"; if(dt=="script"){ - // If we are loading an external script we need to make sure we initiate + // If we are loading an external script we need to make sure we initiate // it first. To do that we will re-write the callback that was provided. var tmp = callback; callback = function(data){ @@ -1291,10 +1292,10 @@ VirtualSky.prototype.checkLoaded = function(){ // Get the constellation line data if(!this.lines && this.constellation.lines) this.load('lines',this.file.lines); - + // Get the constellation line data if(!this.boundaries && this.constellation.boundaries) this.load('boundaries',this.file.boundaries); - + // Get the meteor showers if(!this.showers && this.meteorshowers) this.load('showers',this.file.showers); @@ -1322,12 +1323,12 @@ VirtualSky.prototype.createSky = function(){ window.onresize = function(){ _obj.resize(); }; this.checkLoaded(); - + // Get the faint star data this.changeMagnitude(0); var o; - + // Add named objects to the display if(this.objects){ // To stop lookUp being hammered, we'll only lookup a maximum of 5 objects @@ -1383,7 +1384,7 @@ VirtualSky.prototype.createSky = function(){ if(this.excanvas) this.c = G_vmlCanvasManager.initElement(this.c); - if(this.c && this.c.getContext){ + if(this.c && this.c.getContext){ this.setWH(this.wide,this.tall); var ctx = this.ctx = this.c.getContext('2d'); ctx.clearRect(0,0,this.wide,this.tall); @@ -1423,7 +1424,7 @@ VirtualSky.prototype.createSky = function(){ e.ra = skyPos.ra / sky.d2r; e.dec = skyPos.dec / sky.d2r; } - return e; + return e; } function getXY(sky,o,el,e){ e.x = o.pageX - el.offset().left - window.scrollX; @@ -1646,7 +1647,7 @@ VirtualSky.prototype.toggleHelp = function(){ this.container.append('
'+ '
×
'+ '
'+this.getPhrase('keyboard')+'
'+ - '
    '+ + '
      '+ '
      '+this.lang.title+': '+this.version+'
      '+ '
      '); @@ -1755,7 +1756,7 @@ VirtualSky.prototype.whichPointer = function(x,y){ for(var i = 0 ; i < this.pointers.length ; i++) if(Math.abs(x-this.pointers[i].x) < 5 && Math.abs(y-this.pointers[i].y) < 5) return i; - + return -1; }; VirtualSky.prototype.toggleInfoBox = function(i){ @@ -1858,7 +1859,7 @@ function inrangeAz(a,deg){ }else{ var twopi = (2*Math.PI); while(a < 0) a += twopi; - while(a > twopi) a -= twopi; + while(a > twopi) a -= twopi; } return a; } @@ -1880,7 +1881,7 @@ VirtualSky.prototype.selectProjection = function(proj){ this.polartype = this.projection.polartype == true; // Set coordinate transforms - + // Convert AZ,EL -> X,Y // Inputs: az (rad), el (rad), width (px), height (px) if(typeof this.projection.azel2xy==="function"){ @@ -2218,7 +2219,7 @@ VirtualSky.prototype.Transform = function(p, rot, indeg){ var cp1 = Math.cos(p[1]); var m = [Math.cos(p[0])*cp1, Math.sin(p[0])*cp1, Math.sin(p[1])]; var s = [m[0]*rot[0] + m[1]*rot[1] + m[2]*rot[2], m[0]*rot[3] + m[1]*rot[4] + m[2]*rot[5], m[0]*rot[6] + m[1]*rot[7] + m[2]*rot[8] ]; - var r = Math.sqrt(s[0]*s[0] + s[1]*s[1] + s[2]*s[2]); + var r = Math.sqrt(s[0]*s[0] + s[1]*s[1] + s[2]*s[2]); var b = Math.asin(s[2]/r); // Declination in range -90 -> +90 var cb = Math.cos(b); var a = Math.atan2(((s[1]/r)/cb),((s[0]/r)/cb)); @@ -2329,7 +2330,7 @@ VirtualSky.prototype.drawImmediate = function(proj){ c.closePath(); } } - + this.startClip() .drawGridlines("az") .drawGridlines("eq") @@ -2438,8 +2439,8 @@ VirtualSky.prototype.drawImmediate = function(proj){ '
      ×
      '+ '
      '+s.getPhrase('date')+'
      '+ '
      '+ - '' + - '' + + '' + + '' + '
      '+ '
      '); S(hid+'_calendar').css({width:w}); @@ -2498,7 +2499,7 @@ VirtualSky.prototype.drawImmediate = function(proj){ if(typeof s.callback.geo=="function") s.callback.geo.call(s); }); } - + off = S('#'+this.idinner).position(); S('.'+this.id+'_position').css({ position:'absolute', @@ -2589,7 +2590,7 @@ VirtualSky.prototype.createLightbox = function(lb,opts){ this.vs.lightbox = null; return this; }; - + this.lightbox = new Lightbox(lb,this,opts); return this; @@ -2624,7 +2625,7 @@ VirtualSky.prototype.drawStars = function(){ if(this.showstars) c.arc(p.x,p.y,d,0,Math.PI*2,true); if(this.showstarlabels && this.starnames[this.stars[i][0]]) this.drawLabel(p.x,p.y,d,"",this.htmlDecode(this.starnames[this.stars[i][0]])); } - } + } } c.fill(); @@ -2739,7 +2740,7 @@ VirtualSky.prototype.drawPlanets = function(){ c.stroke(); } } - + // Sun & Moon if(this.showplanets || this.showplanetlabels){ @@ -2784,7 +2785,7 @@ VirtualSky.prototype.drawPlanet = function(x,y,d,colour,label){ return this; }; VirtualSky.prototype.drawText = function(txt,x,y){ - this.ctx.beginPath(); + this.ctx.beginPath(); this.ctx.fillText(txt,x,y); return this.ctx.measureText(txt).width; }; @@ -2871,7 +2872,7 @@ VirtualSky.prototype.drawConstellationLines = function(colour){ // Draw the boundaries of constellations // Input: colour (e.g. "rgb(255,255,0)") // We should have all the boundary points stored in this.boundaries. As many of the constellations -// will share boundaries we don't want to bother drawing lines that we've already done so we will +// will share boundaries we don't want to bother drawing lines that we've already done so we will // keep a record of the lines we've drawn as we go. As some segments may be large on the sky we will // interpolate a few points between so that boundaries follow the curvature of the projection better. // As the boundaries are in FK1 we will calculate the J2000 positions once and keep them cached as @@ -2919,15 +2920,15 @@ VirtualSky.prototype.drawConstellationBoundaries = function(colour){ if(ra < -180) ra = ra+360; dc = (b[1]-a[1]); - // If we've already done this line we'll only calculate + // If we've already done this line we'll only calculate // two points on the line otherwise we'll do 5 n = (move) ? 5 : 2; if(ra/2 > n) n = parseInt(ra); if(dc/2 > n) n = parseInt(dc); - + dra = ra/n; ddc = dc/n; - + for(i = 1; i <= n; i++){ ra = a[0]+(i*dra); if(ra < 0) ra += 360; @@ -3001,7 +3002,7 @@ VirtualSky.prototype.drawGalaxy = function(colour){ dy = Math.abs(pa.y-pb.y); if(!isNaN(dx) && !isNaN(dy)){ // Basic error checking: if the line is very long we need to normalize to other side of sky - if(dx >= maxl || dy >= maxl) this.ctx.moveTo(pb.x,pb.y); + if(dx >= maxl || dy >= maxl) this.ctx.moveTo(pb.x,pb.y); this.ctx.lineTo(pb.x,pb.y); }else{ this.ctx.moveTo(pb.x,pb.y); @@ -3061,14 +3062,14 @@ VirtualSky.prototype.drawEcliptic = function(colour){ if(!colour || typeof colour!="string") colour = this.col.ec; var c = this.ctx; var step = 2*this.d2r; - c.beginPath(); + c.beginPath(); c.strokeStyle = colour; c.lineWidth = 3; var maxl = this.maxLine(); var old = {x:-1,y:-1,moved:false}; for(var a = 0 ; a < Math.PI*2 ; a += step) old = joinpoint(this,"ec",a,0,old,maxl); - + c.stroke(); return this; }; @@ -3082,7 +3083,7 @@ VirtualSky.prototype.drawMeridian = function(colour){ var maxb = (typeof this.projection.maxb==="number") ? this.projection.maxb*this.d2r : Math.PI/2; var step = 2*this.d2r; var maxl = this.maxLine(); - c.beginPath(); + c.beginPath(); c.strokeStyle = colour; c.lineWidth = 2; @@ -3104,7 +3105,7 @@ VirtualSky.prototype.drawGridlines = function(type,step,colour){ c = this.ctx; oldx = 0; oldy = 0; - c.beginPath(); + c.beginPath(); c.strokeStyle = colour; c.lineWidth = (this.grid.lineWidth || 1); bstep = 2; @@ -3127,7 +3128,7 @@ VirtualSky.prototype.drawGridlines = function(type,step,colour){ for(b = minb; b <= maxb ; b+= bstep) old = joinpoint(this,type,a,b,old,maxl); } c.stroke(); - c.beginPath(); + c.beginPath(); if(type=="az"){ minb = 0; maxb = 90-bstep*this.r2d; @@ -3178,7 +3179,7 @@ VirtualSky.prototype.drawCardinalPoints = function(){ if(x > 0) c.fillText(d[i],x,y); } c.fill(); - + return this; }; @@ -3227,7 +3228,7 @@ function joinpoint(s,type,a,b,old,maxl){ old.moved = true; }else{ // If the last point on s contour is more than a canvas width away - // it is probably supposed to be behind us so we won't draw a line + // it is probably supposed to be behind us so we won't draw a line if(!old.moved || Math.sqrt(Math.pow(old.x-x,2)+Math.pow(old.y-y,2)) > maxl){ c.moveTo(x,y); old.moved = true; @@ -3257,7 +3258,7 @@ VirtualSky.prototype.setGeo = function(pos){ // Input: latitude (deg) VirtualSky.prototype.setLatitude = function(l){ this.latitude = {'deg':parseFloat(l),'rad':inrangeEl(parseFloat(l)*this.d2r)}; - return this; + return this; }; // Input: longitude (deg) @@ -3265,7 +3266,7 @@ VirtualSky.prototype.setLongitude = function(l){ this.longitude = {'deg':parseFloat(l),'rad':parseFloat(l)*this.d2r}; while(this.longitude.rad <= -Math.PI) this.longitude.rad += 2*Math.PI; while(this.longitude.rad > Math.PI) this.longitude.rad -= 2*Math.PI; - return this; + return this; }; @@ -3326,7 +3327,7 @@ VirtualSky.prototype.panStep = function(){ // Still animating if(t < 1){ // update and draw - this.setRADec(ra,dc).draw(); + this.setRADec(ra,dc).draw(); var _obj = this; // request new frame requestAnimFrame(function() { _obj.panStep(); }); @@ -3482,7 +3483,7 @@ VirtualSky.prototype.spinIt = function(tick,wait){ else{ var t = 1.0/this.fps; var s = 2; - // this.spin is the number of seconds to update the clock by + // this.spin is the number of seconds to update the clock by if(this.spin == 0) this.spin = (tick == "up") ? t : -t; else{ if(Math.abs(this.spin) < 1) s *= 2;