From: Tim Wood Date: Sat, 12 Nov 2011 02:11:20 +0000 (-0700) Subject: Cleaning up paths for minified language files X-Git-Tag: 1.1.2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f42ebc92ecd4c8042a9364b6a8bf2cb4aefc93c;p=thirdparty%2Fmoment.git Cleaning up paths for minified language files Adding cache busting timestamp to build script for static assets. Adding Polish language #53 Adding Swedish language #52 Unminifying unit tests for more detailed debugging. --- diff --git a/build.js b/build.js index a4dd8da72..5b37e9312 100755 --- a/build.js +++ b/build.js @@ -3,7 +3,8 @@ var fs = require('fs'), jshint = require('jshint'), gzip = require('gzip'), jade = require('jade'), - clean = require('clean-css'); + clean = require('clean-css'), + moment = require('./moment'); /********************************************* @@ -38,14 +39,15 @@ var JSHINT_CONFIG = { "strict": false, "white": true }; -var LANG_MINIFY = "fr it pt es nl de".split(" "); -var LANG_TEST = "en fr it pt es nl de".split(" "); +var LANG_MINIFY = "fr it pt es nl de sv pl".split(" "); +var LANG_TEST = "en fr it pt es nl de sv pl".split(" "); var LANG_PREFIX = "(function() { var moment; if (typeof window === 'undefined') { moment = require('../../moment'); module = QUnit.module; } else { moment = window.moment; }"; var LANG_SUFFIX = "})();"; var VERSION = '1.1.1'; var MINIFY_COMMENT = '/* Moment.js | version : ' + VERSION + ' | author : Tim Wood | license : MIT */\n'; var MINSIZE = 0; var SRCSIZE = 0; +var BUILD_DATE = moment().format('YYMMDD_HHmmss'); /********************************************* @@ -135,15 +137,15 @@ function hint(source, name) { source; for (i = 0; i < LANG_MINIFY.length; i++) { source = fs.readFileSync('./lang/' + LANG_MINIFY[i] + '.js', 'utf8'); - if (hint(source, 'lang/' + LANG_MINIFY[i])) { - minifyToFile(source, 'lang/' + LANG_MINIFY[i]); + if (hint(source, 'lang/min/' + LANG_MINIFY[i])) { + minifyToFile(source, 'lang/min/' + LANG_MINIFY[i]); allSource += source; } else { failures ++; } } if (failures === 0) { - minifyToFile(allSource, 'lang/all'); + minifyToFile(allSource, 'lang/min/all'); minifyToFile(allSource, 'site/js/lang-all'); } })(); @@ -213,7 +215,7 @@ function makeUnitTests(){ var q = fs.readFileSync('./sitesrc/js/qunit.js', 'utf8'); var u = fs.readFileSync('./sitesrc/js/unit-tests.js', 'utf8'); var l = fs.readFileSync('./sitesrc/js/lang-tests.js', 'utf8'); - minifyToFile(q + u + l, 'site/js/test'); + makeFile('site/js/test.min.js', q + u + l); } @@ -231,7 +233,8 @@ function jadeToHtml(jadePath, htmlPath) { var args = { version : VERSION, minsize : toKb(MINSIZE), - srcsize : toKb(SRCSIZE) + srcsize : toKb(SRCSIZE), + builddate : BUILD_DATE }; var snippet = fs.readFile(jadePath, 'utf8', function(err, data){ var compile = jade.compile(data, { diff --git a/lang/all.min.js b/lang/min/all.min.js similarity index 61% rename from lang/all.min.js rename to lang/min/all.min.js index 81a4c2837..c90aba2a6 100644 --- a/lang/all.min.js +++ b/lang/min/all.min.js @@ -1 +1 @@ -(function(){var a={months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),longDateFormat:{L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"une année",yy:"%d années"},ordinal:function(a){return a===1?"er":"ème"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("fr",a)})(),function(){var a={months:"Gennaio_Febbraio_Marzo_Aprile_Maggio_Giugno_Luglio_Agosto_Settebre_Ottobre_Novembre_Dicembre".split("_"),monthsShort:"Gen_Feb_Mar_Apr_Mag_Giu_Lug_Ago_Set_Ott_Nov_Dic".split("_"),weekdays:"Domenica_Lunedi_Martedi_Mercoledi_Giovedi_Venerdi_Sabato".split("_"),weekdaysShort:"Dom_Lun_Mar_Mer_Gio_Ven_Sab".split("_"),longDateFormat:{L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s fa",s:"secondi",m:"un minuto",mm:"%d minuti",h:"un ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("it",a)}(),function(){var a={months:"Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),monthsShort:"Jan_Feb_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdays:"Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),weekdaysShort:"Dom_Seg_Ter_Qua_Qui_Sex_Sáb".split("_"),longDateFormat:{L:"DD/MM/YYYY",LL:"D \\de MMMM \\de YYYY",LLL:"D \\de MMMM \\de YYYY HH:mm",LLLL:"dddd, D \\de MMMM \\de YYYY HH:mm"},relativeTime:{future:"em %s",past:"%s atrás",s:"segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"},ordinal:function(a){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("pt",a)}(),function(){var a={months:"Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre".split("_"),monthsShort:"Ene._Feb._Mar._Abr._May._Jun._Jul._Ago._Sep._Oct._Nov._Dic.".split("_"),weekdays:"Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado".split("_"),weekdaysShort:"Dom._Lun._Mar._Mié._Jue._Vie._Sáb.".split("_"),longDateFormat:{L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(a){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("es",a)}(),function(){var a={months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mar._apr._mei._jun._jul._aug._sep._okt._nov._dec.".split("_"),weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),longDateFormat:{L:"DD-MM-YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"één minuutje",mm:"%d minuten",h:"één uur",hh:"%d uren",d:"één dag",dd:"%d dagen",M:"één maand",MM:"%d maanden",y:"één jaar",yy:"%d jaren"},ordinal:function(a){return a===1||a===8||a>=20?"ste":"de"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("nl",a)}() \ No newline at end of file +(function(){var a={months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),longDateFormat:{L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"une année",yy:"%d années"},ordinal:function(a){return a===1?"er":"ème"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("fr",a)})(),function(){var a={months:"Gennaio_Febbraio_Marzo_Aprile_Maggio_Giugno_Luglio_Agosto_Settebre_Ottobre_Novembre_Dicembre".split("_"),monthsShort:"Gen_Feb_Mar_Apr_Mag_Giu_Lug_Ago_Set_Ott_Nov_Dic".split("_"),weekdays:"Domenica_Lunedi_Martedi_Mercoledi_Giovedi_Venerdi_Sabato".split("_"),weekdaysShort:"Dom_Lun_Mar_Mer_Gio_Ven_Sab".split("_"),longDateFormat:{L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s fa",s:"secondi",m:"un minuto",mm:"%d minuti",h:"un ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("it",a)}(),function(){var a={months:"Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),monthsShort:"Jan_Feb_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdays:"Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),weekdaysShort:"Dom_Seg_Ter_Qua_Qui_Sex_Sáb".split("_"),longDateFormat:{L:"DD/MM/YYYY",LL:"D \\de MMMM \\de YYYY",LLL:"D \\de MMMM \\de YYYY HH:mm",LLLL:"dddd, D \\de MMMM \\de YYYY HH:mm"},relativeTime:{future:"em %s",past:"%s atrás",s:"segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"},ordinal:function(a){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("pt",a)}(),function(){var a={months:"Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre".split("_"),monthsShort:"Ene._Feb._Mar._Abr._May._Jun._Jul._Ago._Sep._Oct._Nov._Dic.".split("_"),weekdays:"Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado".split("_"),weekdaysShort:"Dom._Lun._Mar._Mié._Jue._Vie._Sáb.".split("_"),longDateFormat:{L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(a){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("es",a)}(),function(){var a={months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mar._apr._mei._jun._jul._aug._sep._okt._nov._dec.".split("_"),weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),longDateFormat:{L:"DD-MM-YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"één minuutje",mm:"%d minuten",h:"één uur",hh:"%d uren",d:"één dag",dd:"%d dagen",M:"één maand",MM:"%d maanden",y:"één jaar",yy:"%d jaren"},ordinal:function(a){return a===1||a===8||a>=20?"ste":"de"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("nl",a)}(),function(){var a={months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"),weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),longDateFormat:{L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm U\\hr",LLLL:"dddd, D. MMMM YYYY HH:mm U\\hr"},relativeTime:{future:"in %s",past:"vor %s",s:"ein paar Sekunden",m:"einer Minute",mm:"%d Minuten",h:"einer Stunde",hh:"%d Stunden",d:"einem Tag",dd:"%d Tagen",M:"einem Monat",MM:"%d Monaten",y:"einem Jahr",yy:"%d Jahren"},ordinal:function(a){return"."}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("de",a)}(),function(){var a={months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),longDateFormat:{L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"om %s",past:"för %s sen",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"e":b===1?"a":b===2?"a":b===3?"e":"e"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("sv",a)}(),function(){var a={months:"styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"nie_pon_wt_śr_czw_pt_sb".split("_"),longDateFormat:{L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",m:"minutę",mm:"%d minut",h:"godzinę",hh:"%d godzin",d:"1 dzień",dd:"%d dni",M:"miesiąc",MM:"%d miesięcy",y:"rok",yy:"%d lat"},ordinal:function(a){return"."}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("pl",a)}() \ No newline at end of file diff --git a/lang/de.min.js b/lang/min/de.min.js similarity index 100% rename from lang/de.min.js rename to lang/min/de.min.js diff --git a/lang/es.min.js b/lang/min/es.min.js similarity index 100% rename from lang/es.min.js rename to lang/min/es.min.js diff --git a/lang/fr.min.js b/lang/min/fr.min.js similarity index 100% rename from lang/fr.min.js rename to lang/min/fr.min.js diff --git a/lang/it.min.js b/lang/min/it.min.js similarity index 100% rename from lang/it.min.js rename to lang/min/it.min.js diff --git a/lang/nl.min.js b/lang/min/nl.min.js similarity index 100% rename from lang/nl.min.js rename to lang/min/nl.min.js diff --git a/lang/min/pl.min.js b/lang/min/pl.min.js new file mode 100644 index 000000000..3706c36b4 --- /dev/null +++ b/lang/min/pl.min.js @@ -0,0 +1 @@ +(function(){var a={months:"styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"nie_pon_wt_śr_czw_pt_sb".split("_"),longDateFormat:{L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",m:"minutę",mm:"%d minut",h:"godzinę",hh:"%d godzin",d:"1 dzień",dd:"%d dni",M:"miesiąc",MM:"%d miesięcy",y:"rok",yy:"%d lat"},ordinal:function(a){return"."}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("pl",a)})() \ No newline at end of file diff --git a/lang/pt.min.js b/lang/min/pt.min.js similarity index 100% rename from lang/pt.min.js rename to lang/min/pt.min.js diff --git a/lang/min/sv.min.js b/lang/min/sv.min.js new file mode 100644 index 000000000..444529d9b --- /dev/null +++ b/lang/min/sv.min.js @@ -0,0 +1 @@ +(function(){var a={months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),longDateFormat:{L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"om %s",past:"för %s sen",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"e":b===1?"a":b===2?"a":b===3?"e":"e"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("sv",a)})() \ No newline at end of file diff --git a/lang/pl.js b/lang/pl.js new file mode 100644 index 000000000..5c2b7e7f7 --- /dev/null +++ b/lang/pl.js @@ -0,0 +1,41 @@ +(function () { + var lang = { + months : "styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"), + monthsShort : "sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"), + weekdays : "niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"), + weekdaysShort : "nie_pon_wt_śr_czw_pt_sb".split("_"), + longDateFormat : { + L : "DD-MM-YYYY", + LL : "D MMMM YYYY", + LLL : "D MMMM YYYY HH:mm", + LLLL : "dddd, D MMMM YYYY HH:mm" + }, + relativeTime : { + future : "za %s", + past : "%s temu", + s : "kilka sekund", + m : "minutę", + mm : "%d minut", + h : "godzinę", + hh : "%d godzin", + d : "1 dzień", + dd : "%d dni", + M : "miesiąc", + MM : "%d miesięcy", + y : "rok", + yy : "%d lat" + }, + ordinal : function (number) { + return '.'; + } + }; + + // Node + if (typeof module !== 'undefined') { + module.exports = lang; + } + // Browser + if (typeof window !== 'undefined' && this.moment && this.moment.lang) { + this.moment.lang('pl', lang); + } +}()); diff --git a/lang/sv.js b/lang/sv.js new file mode 100644 index 000000000..c79e8fb30 --- /dev/null +++ b/lang/sv.js @@ -0,0 +1,45 @@ +(function () { + var lang = { + months : "januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"), + monthsShort : "jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"), + weekdays : "söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"), + weekdaysShort : "sön_mån_tis_ons_tor_fre_lör".split("_"), + longDateFormat : { + L : "YYYY-MM-DD", + LL : "D MMMM YYYY", + LLL : "D MMMM YYYY HH:mm", + LLLL : "dddd D MMMM YYYY HH:mm" + }, + relativeTime : { + future : "om %s", + past : "för %s sen", + s : "några sekunder", + m : "en minut", + mm : "%d minuter", + h : "en timme", + hh : "%d timmar", + d : "en dag", + dd : "%d dagar", + M : "en månad", + MM : "%d månader", + y : "ett år", + yy : "%d år" + }, + ordinal : function (number) { + var b = number % 10; + return (~~ (number % 100 / 10) === 1) ? 'e' : + (b === 1) ? 'a' : + (b === 2) ? 'a' : + (b === 3) ? 'e' : 'e'; + } + }; + + // Node + if (typeof module !== 'undefined') { + module.exports = lang; + } + // Browser + if (typeof window !== 'undefined' && this.moment && this.moment.lang) { + this.moment.lang('sv', lang); + } +}()); diff --git a/lang/test/pl.js b/lang/test/pl.js new file mode 100644 index 000000000..a5dd5955e --- /dev/null +++ b/lang/test/pl.js @@ -0,0 +1,157 @@ + +/************************************************** + Polish + *************************************************/ + +module("lang:pl"); + +test("format", 18, function() { + moment.lang('pl'); + var a = [ + ['dddd, MMMM Do YYYY, h:mm:ss a', 'niedziela, luty 14. 2010, 3:25:50 pm'], + ['ddd, hA', 'nie, 3PM'], + ['M Mo MM MMMM MMM', '2 2. 02 luty lut'], + ['YYYY YY', '2010 10'], + ['D Do DD', '14 14. 14'], + ['d do dddd ddd', '0 0. niedziela nie'], + ['DDD DDDo DDDD', '45 45. 045'], + ['w wo ww', '8 8. 08'], + ['h hh', '3 03'], + ['H HH', '15 15'], + ['m mm', '25 25'], + ['s ss', '50 50'], + ['a A', 'pm PM'], + ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45. day of the year'], + ['L', '14-02-2010'], + ['LL', '14 luty 2010'], + ['LLL', '14 luty 2010 15:25'], + ['LLLL', 'niedziela, 14 luty 2010 15:25'] + ], + b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), + i; + for (i = 0; i < a.length; i++) { + equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); + } +}); + +test("format YY", 1, function() { + var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125)); + equal(b.format('YY'), '09', 'YY ---> 09'); +}); + +test("format timezone", 2, function() { + var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)); + ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"'); + ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"'); +}); + +test("format ordinal", 31, function() { + moment.lang('pl'); + equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.'); + equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.'); + equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.'); + equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.'); + equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.'); + equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.'); + equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.'); + equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.'); + equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.'); + equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.'); + + equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.'); + equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.'); + equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.'); + equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.'); + equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.'); + equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.'); + equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.'); + equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.'); + equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.'); + equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.'); + + equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.'); + equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.'); + equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.'); + equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.'); + equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.'); + equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.'); + equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.'); + equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.'); + equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.'); + equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.'); + + equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.'); +}); + +test("format month", 12, function() { + moment.lang('pl'); + var expected = 'styczeń sty_luty lut_marzec mar_kwiecień kwi_maj maj_czerwiec cze_lipiec lip_sierpień sie_wrzesień wrz_październik paź_listopad lis_grudzień gru'.split("_"); + var i; + for (i = 0; i < expected.length; i++) { + equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]); + } +}); + +test("format week", 7, function() { + moment.lang('pl'); + var expected = 'niedziela nie_poniedziałek pon_wtorek wt_środa śr_czwartek czw_piątek pt_sobota sb'.split("_"); + var i; + for (i = 0; i < expected.length; i++) { + equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]); + } +}); + +test("from", 30, function() { + moment.lang('pl'); + var start = moment([2007, 1, 28]); + equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "kilka sekund", "44 seconds = a few seconds"); + equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minutę", "45 seconds = a minute"); + equal(start.from(moment([2007, 1, 28]).add({s:89}), true), "minutę", "89 seconds = a minute"); + equal(start.from(moment([2007, 1, 28]).add({s:90}), true), "2 minut", "90 seconds = 2 minutes"); + equal(start.from(moment([2007, 1, 28]).add({m:44}), true), "44 minut", "44 minutes = 44 minutes"); + equal(start.from(moment([2007, 1, 28]).add({m:45}), true), "godzinę", "45 minutes = an hour"); + equal(start.from(moment([2007, 1, 28]).add({m:89}), true), "godzinę", "89 minutes = an hour"); + equal(start.from(moment([2007, 1, 28]).add({m:90}), true), "2 godzin", "90 minutes = 2 hours"); + equal(start.from(moment([2007, 1, 28]).add({h:5}), true), "5 godzin", "5 hours = 5 hours"); + equal(start.from(moment([2007, 1, 28]).add({h:21}), true), "21 godzin", "21 hours = 21 hours"); + equal(start.from(moment([2007, 1, 28]).add({h:22}), true), "1 dzień", "22 hours = a day"); + equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "1 dzień", "35 hours = a day"); + equal(start.from(moment([2007, 1, 28]).add({h:36}), true), "2 dni", "36 hours = 2 days"); + equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "1 dzień", "1 day = a day"); + equal(start.from(moment([2007, 1, 28]).add({d:5}), true), "5 dni", "5 days = 5 days"); + equal(start.from(moment([2007, 1, 28]).add({d:25}), true), "25 dni", "25 days = 25 days"); + equal(start.from(moment([2007, 1, 28]).add({d:26}), true), "miesiąc", "26 days = a month"); + equal(start.from(moment([2007, 1, 28]).add({d:30}), true), "miesiąc", "30 days = a month"); + equal(start.from(moment([2007, 1, 28]).add({d:45}), true), "miesiąc", "45 days = a month"); + equal(start.from(moment([2007, 1, 28]).add({d:46}), true), "2 miesięcy", "46 days = 2 months"); + equal(start.from(moment([2007, 1, 28]).add({d:74}), true), "2 miesięcy", "75 days = 2 months"); + equal(start.from(moment([2007, 1, 28]).add({d:76}), true), "3 miesięcy", "76 days = 3 months"); + equal(start.from(moment([2007, 1, 28]).add({M:1}), true), "miesiąc", "1 month = a month"); + equal(start.from(moment([2007, 1, 28]).add({M:5}), true), "5 miesięcy", "5 months = 5 months"); + equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 miesięcy", "344 days = 11 months"); + equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "rok", "345 days = a year"); + equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "rok", "547 days = a year"); + equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 lat", "548 days = 2 years"); + equal(start.from(moment([2007, 1, 28]).add({y:1}), true), "rok", "1 year = a year"); + equal(start.from(moment([2007, 1, 28]).add({y:5}), true), "5 lat", "5 years = 5 years"); +}); + +test("suffix", 2, function() { + moment.lang('pl'); + equal(moment(30000).from(0), "za kilka sekund", "prefix"); + equal(moment(0).from(30000), "kilka sekund temu", "suffix"); +}); + + +test("now from now", 1, function() { + moment.lang('pl'); + equal(moment().fromNow(), "kilka sekund temu", "now from now should display as in the past"); +}); + + +test("fromNow", 2, function() { + moment.lang('pl'); + equal(moment().add({s:30}).fromNow(), "za kilka sekund", "in a few seconds"); + equal(moment().add({d:5}).fromNow(), "za 5 dni", "in 5 days"); +}); + diff --git a/lang/test/sv.js b/lang/test/sv.js new file mode 100644 index 000000000..c2771ac48 --- /dev/null +++ b/lang/test/sv.js @@ -0,0 +1,157 @@ + +/************************************************** + English + *************************************************/ + +module("lang:sv"); + +test("format", 18, function() { + moment.lang('sv'); + var a = [ + ['dddd, MMMM Do YYYY, h:mm:ss a', 'söndag, februari 14e 2010, 3:25:50 pm'], + ['ddd, hA', 'sön, 3PM'], + ['M Mo MM MMMM MMM', '2 2a 02 februari feb'], + ['YYYY YY', '2010 10'], + ['D Do DD', '14 14e 14'], + ['d do dddd ddd', '0 0e söndag sön'], + ['DDD DDDo DDDD', '45 45e 045'], + ['w wo ww', '8 8e 08'], + ['h hh', '3 03'], + ['H HH', '15 15'], + ['m mm', '25 25'], + ['s ss', '50 50'], + ['a A', 'pm PM'], + ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45e day of the year'], + ['L', '2010-02-14'], + ['LL', '14 februari 2010'], + ['LLL', '14 februari 2010 15:25'], + ['LLLL', 'söndag 14 februari 2010 15:25'] + ], + b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), + i; + for (i = 0; i < a.length; i++) { + equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); + } +}); + +test("format YY", 1, function() { + var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125)); + equal(b.format('YY'), '09', 'YY ---> 09'); +}); + +test("format timezone", 2, function() { + var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)); + ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"'); + ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"'); +}); + +test("format ordinal", 31, function() { + moment.lang('sv'); + equal(moment([2011, 0, 1]).format('DDDo'), '1a', '1a'); + equal(moment([2011, 0, 2]).format('DDDo'), '2a', '2a'); + equal(moment([2011, 0, 3]).format('DDDo'), '3e', '3e'); + equal(moment([2011, 0, 4]).format('DDDo'), '4e', '4e'); + equal(moment([2011, 0, 5]).format('DDDo'), '5e', '5e'); + equal(moment([2011, 0, 6]).format('DDDo'), '6e', '6e'); + equal(moment([2011, 0, 7]).format('DDDo'), '7e', '7e'); + equal(moment([2011, 0, 8]).format('DDDo'), '8e', '8e'); + equal(moment([2011, 0, 9]).format('DDDo'), '9e', '9e'); + equal(moment([2011, 0, 10]).format('DDDo'), '10e', '10e'); + + equal(moment([2011, 0, 11]).format('DDDo'), '11e', '11e'); + equal(moment([2011, 0, 12]).format('DDDo'), '12e', '12e'); + equal(moment([2011, 0, 13]).format('DDDo'), '13e', '13e'); + equal(moment([2011, 0, 14]).format('DDDo'), '14e', '14e'); + equal(moment([2011, 0, 15]).format('DDDo'), '15e', '15e'); + equal(moment([2011, 0, 16]).format('DDDo'), '16e', '16e'); + equal(moment([2011, 0, 17]).format('DDDo'), '17e', '17e'); + equal(moment([2011, 0, 18]).format('DDDo'), '18e', '18e'); + equal(moment([2011, 0, 19]).format('DDDo'), '19e', '19e'); + equal(moment([2011, 0, 20]).format('DDDo'), '20e', '20e'); + + equal(moment([2011, 0, 21]).format('DDDo'), '21a', '21a'); + equal(moment([2011, 0, 22]).format('DDDo'), '22a', '22a'); + equal(moment([2011, 0, 23]).format('DDDo'), '23e', '23e'); + equal(moment([2011, 0, 24]).format('DDDo'), '24e', '24e'); + equal(moment([2011, 0, 25]).format('DDDo'), '25e', '25e'); + equal(moment([2011, 0, 26]).format('DDDo'), '26e', '26e'); + equal(moment([2011, 0, 27]).format('DDDo'), '27e', '27e'); + equal(moment([2011, 0, 28]).format('DDDo'), '28e', '28e'); + equal(moment([2011, 0, 29]).format('DDDo'), '29e', '29e'); + equal(moment([2011, 0, 30]).format('DDDo'), '30e', '30e'); + + equal(moment([2011, 0, 31]).format('DDDo'), '31a', '31a'); +}); + +test("format month", 12, function() { + moment.lang('sv'); + var expected = 'januari jan_februari feb_mars mar_april apr_maj maj_juni jun_juli jul_augusti aug_september sep_oktober okt_november nov_december dec'.split("_"); + var i; + for (i = 0; i < expected.length; i++) { + equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]); + } +}); + +test("format week", 7, function() { + moment.lang('sv'); + var expected = 'söndag sön_måndag mån_tisdag tis_onsdag ons_torsdag tor_fredag fre_lördag lör'.split("_"); + var i; + for (i = 0; i < expected.length; i++) { + equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]); + } +}); + +test("from", 30, function() { + moment.lang('sv'); + var start = moment([2007, 1, 28]); + equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "några sekunder", "44 sekunder = a few seconds"); + equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "en minut", "45 seconds = a minute"); + equal(start.from(moment([2007, 1, 28]).add({s:89}), true), "en minut", "89 seconds = a minute"); + equal(start.from(moment([2007, 1, 28]).add({s:90}), true), "2 minuter", "90 seconds = 2 minutes"); + equal(start.from(moment([2007, 1, 28]).add({m:44}), true), "44 minuter", "44 minutes = 44 minutes"); + equal(start.from(moment([2007, 1, 28]).add({m:45}), true), "en timme", "45 minutes = an hour"); + equal(start.from(moment([2007, 1, 28]).add({m:89}), true), "en timme", "89 minutes = an hour"); + equal(start.from(moment([2007, 1, 28]).add({m:90}), true), "2 timmar", "90 minutes = 2 hours"); + equal(start.from(moment([2007, 1, 28]).add({h:5}), true), "5 timmar", "5 hours = 5 hours"); + equal(start.from(moment([2007, 1, 28]).add({h:21}), true), "21 timmar", "21 hours = 21 hours"); + equal(start.from(moment([2007, 1, 28]).add({h:22}), true), "en dag", "22 hours = a day"); + equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "en dag", "35 hours = a day"); + equal(start.from(moment([2007, 1, 28]).add({h:36}), true), "2 dagar", "36 hours = 2 days"); + equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "en dag", "1 day = a day"); + equal(start.from(moment([2007, 1, 28]).add({d:5}), true), "5 dagar", "5 days = 5 days"); + equal(start.from(moment([2007, 1, 28]).add({d:25}), true), "25 dagar", "25 days = 25 days"); + equal(start.from(moment([2007, 1, 28]).add({d:26}), true), "en månad", "26 days = a month"); + equal(start.from(moment([2007, 1, 28]).add({d:30}), true), "en månad", "30 days = a month"); + equal(start.from(moment([2007, 1, 28]).add({d:45}), true), "en månad", "45 days = a month"); + equal(start.from(moment([2007, 1, 28]).add({d:46}), true), "2 månader", "46 days = 2 months"); + equal(start.from(moment([2007, 1, 28]).add({d:74}), true), "2 månader", "75 days = 2 months"); + equal(start.from(moment([2007, 1, 28]).add({d:76}), true), "3 månader", "76 days = 3 months"); + equal(start.from(moment([2007, 1, 28]).add({M:1}), true), "en månad", "1 month = a month"); + equal(start.from(moment([2007, 1, 28]).add({M:5}), true), "5 månader", "5 months = 5 months"); + equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 månader", "344 days = 11 months"); + equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "ett år", "345 days = a year"); + equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "ett år", "547 days = a year"); + equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 år", "548 days = 2 years"); + equal(start.from(moment([2007, 1, 28]).add({y:1}), true), "ett år", "1 year = a year"); + equal(start.from(moment([2007, 1, 28]).add({y:5}), true), "5 år", "5 years = 5 years"); +}); + +test("suffix", 2, function() { + moment.lang('sv'); + equal(moment(30000).from(0), "om några sekunder", "prefix"); + equal(moment(0).from(30000), "för några sekunder sen", "suffix"); +}); + + +test("now from now", 1, function() { + moment.lang('sv'); + equal(moment().fromNow(), "för några sekunder sen", "now from now should display as in the past"); +}); + + +test("fromNow", 2, function() { + moment.lang('sv'); + equal(moment().add({s:30}).fromNow(), "om några sekunder", "in a few seconds"); + equal(moment().add({d:5}).fromNow(), "om 5 dagar", "in 5 days"); +}); + diff --git a/site/docs/index.html b/site/docs/index.html index dd4d53038..f29fa7b8d 100644 --- a/site/docs/index.html +++ b/site/docs/index.html @@ -1,4 +1,4 @@ -Moment.js Documentation

Moment.js Documentation

A lightweight javascript date library for parsing, manipulating, and formatting dates.

Where to get it

Github

Production Version 1.1.12.5kb minified & gzippedDevelopment Version 1.1.117.8kb full source + comments

You can also clone the project with Git by running:

git clone git://github.com/timrwood/moment

npm

npm install moment

Where to use it

Moment was designed to work in both the browser and in NodeJS. All code will work in both environments. All unit tests are run in both environments.

In NodeJS

var moment = require('moment');
+Moment.js Documentation

Moment.js Documentation

A lightweight javascript date library for parsing, manipulating, and formatting dates.

Where to get it

Github

Production Version 1.1.12.5kb minified & gzippedDevelopment Version 1.1.117.8kb full source + comments

You can also clone the project with Git by running:

git clone git://github.com/timrwood/moment

npm

npm install moment

Where to use it

Moment was designed to work in both the browser and in NodeJS. All code will work in both environments. All unit tests are run in both environments.

In NodeJS

var moment = require('moment');
 moment().add('hours', 1).fromNow(); // "1 hour ago"
 

In the browser

<script src="moment.min.js"></script>
 moment().add('hours', 1).fromNow(); // "1 hour ago"
@@ -181,7 +181,7 @@ moment(1316116057189).fromNow(); // il y a une heure
         (b === 2) ? 'nd' : 
         (b === 3) ? 'rd' : 'th';
 };
-

For more information on ordinal numbers, see wikipedia