Best JavaScript code snippet using wpt
bootstrap-table-locale-all.js
Source:bootstrap-table-locale-all.js
1/**2 * Bootstrap Table Afrikaans translation3 * Author: Phillip Kruger <phillip.kruger@gmail.com>4 */5(function ($) {6 'use strict';7 $.fn.bootstrapTable.locales['af-ZA'] = {8 formatLoadingMessage: function () {9 return 'Besig om te laai, wag asseblief ...';10 },11 formatRecordsPerPage: function (pageNumber) {12 return pageNumber + ' rekords per bladsy';13 },14 formatShowingRows: function (pageFrom, pageTo, totalRows) {15 return 'Resultate ' + pageFrom + ' tot ' + pageTo + ' van ' + totalRows + ' rye';16 },17 formatSearch: function () {18 return 'Soek';19 },20 formatNoMatches: function () {21 return 'Geen rekords gevind nie';22 },23 formatPaginationSwitch: function () {24 return 'Wys/verberg bladsy nummering';25 },26 formatRefresh: function () {27 return 'Herlaai';28 },29 formatToggle: function () {30 return 'Wissel';31 },32 formatColumns: function () {33 return 'Kolomme';34 }35 };36 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['af-ZA']);37})(jQuery);38/**39 * Bootstrap Table English translation40 * Author: Zhixin Wen<wenzhixin2010@gmail.com>41 */42(function ($) {43 'use strict';44 $.fn.bootstrapTable.locales['ar-SA'] = {45 formatLoadingMessage: function () {46 return 'جار٠اÙتØÙ
ÙÙ, Ùرج٠اÙØ¥Ùتظار...';47 },48 formatRecordsPerPage: function (pageNumber) {49 return pageNumber + ' سج٠ÙÙ٠صÙØØ©';50 },51 formatShowingRows: function (pageFrom, pageTo, totalRows) {52 return 'اÙظاÙر ' + pageFrom + ' Ø¥ÙÙ ' + pageTo + ' Ù
Ù ' + totalRows + ' سجÙ';53 },54 formatSearch: function () {55 return 'بØØ«';56 },57 formatNoMatches: function () {58 return 'Ùا تÙجد Ùتائج Ù
طابÙØ© ÙÙبØØ«';59 },60 formatPaginationSwitch: function () {61 return 'إخÙاء\إظÙار ترÙÙÙ
اÙصÙØات';62 },63 formatRefresh: function () {64 return 'تØدÙØ«';65 },66 formatToggle: function () {67 return 'تغÙÙر';68 },69 formatColumns: function () {70 return 'أعÙ
دة';71 }72 };73 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ar-SA']);74})(jQuery);75/**76 * Bootstrap Table Catalan translation77 * Authors: Marc Pina<iwalkalone69@gmail.com>78 * Claudi Martinez<claudix.kernel@gmail.com>79 */80(function ($) {81 'use strict';82 $.fn.bootstrapTable.locales['ca-ES'] = {83 formatLoadingMessage: function () {84 return 'Espereu, si us plau...';85 },86 formatRecordsPerPage: function (pageNumber) {87 return pageNumber + ' resultats per pà gina';88 },89 formatShowingRows: function (pageFrom, pageTo, totalRows) {90 return 'Mostrant de ' + pageFrom + ' fins ' + pageTo + ' - total ' + totalRows + ' resultats';91 },92 formatSearch: function () {93 return 'Cerca';94 },95 formatNoMatches: function () {96 return 'No s\'han trobat resultats';97 },98 formatPaginationSwitch: function () {99 return 'Amaga/Mostra paginació';100 },101 formatRefresh: function () {102 return 'Refresca';103 },104 formatToggle: function () {105 return 'Alterna formatació';106 },107 formatColumns: function () {108 return 'Columnes';109 },110 formatAllRows: function () {111 return 'Tots';112 }113 };114 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ca-ES']);115})(jQuery);116/**117 * Bootstrap Table Czech translation118 * Author: Lukas Kral (monarcha@seznam.cz)119 * Author: Jakub Svestka <svestka1999@gmail.com>120 */121(function ($) {122 'use strict';123 $.fn.bootstrapTable.locales['cs-CZ'] = {124 formatLoadingMessage: function () {125 return 'Äekejte, prosÃm...';126 },127 formatRecordsPerPage: function (pageNumber) {128 return pageNumber + ' položek na stránku';129 },130 formatShowingRows: function (pageFrom, pageTo, totalRows) {131 return 'Zobrazena ' + pageFrom + '. - ' + pageTo + '. položka z celkových ' + totalRows;132 },133 formatSearch: function () {134 return 'VyhledávánÃ';135 },136 formatNoMatches: function () {137 return 'Nenalezena žádná vyhovujÃcà položka';138 },139 formatPaginationSwitch: function () {140 return 'Skrýt/Zobrazit stránkovánÃ';141 },142 formatRefresh: function () {143 return 'Aktualizovat';144 },145 formatToggle: function () {146 return 'PÅepni';147 },148 formatColumns: function () {149 return 'Sloupce';150 },151 formatAllRows: function () {152 return 'VÅ¡e';153 }154 };155 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['cs-CZ']);156})(jQuery);157/**158 * Bootstrap Table danish translation159 * Author: Your Name Jan Borup Coyle, github@coyle.dk160 */161(function ($) {162 'use strict';163 $.fn.bootstrapTable.locales['da-DK'] = {164 formatLoadingMessage: function () {165 return 'Indlæser, vent venligst...';166 },167 formatRecordsPerPage: function (pageNumber) {168 return pageNumber + ' poster pr side';169 },170 formatShowingRows: function (pageFrom, pageTo, totalRows) {171 return 'Viser ' + pageFrom + ' til ' + pageTo + ' af ' + totalRows + ' rækker';172 },173 formatSearch: function () {174 return 'Søg';175 },176 formatNoMatches: function () {177 return 'Ingen poster fundet';178 },179 formatRefresh: function () {180 return 'Opdater';181 },182 formatToggle: function () {183 return 'Skift';184 },185 formatColumns: function () {186 return 'Kolonner';187 }188 };189 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['da-DK']);190})(jQuery);191/**192* Bootstrap Table German translation193* Author: Paul Mohr - Sopamo<p.mohr@sopamo.de>194*/195(function ($) {196 'use strict';197 $.fn.bootstrapTable.locales['de-DE'] = {198 formatLoadingMessage: function () {199 return 'Lade, bitte warten...';200 },201 formatRecordsPerPage: function (pageNumber) {202 return pageNumber + ' Einträge pro Seite.';203 },204 formatShowingRows: function (pageFrom, pageTo, totalRows) {205 return 'Zeige Zeile ' + pageFrom + ' bis ' + pageTo + ' von ' + totalRows + ' Zeile' + ((totalRows > 1) ? "n" : "")+".";206 },207 formatDetailPagination: function (totalRows) {208 return 'Zeige ' + totalRows + ' Zeile' + ((totalRows > 1) ? "n" : "")+".";209 },210 formatSearch: function () {211 return 'Suchen ...';212 },213 formatNoMatches: function () {214 return 'Keine passenden Ergebnisse gefunden.';215 },216 formatRefresh: function () {217 return 'Neu laden';218 },219 formatToggle: function () {220 return 'Umschalten';221 },222 formatColumns: function () {223 return 'Spalten';224 },225 formatAllRows: function () {226 return 'Alle';227 }228 };229 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['de-DE']);230})(jQuery);231/**232 * Bootstrap Table Greek translation233 * Author: giannisdallas234 */235(function ($) {236 'use strict';237 $.fn.bootstrapTable.locales['el-GR'] = {238 formatLoadingMessage: function () {239 return 'ΦοÏÏÏνει, ÏαÏÎ±ÎºÎ±Î»Ï ÏεÏιμÎνεÏε...';240 },241 formatRecordsPerPage: function (pageNumber) {242 return pageNumber + ' αÏοÏελÎÏμαÏα ανά Ïελίδα';243 },244 formatShowingRows: function (pageFrom, pageTo, totalRows) {245 return 'ÎμÏανίζονÏαι αÏÏ Ïην ' + pageFrom + ' ÏÏ Ïην ' + pageTo + ' αÏÏ ÏÏνολο ' + totalRows + ' ÏειÏÏν';246 },247 formatSearch: function () {248 return 'ÎναζηÏήÏÏε';249 },250 formatNoMatches: function () {251 return 'Îεν βÏÎθηκαν αÏοÏελÎÏμαÏα';252 }253 };254 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['el-GR']);255})(jQuery);256/**257 * Bootstrap Table English translation258 * Author: Zhixin Wen<wenzhixin2010@gmail.com>259 */260(function ($) {261 'use strict';262 $.fn.bootstrapTable.locales['en-US'] = {263 formatLoadingMessage: function () {264 return 'Loading, please wait...';265 },266 formatRecordsPerPage: function (pageNumber) {267 return pageNumber + ' rows per page';268 },269 formatShowingRows: function (pageFrom, pageTo, totalRows) {270 return 'Showing ' + pageFrom + ' to ' + pageTo + ' of ' + totalRows + ' rows';271 },272 formatSearch: function () {273 return 'Search';274 },275 formatNoMatches: function () {276 return 'No matching records found';277 },278 formatPaginationSwitch: function () {279 return 'Hide/Show pagination';280 },281 formatRefresh: function () {282 return 'Refresh';283 },284 formatToggle: function () {285 return 'Toggle';286 },287 formatColumns: function () {288 return 'Columns';289 },290 formatAllRows: function () {291 return 'All';292 },293 formatExport: function () {294 return 'Export data';295 },296 formatClearFilters: function () {297 return 'Clear filters';298 }299 };300 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['en-US']);301})(jQuery);302/**303 * Bootstrap Table Spanish (Argentina) translation304 * Author: Felix Vera (felix.vera@gmail.com)305 */306(function ($) {307 'use strict';308 $.fn.bootstrapTable.locales['es-AR'] = {309 formatLoadingMessage: function () {310 return 'Cargando, espere por favor...';311 },312 formatRecordsPerPage: function (pageNumber) {313 return pageNumber + ' registros por página';314 },315 formatShowingRows: function (pageFrom, pageTo, totalRows) {316 return 'Mostrando ' + pageFrom + ' a ' + pageTo + ' de ' + totalRows + ' filas';317 },318 formatSearch: function () {319 return 'Buscar';320 },321 formatNoMatches: function () {322 return 'No se encontraron registros';323 },324 formatAllRows: function () {325 return 'Todo';326 }327 };328 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['es-AR']);329})(jQuery);330/**331 * Traducción de librerÃa Bootstrap Table a Español (Chile)332 * @author Brian Ãlvarez Azócar333 * email brianalvarezazocar@gmail.com334 */335(function($) {336 'use strict';337 $.fn.bootstrapTable.locales['es-CL'] = {338 formatLoadingMessage: function() {339 return 'Cargando, espere por favor...';340 },341 formatRecordsPerPage: function(pageNumber) {342 return pageNumber + ' filas por p\u00E1gina';343 },344 formatShowingRows: function(pageFrom, pageTo, totalRows) {345 return 'Mostrando ' + pageFrom + ' a ' + pageTo + ' de ' + totalRows + ' filas';346 },347 formatSearch: function() {348 return 'Buscar';349 },350 formatNoMatches: function() {351 return 'No se encontraron registros';352 },353 formatPaginationSwitch: function() {354 return 'Ocultar/Mostrar paginaci\u00F3n';355 },356 formatRefresh: function() {357 return 'Refrescar';358 },359 formatToggle: function() {360 return 'Cambiar';361 },362 formatColumns: function() {363 return 'Columnas';364 },365 formatAllRows: function() {366 return 'Todo';367 }368 };369 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['es-CL']);370})(jQuery);371/**372 * Bootstrap Table Spanish (Costa Rica) translation373 * Author: Dennis Hernández (http://djhvscf.github.io/Blog/)374 */375(function ($) {376 'use strict';377 $.fn.bootstrapTable.locales['es-CR'] = {378 formatLoadingMessage: function () {379 return 'Cargando, por favor espere...';380 },381 formatRecordsPerPage: function (pageNumber) {382 return pageNumber + ' registros por página';383 },384 formatShowingRows: function (pageFrom, pageTo, totalRows) {385 return 'Mostrando de ' + pageFrom + ' a ' + pageTo + ' registros de ' + totalRows + ' registros en total';386 },387 formatSearch: function () {388 return 'Buscar';389 },390 formatNoMatches: function () {391 return 'No se encontraron registros';392 },393 formatRefresh: function () {394 return 'Refrescar';395 },396 formatToggle: function () {397 return 'Alternar';398 },399 formatColumns: function () {400 return 'Columnas';401 },402 formatAllRows: function () {403 return 'Todo';404 }405 };406 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['es-CR']);407})(jQuery);408/**409 * Bootstrap Table Spanish Spain translation410 * Author: Marc Pina<iwalkalone69@gmail.com>411 */412(function ($) {413 'use strict';414 $.fn.bootstrapTable.locales['es-ES'] = {415 formatLoadingMessage: function () {416 return 'Por favor espere...';417 },418 formatRecordsPerPage: function (pageNumber) {419 return pageNumber + ' resultados por página';420 },421 formatShowingRows: function (pageFrom, pageTo, totalRows) {422 return 'Mostrando desde ' + pageFrom + ' hasta ' + pageTo + ' - En total ' + totalRows + ' resultados';423 },424 formatSearch: function () {425 return 'Buscar';426 },427 formatNoMatches: function () {428 return 'No se encontraron resultados';429 },430 formatPaginationSwitch: function () {431 return 'Ocultar/Mostrar paginación';432 },433 formatRefresh: function () {434 return 'Refrescar';435 },436 formatToggle: function () {437 return 'Ocultar/Mostrar';438 },439 formatColumns: function () {440 return 'Columnas';441 },442 formatAllRows: function () {443 return 'Todos';444 }445 };446 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['es-ES']);447})(jQuery);448/**449 * Bootstrap Table Spanish (México) translation (Obtenido de traducción de Argentina)450 * Author: Felix Vera (felix.vera@gmail.com) 451 * Copiado: Mauricio Vera (mauricioa.vera@gmail.com)452 */453(function ($) {454 'use strict';455 $.fn.bootstrapTable.locales['es-MX'] = {456 formatLoadingMessage: function () {457 return 'Cargando, espere por favor...';458 },459 formatRecordsPerPage: function (pageNumber) {460 return pageNumber + ' registros por página';461 },462 formatShowingRows: function (pageFrom, pageTo, totalRows) {463 return 'Mostrando ' + pageFrom + ' a ' + pageTo + ' de ' + totalRows + ' filas';464 },465 formatSearch: function () {466 return 'Buscar';467 },468 formatNoMatches: function () {469 return 'No se encontraron registros';470 },471 formatAllRows: function () {472 return 'Todo';473 }474 };475 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['es-MX']);476})(jQuery);477/**478 * Bootstrap Table Spanish (Nicaragua) translation479 * Author: Dennis Hernández (http://djhvscf.github.io/Blog/)480 */481(function ($) {482 'use strict';483 $.fn.bootstrapTable.locales['es-NI'] = {484 formatLoadingMessage: function () {485 return 'Cargando, por favor espere...';486 },487 formatRecordsPerPage: function (pageNumber) {488 return pageNumber + ' registros por página';489 },490 formatShowingRows: function (pageFrom, pageTo, totalRows) {491 return 'Mostrando de ' + pageFrom + ' a ' + pageTo + ' registros de ' + totalRows + ' registros en total';492 },493 formatSearch: function () {494 return 'Buscar';495 },496 formatNoMatches: function () {497 return 'No se encontraron registros';498 },499 formatRefresh: function () {500 return 'Refrescar';501 },502 formatToggle: function () {503 return 'Alternar';504 },505 formatColumns: function () {506 return 'Columnas';507 },508 formatAllRows: function () {509 return 'Todo';510 }511 };512 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['es-NI']);513})(jQuery);514/**515 * Bootstrap Table Spanish (España) translation516 * Author: Antonio Pérez <anpegar@gmail.com>517 */518 (function ($) {519 'use strict';520 521 $.fn.bootstrapTable.locales['es-SP'] = {522 formatLoadingMessage: function () {523 return 'Cargando, por favor espera...';524 },525 formatRecordsPerPage: function (pageNumber) {526 return pageNumber + ' registros por página.';527 },528 formatShowingRows: function (pageFrom, pageTo, totalRows) {529 return pageFrom + ' - ' + pageTo + ' de ' + totalRows + ' registros.';530 },531 formatSearch: function () {532 return 'Buscar';533 },534 formatNoMatches: function () {535 return 'No se han encontrado registros.';536 },537 formatRefresh: function () {538 return 'Actualizar';539 },540 formatToggle: function () {541 return 'Alternar';542 },543 formatColumns: function () {544 return 'Columnas';545 },546 formatAllRows: function () {547 return 'Todo';548 }549 };550 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['es-SP']);551})(jQuery);552/**553 * Bootstrap Table Estonian translation554 * Author: kristjan@logist.it>555 */556(function ($) {557 'use strict';558 $.fn.bootstrapTable.locales['et-EE'] = {559 formatLoadingMessage: function () {560 return 'Päring käib, palun oota...';561 },562 formatRecordsPerPage: function (pageNumber) {563 return pageNumber + ' rida lehe kohta';564 },565 formatShowingRows: function (pageFrom, pageTo, totalRows) {566 return 'Näitan tulemusi ' + pageFrom + ' kuni ' + pageTo + ' - kokku ' + totalRows + ' tulemust';567 },568 formatSearch: function () {569 return 'Otsi';570 },571 formatNoMatches: function () {572 return 'Päringu tingimustele ei vastanud ühtegi tulemust';573 },574 formatPaginationSwitch: function () {575 return 'Näita/Peida lehtedeks jagamine';576 },577 formatRefresh: function () {578 return 'Värskenda';579 },580 formatToggle: function () {581 return 'Lülita';582 },583 formatColumns: function () {584 return 'Veerud';585 },586 formatAllRows: function () {587 return 'Kõik';588 }589 };590 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['et-EE']);591})(jQuery);592/**593 * Bootstrap Table Persian translation594 * Author: MJ Vakili <mjv.1989@Gmail.com>595 */596(function ($) {597 'use strict';598 $.fn.bootstrapTable.locales['fa-IR'] = {599 formatLoadingMessage: function () {600 return 'در Øا٠بارگذارÛ, ÙØ·Ùا صبر Ú©ÙÛد...';601 },602 formatRecordsPerPage: function (pageNumber) {603 return pageNumber + ' رکÙرد در صÙØÙ';604 },605 formatShowingRows: function (pageFrom, pageTo, totalRows) {606 return 'ÙÙ
اÛØ´ ' + pageFrom + ' تا ' + pageTo + ' از ' + totalRows + ' ردÛÙ';607 },608 formatSearch: function () {609 return 'جستجÙ';610 },611 formatNoMatches: function () {612 return 'رکÙØ±Ø¯Û ÛاÙت Ùشد.';613 },614 formatPaginationSwitch: function () {615 return 'ÙÙ
اÛØ´/Ù
Ø®ÙÛ ØµÙØ٠بÙدÛ';616 },617 formatRefresh: function () {618 return 'ب٠رÙز رساÙÛ';619 },620 formatToggle: function () {621 return 'تغÛÛر ÙÙ
اÛØ´';622 },623 formatColumns: function () {624 return 'سطر Ùا';625 },626 formatAllRows: function () {627 return 'ÙÙ
Ù';628 }629 };630 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['fa-IR']);631})(jQuery);632/**633 * Bootstrap Table French (Belgium) translation634 * Author: Julien Bisconti (julien.bisconti@gmail.com)635 */636(function ($) {637 'use strict';638 $.fn.bootstrapTable.locales['fr-BE'] = {639 formatLoadingMessage: function () {640 return 'Chargement en cours...';641 },642 formatRecordsPerPage: function (pageNumber) {643 return pageNumber + ' entrées par page';644 },645 formatShowingRows: function (pageFrom, pageTo, totalRows) {646 return 'Affiche de' + pageFrom + ' à ' + pageTo + ' sur ' + totalRows + ' lignes';647 },648 formatSearch: function () {649 return 'Recherche';650 },651 formatNoMatches: function () {652 return 'Pas de fichiers trouvés';653 }654 };655 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['fr-BE']);656})(jQuery);657/**658 * Bootstrap Table French (France) translation659 * Author: Dennis Hernández (http://djhvscf.github.io/Blog/)660 * Modification: Tidalf (https://github.com/TidalfFR)661 */662(function ($) {663 'use strict';664 $.fn.bootstrapTable.locales['fr-FR'] = {665 formatLoadingMessage: function () {666 return 'Chargement en cours, patientez, s´il vous plaît ...';667 },668 formatRecordsPerPage: function (pageNumber) {669 return pageNumber + ' lignes par page';670 },671 formatShowingRows: function (pageFrom, pageTo, totalRows) {672 return 'Affichage des lignes ' + pageFrom + ' à ' + pageTo + ' sur ' + totalRows + ' lignes au total';673 },674 formatSearch: function () {675 return 'Rechercher';676 },677 formatNoMatches: function () {678 return 'Aucun résultat trouvé';679 },680 formatRefresh: function () {681 return 'Rafraîchir';682 },683 formatToggle: function () {684 return 'Alterner';685 },686 formatColumns: function () {687 return 'Colonnes';688 },689 formatAllRows: function () {690 return 'Tous';691 }692 };693 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['fr-FR']);694})(jQuery);695/**696 * Bootstrap Table Hebrew translation697 * Author: legshooter698 */699(function ($) {700 'use strict';701 $.fn.bootstrapTable.locales['he-IL'] = {702 formatLoadingMessage: function () {703 return '×××¢×, × × ×××ת××...';704 },705 formatRecordsPerPage: function (pageNumber) {706 return pageNumber + ' ש×ר×ת ××¢×××';707 },708 formatShowingRows: function (pageFrom, pageTo, totalRows) {709 return '×צ×× ' + pageFrom + ' ×¢× ' + pageTo + ' ×-' + totalRows + ' ש×ר×ת';710 },711 formatSearch: function () {712 return '××פ×ש';713 },714 formatNoMatches: function () {715 return '×× × ×צ×× ×¨×©×××ת ת××××ת';716 },717 formatPaginationSwitch: function () {718 return '×סתר/××¦× ×ספ×ר ×פ××';719 },720 formatRefresh: function () {721 return '×¨×¢× ×';722 },723 formatToggle: function () {724 return '××××£ תצ×××';725 },726 formatColumns: function () {727 return '×¢××××ת';728 },729 formatAllRows: function () {730 return '×××';731 }732 };733 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['he-IL']);734})(jQuery);735/**736 * Bootstrap Table Croatian translation737 * Author: Petra Å trbenac (petra.strbenac@gmail.com)738 * Author: Petra Å trbenac (petra.strbenac@gmail.com)739 */740(function ($) {741 'use strict';742 $.fn.bootstrapTable.locales['hr-HR'] = {743 formatLoadingMessage: function () {744 return 'Molimo priÄekajte ...';745 },746 formatRecordsPerPage: function (pageNumber) {747 return pageNumber + ' broj zapisa po stranici';748 },749 formatShowingRows: function (pageFrom, pageTo, totalRows) {750 return 'Prikazujem ' + pageFrom + '. - ' + pageTo + '. od ukupnog broja zapisa ' + totalRows;751 },752 formatSearch: function () {753 return 'Pretraži';754 },755 formatNoMatches: function () {756 return 'Nije pronaÄen niti jedan zapis';757 },758 formatPaginationSwitch: function () {759 return 'Prikaži/sakrij stranice';760 },761 formatRefresh: function () {762 return 'Osvježi';763 },764 formatToggle: function () {765 return 'Promijeni prikaz';766 },767 formatColumns: function () {768 return 'Kolone';769 },770 formatAllRows: function () {771 return 'Sve';772 }773 };774 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['hr-HR']);775})(jQuery);776/**777 * Bootstrap Table Hungarian translation778 * Author: Nagy Gergely <info@nagygergely.eu>779 */780(function ($) {781 'use strict';782 $.fn.bootstrapTable.locales['hu-HU'] = {783 formatLoadingMessage: function () {784 return 'Betöltés, kérem várjon...';785 },786 formatRecordsPerPage: function (pageNumber) {787 return pageNumber + ' rekord per oldal';788 },789 formatShowingRows: function (pageFrom, pageTo, totalRows) {790 return 'MegjelenÃtve ' + pageFrom + ' - ' + pageTo + ' / ' + totalRows + ' összesen';791 },792 formatSearch: function () {793 return 'Keresés';794 },795 formatNoMatches: function () {796 return 'Nincs találat';797 },798 formatPaginationSwitch: function () {799 return 'Lapozó elrejtése/megjelenÃtése';800 },801 formatRefresh: function () {802 return 'FrissÃtés';803 },804 formatToggle: function () {805 return 'Ãsszecsuk/Kinyit';806 },807 formatColumns: function () {808 return 'Oszlopok';809 },810 formatAllRows: function () {811 return 'Ãsszes';812 }813 };814 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['hu-HU']);815})(jQuery);816/**817 * Bootstrap Table Indonesian translation818 * Author: Andre Gardiner<andre@sirdre.com> 819 */820(function ($) {821 'use strict';822 $.fn.bootstrapTable.locales['id-ID'] = {823 formatLoadingMessage: function () {824 return 'Memuat, mohon tunggu...';825 },826 formatRecordsPerPage: function (pageNumber) {827 return pageNumber + ' baris per halaman';828 },829 formatShowingRows: function (pageFrom, pageTo, totalRows) {830 return 'Menampilkan ' + pageFrom + ' sampai ' + pageTo + ' dari ' + totalRows + ' baris';831 }, 832 formatSearch: function () {833 return 'Pencarian';834 },835 formatNoMatches: function () {836 return 'Tidak ditemukan data yang cocok';837 },838 formatPaginationSwitch: function () {839 return 'Sembunyikan/Tampilkan halaman';840 },841 formatRefresh: function () {842 return 'Muat ulang';843 },844 formatToggle: function () {845 return 'Beralih';846 },847 formatColumns: function () {848 return 'kolom';849 },850 formatAllRows: function () {851 return 'Semua';852 },853 formatExport: function () {854 return 'Ekspor data';855 },856 formatClearFilters: function () {857 return 'Bersihkan filter';858 }859 };860 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['id-ID']);861})(jQuery);862/**863 * Bootstrap Table Italian translation864 * Author: Davide Renzi<davide.renzi@gmail.com>865 * Author: Davide Borsatto <davide.borsatto@gmail.com>866 * Author: Alessio Felicioni <alessio.felicioni@gmail.com>867 */868(function ($) {869 'use strict';870 $.fn.bootstrapTable.locales['it-IT'] = {871 formatLoadingMessage: function () {872 return 'Caricamento in corso...';873 },874 formatRecordsPerPage: function (pageNumber) {875 return pageNumber + ' elementi per pagina';876 },877 formatShowingRows: function (pageFrom, pageTo, totalRows) {878 return 'Elementi mostrati da ' + pageFrom + ' a ' + pageTo + ' (Numero totali di elementi ' + totalRows + ')';879 },880 formatSearch: function () {881 return 'Cerca';882 },883 formatNoMatches: function () {884 return 'Nessun elemento trovato';885 },886 formatPaginationSwitch: function () {887 return 'Nascondi/Mostra paginazione';888 },889 formatRefresh: function () {890 return 'Aggiorna';891 },892 formatToggle: function () {893 return 'Attiva/Disattiva';894 },895 formatColumns: function () {896 return 'Colonne';897 },898 formatAllRows: function () {899 return 'Tutto';900 },901 formatExport: function () {902 return 'Esporta dati';903 },904 formatClearFilters: function () {905 return 'Pulisci filtri';906 }907 908 };909 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['it-IT']);910})(jQuery);911/**912 * Bootstrap Table Japanese translation913 * Author: Azamshul Azizy <azamshul@gmail.com>914 */915(function ($) {916 'use strict';917 $.fn.bootstrapTable.locales['ja-JP'] = {918 formatLoadingMessage: function () {919 return 'èªã¿è¾¼ã¿ä¸ã§ããå°ã
ãå¾
ã¡ãã ããã';920 },921 formatRecordsPerPage: function (pageNumber) {922 return 'ãã¼ã¸å½ããæ大' + pageNumber + '件';923 },924 formatShowingRows: function (pageFrom, pageTo, totalRows) {925 return 'å
¨' + totalRows + '件ããã'+ pageFrom + 'ãã' + pageTo + '件ç®ã¾ã§è¡¨ç¤ºãã¦ãã¾ã';926 },927 formatSearch: function () {928 return 'æ¤ç´¢';929 },930 formatNoMatches: function () {931 return '該å½ããã¬ã³ã¼ããè¦ã¤ããã¾ãã';932 },933 formatPaginationSwitch: function () {934 return 'ãã¼ã¸æ°ã表示ã»é表示';935 },936 formatRefresh: function () {937 return 'æ´æ°';938 },939 formatToggle: function () {940 return 'ãã°ã«';941 },942 formatColumns: function () {943 return 'å';944 },945 formatAllRows: function () {946 return 'ãã¹ã¦';947 }948 };949 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ja-JP']);950})(jQuery);951/**952 * Bootstrap Table Georgian translation953 * Author: Levan Lotuashvili <l.lotuashvili@gmail.com>954 */955(function ($) {956 'use strict';957 $.fn.bootstrapTable.locales['ka-GE'] = {958 formatLoadingMessage: function() {959 return 'áá¢ááá áááá, ááá®ááá ááááªáááá...';960 },961 formatRecordsPerPage: function(pageNumber) {962 return pageNumber + ' á©áááá¬áá á áááá áááá ááá';963 },964 formatShowingRows: function(pageFrom, pageTo, totalRows) {965 return 'ááá©ááááááá ' + pageFrom + '-ááá ' + pageTo + '-ááá á©áááá¬áá á á¯ááá£á á ' + totalRows + '-ááá';966 },967 formatSearch: function() {968 return 'á«áááá';969 },970 formatNoMatches: function() {971 return 'áááááªááááá áá áá áá¡';972 },973 formatPaginationSwitch: function() {974 return 'áááá ááááá¡ áááááá áááááá¡ ááááááá/ááááá©ááá';975 },976 formatRefresh: function() {977 return 'ááááá®áááá';978 },979 formatToggle: function() {980 return 'á©áá ááá/ááááá ááá';981 },982 formatColumns: function() {983 return 'á¡ááá¢ááá';984 }985 };986 987 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ka-GE']);988})(jQuery);989/**990 * Bootstrap Table Korean translation991 * Author: Yi Tae-Hyeong (jsonobject@gmail.com)992 */993(function ($) {994 'use strict';995 $.fn.bootstrapTable.locales['ko-KR'] = {996 formatLoadingMessage: function () {997 return 'ë°ì´í°ë¥¼ ë¶ë¬ì¤ë ì¤ì
ëë¤...';998 },999 formatRecordsPerPage: function (pageNumber) {1000 return 'íì´ì§ ë¹ ' + pageNumber + 'ê° ë°ì´í° ì¶ë ¥';1001 },1002 formatShowingRows: function (pageFrom, pageTo, totalRows) {1003 return 'ì ì²´ ' + totalRows + 'ê° ì¤ ' + pageFrom + '~' + pageTo + 'ë²ì§¸ ë°ì´í° ì¶ë ¥,';1004 },1005 formatSearch: function () {1006 return 'ê²ì';1007 },1008 formatNoMatches: function () {1009 return 'ì¡°íë ë°ì´í°ê° ììµëë¤.';1010 },1011 formatRefresh: function () {1012 return 'ìë¡ ê³ ì¹¨';1013 },1014 formatToggle: function () {1015 return 'ì í';1016 },1017 formatColumns: function () {1018 return 'ì»¬ë¼ íí°ë§';1019 }1020 };1021 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ko-KR']);1022})(jQuery);1023/**1024 * Bootstrap Table Malay translation1025 * Author: Azamshul Azizy <azamshul@gmail.com>1026 */1027(function ($) {1028 'use strict';1029 $.fn.bootstrapTable.locales['ms-MY'] = {1030 formatLoadingMessage: function () {1031 return 'Permintaan sedang dimuatkan. Sila tunggu sebentar...';1032 },1033 formatRecordsPerPage: function (pageNumber) {1034 return pageNumber + ' rekod setiap muka surat';1035 },1036 formatShowingRows: function (pageFrom, pageTo, totalRows) {1037 return 'Sedang memaparkan rekod ' + pageFrom + ' hingga ' + pageTo + ' daripada jumlah ' + totalRows + ' rekod';1038 },1039 formatSearch: function () {1040 return 'Cari';1041 },1042 formatNoMatches: function () {1043 return 'Tiada rekod yang menyamai permintaan';1044 },1045 formatPaginationSwitch: function () {1046 return 'Tunjuk/sembunyi muka surat';1047 },1048 formatRefresh: function () {1049 return 'Muatsemula';1050 },1051 formatToggle: function () {1052 return 'Tukar';1053 },1054 formatColumns: function () {1055 return 'Lajur';1056 },1057 formatAllRows: function () {1058 return 'Semua';1059 }1060 };1061 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ms-MY']);1062})(jQuery);1063/**1064 * Bootstrap Table norwegian translation1065 * Author: Jim Nordbø, jim@nordb.no1066 */1067(function ($) {1068 'use strict';1069 $.fn.bootstrapTable.locales['nb-NO'] = {1070 formatLoadingMessage: function () {1071 return 'Oppdaterer, vennligst vent...';1072 },1073 formatRecordsPerPage: function (pageNumber) {1074 return pageNumber + ' poster pr side';1075 },1076 formatShowingRows: function (pageFrom, pageTo, totalRows) {1077 return 'Viser ' + pageFrom + ' til ' + pageTo + ' av ' + totalRows + ' rekker';1078 },1079 formatSearch: function () {1080 return 'Søk';1081 },1082 formatNoMatches: function () {1083 return 'Ingen poster funnet';1084 },1085 formatRefresh: function () {1086 return 'Oppdater';1087 },1088 formatToggle: function () {1089 return 'Endre';1090 },1091 formatColumns: function () {1092 return 'Kolonner';1093 }1094 };1095 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['nb-NO']);1096})(jQuery);1097/**1098 * Bootstrap Table Dutch translation1099 * Author: Your Name <info@a2hankes.nl>1100 */1101(function($) {1102 'use strict';1103 $.fn.bootstrapTable.locales['nl-NL'] = {1104 formatLoadingMessage: function() {1105 return 'Laden, even geduld...';1106 },1107 formatRecordsPerPage: function(pageNumber) {1108 return pageNumber + ' records per pagina';1109 },1110 formatShowingRows: function(pageFrom, pageTo, totalRows) {1111 return 'Toon ' + pageFrom + ' tot ' + pageTo + ' van ' + totalRows + ' record' + ((totalRows > 1) ? 's' : '');1112 },1113 formatDetailPagination: function(totalRows) {1114 return 'Toon ' + totalRows + ' record' + ((totalRows > 1) ? 's' : '');1115 },1116 formatSearch: function() {1117 return 'Zoeken';1118 },1119 formatNoMatches: function() {1120 return 'Geen resultaten gevonden';1121 },1122 formatRefresh: function() {1123 return 'Vernieuwen';1124 },1125 formatToggle: function() {1126 return 'Omschakelen';1127 },1128 formatColumns: function() {1129 return 'Kolommen';1130 },1131 formatAllRows: function() {1132 return 'Alle';1133 },1134 formatPaginationSwitch: function() {1135 return 'Verberg/Toon paginatie';1136 },1137 formatExport: function() {1138 return 'Exporteer data';1139 },1140 formatClearFilters: function() {1141 return 'Verwijder filters';1142 }1143 };1144 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['nl-NL']);1145})(jQuery);1146/**1147 * Bootstrap Table Polish translation1148 * Author: zergu <michal.zagdan @ gmail com>1149 */1150(function ($) {1151 'use strict';1152 $.fn.bootstrapTable.locales['pl-PL'] = {1153 formatLoadingMessage: function () {1154 return 'Åadowanie, proszÄ czekaÄ...';1155 },1156 formatRecordsPerPage: function (pageNumber) {1157 return pageNumber + ' rekordów na stronÄ';1158 },1159 formatShowingRows: function (pageFrom, pageTo, totalRows) {1160 return 'WyÅwietlanie rekordów od ' + pageFrom + ' do ' + pageTo + ' z ' + totalRows;1161 },1162 formatSearch: function () {1163 return 'Szukaj';1164 },1165 formatNoMatches: function () {1166 return 'Niestety, nic nie znaleziono';1167 },1168 formatRefresh: function () {1169 return 'OdÅwież';1170 },1171 formatToggle: function () {1172 return 'PrzeÅÄ
cz';1173 },1174 formatColumns: function () {1175 return 'Kolumny';1176 }1177 };1178 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['pl-PL']);1179})(jQuery);1180/**1181 * Bootstrap Table Brazilian Portuguese Translation1182 * Author: Eduardo Cerqueira<egcerqueira@gmail.com>1183 * Update: João Mello<jmello@hotmail.com.br>1184 */1185(function ($) {1186 'use strict';1187 $.fn.bootstrapTable.locales['pt-BR'] = {1188 formatLoadingMessage: function () {1189 return 'Carregando, aguarde...';1190 },1191 formatRecordsPerPage: function (pageNumber) {1192 return pageNumber + ' registros por página';1193 },1194 formatShowingRows: function (pageFrom, pageTo, totalRows) {1195 return 'Exibindo ' + pageFrom + ' até ' + pageTo + ' de ' + totalRows + ' linhas';1196 },1197 formatSearch: function () { 1198 return 'Pesquisar';1199 },1200 formatRefresh: function () { 1201 return 'Recarregar';1202 },1203 formatToggle: function () { 1204 return 'Alternar';1205 },1206 formatColumns: function () { 1207 return 'Colunas';1208 },1209 formatPaginationSwitch: function () { 1210 return 'Ocultar/Exibir paginação';1211 },1212 formatNoMatches: function () {1213 return 'Nenhum registro encontrado';1214 }1215 };1216 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['pt-BR']);1217})(jQuery);1218/**1219 * Bootstrap Table Portuguese Portugal Translation1220 * Author: Burnspirit<burnspirit@gmail.com>1221 */1222(function ($) {1223 'use strict';1224 $.fn.bootstrapTable.locales['pt-PT'] = {1225 formatLoadingMessage: function () {1226 return 'A carregar, por favor aguarde...';1227 },1228 formatRecordsPerPage: function (pageNumber) {1229 return pageNumber + ' registos por página';1230 },1231 formatShowingRows: function (pageFrom, pageTo, totalRows) {1232 return 'A mostrar ' + pageFrom + ' até ' + pageTo + ' de ' + totalRows + ' linhas';1233 },1234 formatSearch: function () {1235 return 'Pesquisa';1236 },1237 formatNoMatches: function () {1238 return 'Nenhum registo encontrado';1239 },1240 formatPaginationSwitch: function () {1241 return 'Esconder/Mostrar paginação';1242 },1243 formatRefresh: function () {1244 return 'Atualizar';1245 },1246 formatToggle: function () {1247 return 'Alternar';1248 },1249 formatColumns: function () {1250 return 'Colunas';1251 },1252 formatAllRows: function () {1253 return 'Tudo';1254 }1255 };1256 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['pt-PT']);1257})(jQuery);1258/**1259 * Bootstrap Table Romanian translation1260 * Author: cristake <cristianiosif@me.com>1261 */1262(function ($) {1263 'use strict';1264 $.fn.bootstrapTable.locales['ro-RO'] = {1265 formatLoadingMessage: function () {1266 return 'Se incarca, va rugam asteptati...';1267 },1268 formatRecordsPerPage: function (pageNumber) {1269 return pageNumber + ' inregistrari pe pagina';1270 },1271 formatShowingRows: function (pageFrom, pageTo, totalRows) {1272 return 'Arata de la ' + pageFrom + ' pana la ' + pageTo + ' din ' + totalRows + ' randuri';1273 },1274 formatSearch: function () {1275 return 'Cauta';1276 },1277 formatNoMatches: function () {1278 return 'Nu au fost gasite inregistrari';1279 },1280 formatPaginationSwitch: function () {1281 return 'Ascunde/Arata paginatia';1282 },1283 formatRefresh: function () {1284 return 'Reincarca';1285 },1286 formatToggle: function () {1287 return 'Comuta';1288 },1289 formatColumns: function () {1290 return 'Coloane';1291 },1292 formatAllRows: function () {1293 return 'Toate';1294 }1295 };1296 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ro-RO']);1297})(jQuery);1298/**1299 * Bootstrap Table Russian translation1300 * Author: Dunaevsky Maxim <dunmaksim@yandex.ru>1301 */1302(function ($) {1303 'use strict';1304 $.fn.bootstrapTable.locales['ru-RU'] = {1305 formatLoadingMessage: function () {1306 return 'ÐожалÑйÑÑа, подождиÑе, идÑÑ Ð·Ð°Ð³ÑÑзка...';1307 },1308 formatRecordsPerPage: function (pageNumber) {1309 return pageNumber + ' запиÑей на ÑÑÑаниÑÑ';1310 },1311 formatShowingRows: function (pageFrom, pageTo, totalRows) {1312 return 'ÐапиÑи Ñ ' + pageFrom + ' по ' + pageTo + ' из ' + totalRows;1313 },1314 formatSearch: function () {1315 return 'ÐоиÑк';1316 },1317 formatNoMatches: function () {1318 return 'ÐиÑего не найдено';1319 },1320 formatRefresh: function () {1321 return 'ÐбновиÑÑ';1322 },1323 formatToggle: function () {1324 return 'ÐеÑеклÑÑиÑÑ';1325 },1326 formatColumns: function () {1327 return 'Ðолонки';1328 },1329 formatClearFilters: function () {1330 return 'ÐÑиÑÑиÑÑ ÑилÑÑÑÑ';1331 },1332 formatMultipleSort: function () {1333 return 'ÐножеÑÑÐ²ÐµÐ½Ð½Ð°Ñ ÑоÑÑиÑовка';1334 },1335 formatAddLevel: function () {1336 return 'ÐобавиÑÑ ÑÑовенÑ';1337 },1338 formatDeleteLevel: function () {1339 return 'УдалиÑÑ ÑÑовенÑ';1340 },1341 formatColumn: function () {1342 return 'Ðолонка';1343 },1344 formatOrder: function () {1345 return 'ÐоÑÑдок';1346 },1347 formatSortBy: function () {1348 return 'СоÑÑиÑоваÑÑ Ð¿Ð¾';1349 },1350 formatThenBy: function () {1351 return 'заÑем по';1352 },1353 formatSort: function () {1354 return 'СоÑÑиÑоваÑÑ';1355 },1356 formatCancel: function () {1357 return 'ÐÑмена';1358 },1359 formatDuplicateAlertTitle: function () {1360 return 'ÐÑблиÑование колонок!';1361 },1362 formatDuplicateAlertDescription: function () {1363 return 'УдалиÑе, пожалÑйÑÑа, дÑблиÑÑÑÑÑÑ ÐºÐ¾Ð»Ð¾Ð½ÐºÑ, или замениÑе ее на дÑÑгÑÑ.';1364 }1365 };1366 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ru-RU']);1367})(jQuery);1368/**1369 * Bootstrap Table Slovak translation1370 * Author: Jozef Dúc<jozef.d13@gmail.com>1371 */1372(function ($) {1373 'use strict';1374 $.fn.bootstrapTable.locales['sk-SK'] = {1375 formatLoadingMessage: function () {1376 return 'ProsÃm Äakajte ...';1377 },1378 formatRecordsPerPage: function (pageNumber) {1379 return pageNumber + ' záznamov na stranu';1380 },1381 formatShowingRows: function (pageFrom, pageTo, totalRows) {1382 return 'Zobrazená ' + pageFrom + '. - ' + pageTo + '. položka z celkových ' + totalRows;1383 },1384 formatSearch: function () {1385 return 'Vyhľadávanie';1386 },1387 formatNoMatches: function () {1388 return 'Nenájdená žiadna vyhovujúca položka';1389 },1390 formatRefresh: function () {1391 return 'ObnoviÅ¥';1392 },1393 formatToggle: function () {1394 return 'Prepni';1395 },1396 formatColumns: function () {1397 return 'Stĺpce';1398 }1399 };1400 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['sk-SK']);1401})(jQuery);1402/**1403 * Bootstrap Table Swedish translation1404 * Author: C Bratt <bratt@inix.se>1405 */1406(function ($) {1407 'use strict';1408 $.fn.bootstrapTable.locales['sv-SE'] = {1409 formatLoadingMessage: function () {1410 return 'Laddar, vänligen vänta...';1411 },1412 formatRecordsPerPage: function (pageNumber) {1413 return pageNumber + ' rader per sida';1414 },1415 formatShowingRows: function (pageFrom, pageTo, totalRows) {1416 return 'Visa ' + pageFrom + ' till ' + pageTo + ' av ' + totalRows + ' rader';1417 },1418 formatSearch: function () {1419 return 'Sök';1420 },1421 formatNoMatches: function () {1422 return 'Inga matchande resultat funna.';1423 },1424 formatRefresh: function () {1425 return 'Uppdatera';1426 },1427 formatToggle: function () {1428 return 'Skifta';1429 },1430 formatColumns: function () {1431 return 'kolumn';1432 }1433 };1434 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['sv-SE']);1435})(jQuery);1436/**1437 * Bootstrap Table Thai translation1438 * Author: Monchai S.<monchais@gmail.com>1439 */1440(function ($) {1441 'use strict';1442 $.fn.bootstrapTable.locales['th-TH'] = {1443 formatLoadingMessage: function () {1444 return 'à¸à¸³à¸¥à¸±à¸à¹à¸«à¸¥à¸à¸à¹à¸à¸¡à¸¹à¸¥, à¸à¸£à¸¸à¸à¸²à¸£à¸à¸ªà¸±à¸à¸à¸£à¸¹à¹...';1445 },1446 formatRecordsPerPage: function (pageNumber) {1447 return pageNumber + ' รายà¸à¸²à¸£à¸à¹à¸à¸«à¸à¹à¸²';1448 },1449 formatShowingRows: function (pageFrom, pageTo, totalRows) {1450 return 'รายà¸à¸²à¸£à¸à¸µà¹ ' + pageFrom + ' à¸à¸¶à¸ ' + pageTo + ' à¸à¸²à¸à¸à¸±à¹à¸à¸«à¸¡à¸ ' + totalRows + ' รายà¸à¸²à¸£';1451 },1452 formatSearch: function () {1453 return 'à¸à¹à¸à¸«à¸²';1454 },1455 formatNoMatches: function () {1456 return 'à¹à¸¡à¹à¸à¸à¸£à¸²à¸¢à¸à¸²à¸£à¸à¸µà¹à¸à¹à¸à¸«à¸² !';1457 },1458 formatRefresh: function () {1459 return 'รีà¹à¸à¸£à¸ª';1460 },1461 formatToggle: function () {1462 return 'สลัà¸à¸¡à¸¸à¸¡à¸¡à¸à¸';1463 },1464 formatColumns: function () {1465 return 'à¸à¸à¸¥à¸±à¸¡à¸à¹';1466 }1467 };1468 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['th-TH']);1469})(jQuery);1470/**1471 * Bootstrap Table Turkish translation1472 * Author: Emin Åen1473 * Author: Sercan Cakir <srcnckr@gmail.com>1474 */1475(function ($) {1476 'use strict';1477 $.fn.bootstrapTable.locales['tr-TR'] = {1478 formatLoadingMessage: function () {1479 return 'Yükleniyor, lütfen bekleyin...';1480 },1481 formatRecordsPerPage: function (pageNumber) {1482 return 'Sayfa baÅına ' + pageNumber + ' kayıt.';1483 },1484 formatShowingRows: function (pageFrom, pageTo, totalRows) {1485 return totalRows + ' kayıttan ' + pageFrom + '-' + pageTo + ' arası gösteriliyor.';1486 },1487 formatSearch: function () {1488 return 'Ara';1489 },1490 formatNoMatches: function () {1491 return 'EÅleÅen kayıt bulunamadı.';1492 },1493 formatRefresh: function () {1494 return 'Yenile';1495 },1496 formatToggle: function () {1497 return 'DeÄiÅtir';1498 },1499 formatColumns: function () {1500 return 'Sütunlar';1501 },1502 formatAllRows: function () {1503 return 'Tüm Satırlar';1504 }1505 };1506 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['tr-TR']);1507})(jQuery);1508/**1509 * Bootstrap Table Ukrainian translation1510 * Author: Vitaliy Timchenko <vitaliy.timchenko@gmail.com>1511 */1512 (function ($) {1513 'use strict';1514 1515 $.fn.bootstrapTable.locales['uk-UA'] = {1516 formatLoadingMessage: function () {1517 return 'ÐаванÑаженнÑ, бÑÐ´Ñ Ð»Ð°Ñка, заÑекайÑе...';1518 },1519 formatRecordsPerPage: function (pageNumber) {1520 return pageNumber + ' запиÑÑв на ÑÑоÑÑнкÑ';1521 },1522 formatShowingRows: function (pageFrom, pageTo, totalRows) {1523 return 'Ðоказано з ' + pageFrom + ' по ' + pageTo + '. ÐÑÑого: ' + totalRows;1524 },1525 formatSearch: function () {1526 return 'ÐоÑÑк';1527 },1528 formatNoMatches: function () {1529 return 'Ðе знайдено жодного запиÑÑ';1530 },1531 formatRefresh: function () {1532 return 'ÐновиÑи';1533 },1534 formatToggle: function () {1535 return 'ÐмÑниÑи';1536 },1537 formatColumns: function () {1538 return 'СÑовпÑÑ';1539 },1540 formatClearFilters: function () {1541 return 'ÐÑиÑÑиÑи ÑÑлÑÑÑи';1542 },1543 formatMultipleSort: function () {1544 return 'СоÑÑÑÐ²Ð°Ð½Ð½Ñ Ð·Ð° кÑлÑкома ÑÑовпÑÑми';1545 },1546 formatAddLevel: function () {1547 return 'ÐодаÑи ÑÑвенÑ';1548 },1549 formatDeleteLevel: function () {1550 return 'ÐидалиÑи ÑÑвенÑ';1551 },1552 formatColumn: function () {1553 return 'СÑовпеÑÑ';1554 },1555 formatOrder: function () {1556 return 'ÐоÑÑдок';1557 },1558 formatSortBy: function () {1559 return 'СоÑÑÑваÑи за';1560 },1561 formatThenBy: function () {1562 return 'поÑÑм за';1563 },1564 formatSort: function () {1565 return 'СоÑÑÑваÑи';1566 },1567 formatCancel: function () {1568 return 'СкаÑÑваÑи';1569 },1570 formatDuplicateAlertTitle: function () {1571 return 'ÐÑблÑÐ²Ð°Ð½Ð½Ñ ÑÑовпÑÑв!';1572 },1573 formatDuplicateAlertDescription: function () {1574 return 'ÐидалÑÑÑ, бÑÐ´Ñ Ð»Ð°Ñка, дÑблÑÑÑий ÑÑовпеÑÑ, або замÑнÑÑÑ Ð¹Ð¾Ð³Ð¾ на ÑнÑий.';1575 }1576 };1577 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['uk-UA']);1578})(jQuery);1579/**1580 * Bootstrap Table Urdu translation1581 * Author: Malik <me@malikrizwan.com>1582 */1583(function ($) {1584 'use strict';1585 $.fn.bootstrapTable.locales['ur-PK'] = {1586 formatLoadingMessage: function () {1587 return 'Ø¨Ø±Ø§Û Ù
ÛرباÙÛ Ø§Ùتظار Ú©ÛجئÛ';1588 },1589 formatRecordsPerPage: function (pageNumber) {1590 return pageNumber + ' رÛکارÚز ÙÛ ØµÙÛ ';1591 },1592 formatShowingRows: function (pageFrom, pageTo, totalRows) {1593 return 'دÛÚ©Ú¾ÛÚº ' + pageFrom + ' Ø³Û ' + pageTo + ' Ú©Û ' + totalRows + 'رÛکارÚز';1594 },1595 formatSearch: function () {1596 return 'تÙاش';1597 },1598 formatNoMatches: function () {1599 return 'Ú©ÙØ¦Û Ø±ÛÚ©Ø§Ø±Ú ÙÛÛÚº Ù
Ùا';1600 },1601 formatRefresh: function () {1602 return 'ØªØ§Ø²Û Ú©Ø±ÛÚº';1603 },1604 formatToggle: function () {1605 return 'تبدÛ٠کرÛÚº';1606 },1607 formatColumns: function () {1608 return 'کاÙÙ
';1609 }1610 };1611 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ur-PK']);1612})(jQuery);1613/**1614 * Bootstrap Table Uzbek translation1615 * Author: Nabijon Masharipov <mnabijonz@gmail.com>1616 */1617(function ($) {1618 'use strict';1619 $.fn.bootstrapTable.locales['uz-Latn-UZ'] = {1620 formatLoadingMessage: function () {1621 return 'Yuklanyapti, iltimos kuting...';1622 },1623 formatRecordsPerPage: function (pageNumber) {1624 return pageNumber + ' qator har sahifada';1625 },1626 formatShowingRows: function (pageFrom, pageTo, totalRows) {1627 return 'Ko\'rsatypati ' + pageFrom + ' dan ' + pageTo + ' gacha ' + totalRows + ' qatorlarni';1628 },1629 formatSearch: function () {1630 return 'Qidirish';1631 },1632 formatNoMatches: function () {1633 return 'Hech narsa topilmadi';1634 },1635 formatPaginationSwitch: function () {1636 return 'Sahifalashni yashirish/ko\'rsatish';1637 },1638 formatRefresh: function () {1639 return 'Yangilash';1640 },1641 formatToggle: function () {1642 return 'Ko\'rinish';1643 },1644 formatColumns: function () {1645 return 'Ustunlar';1646 },1647 formatAllRows: function () {1648 return 'Hammasi';1649 },1650 formatExport: function () {1651 return 'Eksport';1652 },1653 formatClearFilters: function () {1654 return 'Filtrlarni tozalash';1655 }1656 };1657 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['uz-Latn-UZ']);1658})(jQuery);1659/**1660 * Bootstrap Table Vietnamese translation1661 * Author: Duc N. PHAM <pngduc@gmail.com>1662 */1663(function ($) {1664 'use strict';1665 $.fn.bootstrapTable.locales['vi-VN'] = {1666 formatLoadingMessage: function () {1667 return 'Äang tải...';1668 },1669 formatRecordsPerPage: function (pageNumber) {1670 return pageNumber + ' bản ghi má»i trang';1671 },1672 formatShowingRows: function (pageFrom, pageTo, totalRows) {1673 return 'Hiá»n thá» từ trang ' + pageFrom + ' Äến ' + pageTo + ' của ' + totalRows + ' bảng ghi';1674 },1675 formatSearch: function () {1676 return 'Tìm kiếm';1677 },1678 formatNoMatches: function () {1679 return 'Không có dữ liá»u';1680 }1681 };1682 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['vi-VN']);1683})(jQuery);1684/**1685 * Bootstrap Table Chinese translation1686 * Author: Zhixin Wen<wenzhixin2010@gmail.com>1687 */1688(function ($) {1689 'use strict';1690 $.fn.bootstrapTable.locales['zh-CN'] = {1691 formatLoadingMessage: function () {1692 return 'æ£å¨åªåå°å è½½æ°æ®ä¸ï¼è¯·ç¨åâ¦â¦';1693 },1694 formatRecordsPerPage: function (pageNumber) {1695 return 'æ¯é¡µæ¾ç¤º ' + pageNumber + ' æ¡è®°å½';1696 },1697 formatShowingRows: function (pageFrom, pageTo, totalRows) {1698 return 'æ¾ç¤ºç¬¬ ' + pageFrom + ' å°ç¬¬ ' + pageTo + ' æ¡è®°å½ï¼æ»å
± ' + totalRows + ' æ¡è®°å½';1699 },1700 formatSearch: function () {1701 return 'æç´¢';1702 },1703 formatNoMatches: function () {1704 return '没ææ¾å°å¹é
çè®°å½';1705 },1706 formatPaginationSwitch: function () {1707 return 'éè/æ¾ç¤ºå页';1708 },1709 formatRefresh: function () {1710 return 'å·æ°';1711 },1712 formatToggle: function () {1713 return 'åæ¢';1714 },1715 formatColumns: function () {1716 return 'å';1717 },1718 formatExport: function () {1719 return '导åºæ°æ®';1720 },1721 formatClearFilters: function () {1722 return 'æ¸
空è¿æ»¤';1723 }1724 };1725 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']);1726})(jQuery);1727/**1728 * Bootstrap Table Chinese translation1729 * Author: Zhixin Wen<wenzhixin2010@gmail.com>1730 */1731(function ($) {1732 'use strict';1733 $.fn.bootstrapTable.locales['zh-TW'] = {1734 formatLoadingMessage: function () {1735 return 'æ£å¨åªåå°è¼å
¥è³æï¼è«ç¨åâ¦â¦';1736 },1737 formatRecordsPerPage: function (pageNumber) {1738 return 'æ¯é 顯示 ' + pageNumber + ' é
è¨é';1739 },1740 formatShowingRows: function (pageFrom, pageTo, totalRows) {1741 return '顯示第 ' + pageFrom + ' å°ç¬¬ ' + pageTo + ' é
è¨éï¼ç¸½å
± ' + totalRows + ' é
è¨é';1742 },1743 formatSearch: function () {1744 return 'æå°';1745 },1746 formatNoMatches: function () {1747 return 'æ²ææ¾å°ç¬¦åççµæ';1748 },1749 formatPaginationSwitch: function () {1750 return 'é±è/顯示åé ';1751 },1752 formatRefresh: function () {1753 return 'éæ°æ´ç';1754 },1755 formatToggle: function () {1756 return 'åæ';1757 },1758 formatColumns: function () {1759 return 'å';1760 }1761 };1762 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-TW']);...
numberformat_test.js
Source:numberformat_test.js
...51}52function testVeryBigNumber() {53 var str;54 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.CURRENCY);55 str = fmt.format(1785599999999999888888888888888);56 // when comparing big number, various platform have small different in57 // precision. We have to tolerate that using veryBigNumberCompare.58 var expected = '$1,785,599,999,999,999,400,000,000,000,000.00';59 assertTrue(veryBigNumberCompare(60 '$1,785,599,999,999,999,400,000,000,000,000.00', str));61 str = fmt.format(1.7856E30);62 assertTrue(veryBigNumberCompare(63 '$1,785,599,999,999,999,400,000,000,000,000.00', str));64 str = fmt.format(1.3456E20);65 assertTrue(veryBigNumberCompare('$134,560,000,000,000,000,000.00', str));66 fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.DECIMAL);67 str = fmt.format(1.3456E20);68 assertTrue(veryBigNumberCompare('134,559,999,999,999,980,000', str));69 fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.PERCENT);70 str = fmt.format(1.3456E20);71 assertTrue(veryBigNumberCompare('13,456,000,000,000,000,000,000%', str));72 fmt = new goog.i18n.NumberFormat(73 goog.i18n.NumberFormat.Format.SCIENTIFIC);74 str = fmt.format(1.3456E20);75 assertEquals('1E20', str);76 fmt = new goog.i18n.NumberFormat(77 goog.i18n.NumberFormat.Format.DECIMAL);78 str = fmt.format(-1.234567890123456e306);79 assertEquals(1 + 1 + 306 + 306 / 3, str.length);80 assertEquals('-1,234,567,890,123,45', str.substr(0, 21));81 str = fmt.format(Infinity);82 assertEquals('\u221e', str);83 str = fmt.format(-Infinity);84 assertEquals('-\u221e', str);85}86function testStandardFormat() {87 var str;88 var fmt = new goog.i18n.NumberFormat(89 goog.i18n.NumberFormat.Format.CURRENCY);90 str = fmt.format(1234.579);91 assertEquals('$1,234.58', str);92 fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.DECIMAL);93 str = fmt.format(1234.579);94 assertEquals('1,234.579', str);95 fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.PERCENT);96 str = fmt.format(1234.579);97 assertEquals('123,458%', str);98 fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.SCIENTIFIC);99 str = fmt.format(1234.579);100 assertEquals('1E3', str);101 // Math.log(1000000)/Math.LN10 is strictly less than 6. Make sure it gets102 // formatted correctly.103 str = fmt.format(1000000);104 assertEquals('1E6', str);105}106function testNegativePercentage() {107 var str;108 var fmt = new goog.i18n.NumberFormat('#,##0.00%');109 str = fmt.format(-1234.56);110 assertEquals('-123,456.00%', str);111 fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.PERCENT);112 str = fmt.format(-1234.579);113 assertEquals('-123,458%', str);114}115function testCustomPercentage() {116 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.PERCENT);117 fmt.setMaximumFractionDigits(1);118 fmt.setMinimumFractionDigits(1);119 var str = fmt.format(0.1291);120 assertEquals('12.9%', str);121 fmt.setMaximumFractionDigits(2);122 fmt.setMinimumFractionDigits(1);123 str = fmt.format(0.129);124 assertEquals('12.9%', str);125 fmt.setMaximumFractionDigits(2);126 fmt.setMinimumFractionDigits(1);127 str = fmt.format(0.12);128 assertEquals('12.0%', str);129 fmt.setMaximumFractionDigits(2);130 fmt.setMinimumFractionDigits(1);131 str = fmt.format(0.12911);132 assertEquals('12.91%', str);133}134function testBasicParse() {135 var value;136 var fmt = new goog.i18n.NumberFormat('0.0000');137 value = fmt.parse('123.4579');138 assertEquals(123.4579, value);139 value = fmt.parse('+123.4579');140 assertEquals(123.4579, value);141 value = fmt.parse('-123.4579');142 assertEquals(-123.4579, value);143}144function testPrefixParse() {145 var value;146 var fmt = new goog.i18n.NumberFormat('0.0;(0.0)');147 value = fmt.parse('123.4579');148 assertEquals(123.4579, value);149 value = fmt.parse('(123.4579)');150 assertEquals(-123.4579, value);151}152function testPrecentParse() {153 var value;154 var fmt = new goog.i18n.NumberFormat('0.0;(0.0)');155 value = fmt.parse('123.4579%');156 assertEquals((123.4579 / 100), value);157 value = fmt.parse('(%123.4579)');158 assertEquals((-123.4579 / 100), value);159 value = fmt.parse('123.4579\u2030');160 assertEquals((123.4579 / 1000), value);161 value = fmt.parse('(\u2030123.4579)');162 assertEquals((-123.4579 / 1000), value);163}164function testPercentAndPerMillAdvance() {165 var value;166 var pos = [0];167 var fmt = new goog.i18n.NumberFormat('0');168 value = fmt.parse('120%', pos);169 assertEquals(1.2, value);170 assertEquals(4, pos[0]);171 pos[0] = 0;172 value = fmt.parse('120\u2030', pos);173 assertEquals(0.12, value);174 assertEquals(4, pos[0]);175}176function testInfinityParse() {177 var value;178 var fmt = new goog.i18n.NumberFormat('0.0;(0.0)');179 // gwt need to add those symbols first180 value = fmt.parse('\u221e');181 assertEquals(Number.POSITIVE_INFINITY, value);182 value = fmt.parse('(\u221e)');183 assertEquals(Number.NEGATIVE_INFINITY, value);184}185function testExponentParse() {186 var value;187 var fmt;188 fmt = new goog.i18n.NumberFormat('#E0');189 value = fmt.parse('1.234E3');190 assertEquals(1.234E+3, value);191 fmt = new goog.i18n.NumberFormat('0.###E0');192 value = fmt.parse('1.234E3');193 assertEquals(1.234E+3, value);194 fmt = new goog.i18n.NumberFormat('#E0');195 value = fmt.parse('1.2345E4');196 assertEquals(12345.0, value);197 value = fmt.parse('1.2345E4');198 assertEquals(12345.0, value);199 value = fmt.parse('1.2345E+4');200 assertEquals(12345.0, value);201}202function testGroupingParse() {203 var value;204 var fmt = new goog.i18n.NumberFormat('#,###');205 value = fmt.parse('1,234,567,890');206 assertEquals(1234567890, value);207 value = fmt.parse('12,3456,7890');208 assertEquals(1234567890, value);209 fmt = new goog.i18n.NumberFormat('#');210 value = fmt.parse('1234567890');211 assertEquals(1234567890, value);212}213function testBasicFormat() {214 var fmt = new goog.i18n.NumberFormat('0.0000');215 var str = fmt.format(123.45789179565757);216 assertEquals('123.4579', str);217}218function testGrouping() {219 var str;220 var fmt = new goog.i18n.NumberFormat('#,###');221 str = fmt.format(1234567890);222 assertEquals('1,234,567,890', str);223 fmt = new goog.i18n.NumberFormat('#,####');224 str = fmt.format(1234567890);225 assertEquals('12,3456,7890', str);226 fmt = new goog.i18n.NumberFormat('#');227 str = fmt.format(1234567890);228 assertEquals('1234567890', str);229}230function testPerMill() {231 var str;232 var fmt = new goog.i18n.NumberFormat('###.###\u2030');233 str = fmt.format(0.4857);234 assertEquals('485.7\u2030', str);235}236function testCurrency() {237 var str;238 var fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;-\u00a4#,##0.00');239 str = fmt.format(1234.56);240 assertEquals('$1,234.56', str);241 str = fmt.format(-1234.56);242 assertEquals('-$1,234.56', str);243 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;-\u00a4#,##0.00', 'USD',244 goog.i18n.NumberFormat.CurrencyStyle.LOCAL);245 str = fmt.format(1234.56);246 assertEquals('$1,234.56', str);247 str = fmt.format(-1234.56);248 assertEquals('-$1,234.56', str);249 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;-\u00a4#,##0.00', 'USD',250 goog.i18n.NumberFormat.CurrencyStyle.PORTABLE);251 str = fmt.format(1234.56);252 assertEquals('US$1,234.56', str);253 str = fmt.format(-1234.56);254 assertEquals('-US$1,234.56', str);255 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;-\u00a4#,##0.00', 'USD',256 goog.i18n.NumberFormat.CurrencyStyle.GLOBAL);257 str = fmt.format(1234.56);258 assertEquals('USD $1,234.56', str);259 str = fmt.format(-1234.56);260 assertEquals('-USD $1,234.56', str);261 fmt = new goog.i18n.NumberFormat(262 '\u00a4\u00a4 #,##0.00;-\u00a4\u00a4 #,##0.00');263 str = fmt.format(1234.56);264 assertEquals('USD 1,234.56', str);265 fmt = new goog.i18n.NumberFormat(266 '\u00a4\u00a4 #,##0.00;\u00a4\u00a4 -#,##0.00');267 str = fmt.format(-1234.56);268 assertEquals('USD -1,234.56', str);269 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;-\u00a4#,##0.00', 'BRL');270 str = fmt.format(1234.56);271 assertEquals('R$1,234.56', str);272 str = fmt.format(-1234.56);273 assertEquals('-R$1,234.56', str);274 fmt = new goog.i18n.NumberFormat(275 '\u00a4\u00a4 #,##0.00;(\u00a4\u00a4 #,##0.00)', 'BRL');276 str = fmt.format(1234.56);277 assertEquals('BRL 1,234.56', str);278 str = fmt.format(-1234.56);279 assertEquals('(BRL 1,234.56)', str);280}281function testQuotes() {282 var str;283 var fmt = new goog.i18n.NumberFormat('a\'fo\'\'o\'b#');284 str = fmt.format(123);285 assertEquals('afo\'ob123', str);286 fmt = new goog.i18n.NumberFormat('a\'\'b#');287 str = fmt.format(123);288 assertEquals('a\'b123', str);289 fmt = new goog.i18n.NumberFormat('a\'fo\'\'o\'b#');290 str = fmt.format(-123);291 assertEquals('afo\'ob-123', str);292 fmt = new goog.i18n.NumberFormat('a\'\'b#');293 str = fmt.format(-123);294 assertEquals('a\'b-123', str);295}296function testZeros() {297 var str;298 var fmt;299 fmt = new goog.i18n.NumberFormat('#.#');300 str = fmt.format(0);301 assertEquals('0', str);302 fmt = new goog.i18n.NumberFormat('#.');303 str = fmt.format(0);304 assertEquals('0.', str);305 fmt = new goog.i18n.NumberFormat('.#');306 str = fmt.format(0);307 assertEquals('.0', str);308 fmt = new goog.i18n.NumberFormat('#');309 str = fmt.format(0);310 assertEquals('0', str);311 fmt = new goog.i18n.NumberFormat('#0.#');312 str = fmt.format(0);313 assertEquals('0', str);314 fmt = new goog.i18n.NumberFormat('#0.');315 str = fmt.format(0);316 assertEquals('0.', str);317 fmt = new goog.i18n.NumberFormat('#.0');318 str = fmt.format(0);319 assertEquals('.0', str);320 fmt = new goog.i18n.NumberFormat('#');321 str = fmt.format(0);322 assertEquals('0', str);323 fmt = new goog.i18n.NumberFormat('000');324 str = fmt.format(0);325 assertEquals('000', str);326}327function testExponential() {328 var str;329 var fmt;330 fmt = new goog.i18n.NumberFormat('0.####E0');331 str = fmt.format(0.01234);332 assertEquals('1.234E-2', str);333 fmt = new goog.i18n.NumberFormat('00.000E00');334 str = fmt.format(0.01234);335 assertEquals('12.340E-03', str);336 fmt = new goog.i18n.NumberFormat('##0.######E000');337 str = fmt.format(0.01234);338 assertEquals('12.34E-003', str);339 fmt = new goog.i18n.NumberFormat('0.###E0;[0.###E0]');340 str = fmt.format(0.01234);341 assertEquals('1.234E-2', str);342 fmt = new goog.i18n.NumberFormat('0.####E0');343 str = fmt.format(123456789);344 assertEquals('1.2346E8', str);345 fmt = new goog.i18n.NumberFormat('00.000E00');346 str = fmt.format(123456789);347 assertEquals('12.346E07', str);348 fmt = new goog.i18n.NumberFormat('##0.######E000');349 str = fmt.format(123456789);350 assertEquals('123.456789E006', str);351 fmt = new goog.i18n.NumberFormat('0.###E0;[0.###E0]');352 str = fmt.format(123456789);353 assertEquals('1.235E8', str);354 fmt = new goog.i18n.NumberFormat('0.####E0');355 str = fmt.format(1.23e300);356 assertEquals('1.23E300', str);357 fmt = new goog.i18n.NumberFormat('00.000E00');358 str = fmt.format(1.23e300);359 assertEquals('12.300E299', str);360 fmt = new goog.i18n.NumberFormat('##0.######E000');361 str = fmt.format(1.23e300);362 assertEquals('1.23E300', str);363 fmt = new goog.i18n.NumberFormat('0.###E0;[0.###E0]');364 str = fmt.format(1.23e300);365 assertEquals('1.23E300', str);366 fmt = new goog.i18n.NumberFormat('0.####E0');367 str = fmt.format(-3.141592653e-271);368 assertEquals('-3.1416E-271', str);369 fmt = new goog.i18n.NumberFormat('00.000E00');370 str = fmt.format(-3.141592653e-271);371 assertEquals('-31.416E-272', str);372 fmt = new goog.i18n.NumberFormat('##0.######E000');373 str = fmt.format(-3.141592653e-271);374 assertEquals('-314.159265E-273', str);375 fmt = new goog.i18n.NumberFormat('0.###E0;[0.###E0]');376 str = fmt.format(-3.141592653e-271);377 assertEquals('[3.142E-271]', str);378 fmt = new goog.i18n.NumberFormat('0.####E0');379 str = fmt.format(0);380 assertEquals('0E0', str);381 fmt = new goog.i18n.NumberFormat('00.000E00');382 str = fmt.format(0);383 assertEquals('00.000E00', str);384 fmt = new goog.i18n.NumberFormat('##0.######E000');385 str = fmt.format(0);386 assertEquals('0E000', str);387 fmt = new goog.i18n.NumberFormat('0.###E0;[0.###E0]');388 str = fmt.format(0);389 assertEquals('0E0', str);390 fmt = new goog.i18n.NumberFormat('0.####E0');391 str = fmt.format(-1);392 assertEquals('-1E0', str);393 fmt = new goog.i18n.NumberFormat('00.000E00');394 str = fmt.format(-1);395 assertEquals('-10.000E-01', str);396 fmt = new goog.i18n.NumberFormat('##0.######E000');397 str = fmt.format(-1);398 assertEquals('-1E000', str);399 fmt = new goog.i18n.NumberFormat('0.###E0;[0.###E0]');400 str = fmt.format(-1);401 assertEquals('[1E0]', str);402 fmt = new goog.i18n.NumberFormat('0.####E0');403 str = fmt.format(1);404 assertEquals('1E0', str);405 fmt = new goog.i18n.NumberFormat('00.000E00');406 str = fmt.format(1);407 assertEquals('10.000E-01', str);408 fmt = new goog.i18n.NumberFormat('##0.######E000');409 str = fmt.format(1);410 assertEquals('1E000', str);411 fmt = new goog.i18n.NumberFormat('0.###E0;[0.###E0]');412 str = fmt.format(1);413 assertEquals('1E0', str);414 fmt = new goog.i18n.NumberFormat('#E0');415 str = fmt.format(12345.0);416 assertEquals('1E4', str);417 fmt = new goog.i18n.NumberFormat('0E0');418 str = fmt.format(12345.0);419 assertEquals('1E4', str);420 fmt = new goog.i18n.NumberFormat('##0.###E0');421 str = fmt.format(12345.0);422 assertEquals('12.345E3', str);423 fmt = new goog.i18n.NumberFormat('##0.###E0');424 str = fmt.format(12345.00001);425 assertEquals('12.345E3', str);426 fmt = new goog.i18n.NumberFormat('##0.###E0');427 str = fmt.format(12345);428 assertEquals('12.345E3', str);429 fmt = new goog.i18n.NumberFormat('##0.####E0');430 str = fmt.format(789.12345e-9);431 // Firefox 3.6.3 Linux is known to fail here with a rounding error.432 // fmt.format will return '789.1234E-9'.433 expectedFailures.expectFailureFor(isFirefox363Linux());434 try {435 assertEquals('789.1235E-9', str);436 } catch (e) {437 expectedFailures.handleException(e);438 }439 fmt = new goog.i18n.NumberFormat('##0.####E0');440 str = fmt.format(780.e-9);441 assertEquals('780E-9', str);442 fmt = new goog.i18n.NumberFormat('.###E0');443 str = fmt.format(45678.0);444 assertEquals('.457E5', str);445 fmt = new goog.i18n.NumberFormat('.###E0');446 str = fmt.format(0);447 assertEquals('.0E0', str);448 fmt = new goog.i18n.NumberFormat('#E0');449 str = fmt.format(45678000);450 assertEquals('5E7', str);451 fmt = new goog.i18n.NumberFormat('##E0');452 str = fmt.format(45678000);453 assertEquals('46E6', str);454 fmt = new goog.i18n.NumberFormat('####E0');455 str = fmt.format(45678000);456 assertEquals('4568E4', str);457 fmt = new goog.i18n.NumberFormat('0E0');458 str = fmt.format(45678000);459 assertEquals('5E7', str);460 fmt = new goog.i18n.NumberFormat('00E0');461 str = fmt.format(45678000);462 assertEquals('46E6', str);463 fmt = new goog.i18n.NumberFormat('000E0');464 str = fmt.format(45678000);465 assertEquals('457E5', str);466 fmt = new goog.i18n.NumberFormat('###E0');467 str = fmt.format(0.0000123);468 assertEquals('12E-6', str);469 fmt = new goog.i18n.NumberFormat('###E0');470 str = fmt.format(0.000123);471 assertEquals('123E-6', str);472 fmt = new goog.i18n.NumberFormat('###E0');473 str = fmt.format(0.00123);474 assertEquals('1E-3', str);475 fmt = new goog.i18n.NumberFormat('###E0');476 str = fmt.format(0.0123);477 assertEquals('12E-3', str);478 fmt = new goog.i18n.NumberFormat('###E0');479 str = fmt.format(0.123);480 assertEquals('123E-3', str);481 fmt = new goog.i18n.NumberFormat('###E0');482 str = fmt.format(1.23);483 assertEquals('1E0', str);484 fmt = new goog.i18n.NumberFormat('###E0');485 str = fmt.format(12.3);486 assertEquals('12E0', str);487 fmt = new goog.i18n.NumberFormat('###E0');488 str = fmt.format(123.0);489 assertEquals('123E0', str);490 fmt = new goog.i18n.NumberFormat('###E0');491 str = fmt.format(1230.0);492 assertEquals('1E3', str);493}494function testPlusSignInExponentPart() {495 var fmt;496 fmt = new goog.i18n.NumberFormat('0E+0');497 str = fmt.format(45678000);498 assertEquals('5E+7', str);499}500function testGroupingParse2() {501 var value;502 var fmt;503 fmt = new goog.i18n.NumberFormat('#,###');504 value = fmt.parse('1,234,567,890');505 assertEquals(1234567890, value);506 fmt = new goog.i18n.NumberFormat('#,###');507 value = fmt.parse('12,3456,7890');508 assertEquals(1234567890, value);509 fmt = new goog.i18n.NumberFormat('#');510 value = fmt.parse('1234567890');511 assertEquals(1234567890, value);512}513function testApis() {514 var fmt;515 var str;516 fmt = new goog.i18n.NumberFormat('#,###');517 str = fmt.format(1234567890);518 assertEquals('1,234,567,890', str);519 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;-\u00a4#,##0.00');520 str = fmt.format(1234.56);521 assertEquals('$1,234.56', str);522 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;(\u00a4#,##0.00)');523 str = fmt.format(-1234.56);524 assertEquals('($1,234.56)', str);525 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;-\u00a4#,##0.00', 'SEK');526 str = fmt.format(1234.56);527 assertEquals('kr1,234.56', str);528 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;(\u00a4#,##0.00)', 'SEK');529 str = fmt.format(-1234.56);530 assertEquals('(kr1,234.56)', str);531}532function testLocaleSwitch() {533 goog.i18n.NumberFormatSymbols = goog.i18n.NumberFormatSymbols_fr;534 // When this test is performed in test cluster, 2 out of 60 machines have535 // problem getting the symbol. It is likely to be caused by size of uncompiled536 // symbol file. There will not be an issue after it is compiled.537 if (goog.i18n.NumberFormatSymbols.DECIMAL_SEP ==538 goog.i18n.NumberFormatSymbols_en.DECIMAL_SEP) {539 // fails to load French symbols, skip the test.540 return;541 }542 var fmt = new goog.i18n.NumberFormat('#,###');543 var str = fmt.format(1234567890);544 assertEquals('1\u00a0234\u00a0567\u00a0890', str);545 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;-\u00a4#,##0.00');546 str = fmt.format(1234.56);547 assertEquals('\u20AC1\u00a0234,56', str);548 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;(\u00a4#,##0.00)');549 str = fmt.format(-1234.56);550 assertEquals('(\u20AC1\u00a0234,56)', str);551 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;-\u00a4#,##0.00', 'SEK');552 str = fmt.format(1234.56);553 assertEquals('kr1\u00a0234,56', str);554 fmt = new goog.i18n.NumberFormat('\u00a4#,##0.00;(\u00a4#,##0.00)', 'SEK');555 str = fmt.format(-1234.56);556 assertEquals('(kr1\u00a0234,56)', str);557}558function testFrenchParse() {559 goog.i18n.NumberFormatSymbols = goog.i18n.NumberFormatSymbols_fr;560 // When this test is performed in test cluster, 2 out of 60 machines have561 // problem getting the symbol. It is likely to be caused by size of uncompiled562 // symbol file. There will not be an issue after it is compiled.563 if (goog.i18n.NumberFormatSymbols.DECIMAL_SEP ==564 goog.i18n.NumberFormatSymbols_en.DECIMAL_SEP) {565 // fails to load French symbols, skip the test.566 return;567 }568 var fmt = new goog.i18n.NumberFormat('0.0000');569 var value = fmt.parse('0,30');570 assertEquals(0.30, value);571 fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.CURRENCY);572 value = fmt.parse('0,30\u00A0\u20AC');573 assertEquals(0.30, value);574 fmt = new goog.i18n.NumberFormat('#,##0.00');575 value = fmt.parse('123 456,99');576 assertEquals(123456.99, value);577 fmt = new goog.i18n.NumberFormat('#,##0.00');578 value = fmt.parse('123\u00a0456,99');579 assertEquals(123456.99, value);580 fmt = new goog.i18n.NumberFormat('#,##0.00');581 value = fmt.parse('8 123\u00a0456,99');582 assertEquals(8123456.99, value);583}584function testFailParseShouldThrow() {585 var fmt = new goog.i18n.NumberFormat('0.0000');586 var value = fmt.parse('x');587 assertNaN(value);588 fmt = new goog.i18n.NumberFormat('0.000x');589 value = fmt.parse('3y');590 assertNaN(value);591 fmt = new goog.i18n.NumberFormat('x0.000');592 value = fmt.parse('y3');593 assertNaN(value);594}595/**596 * @return {boolean} Whether we're on Linux Firefox 3.6.3.597 */598function isFirefox363Linux() {599 return goog.userAgent.product.FIREFOX && goog.userAgent.LINUX &&600 goog.userAgent.product.isVersion('3.6.3') &&601 !goog.userAgent.product.isVersion('3.6.4');602}603function testEnforceAscii() {604 try {605 goog.i18n.NumberFormatSymbols.ZERO_DIGIT = 'A';606 var fmt = new goog.i18n.NumberFormat('0.0000');607 var str = fmt.format(123.45789179565757);608 assertEquals('BCD.EFHJ', str);609 goog.i18n.NumberFormat.setEnforceAsciiDigits(true);610 str = fmt.format(123.45789179565757);611 assertEquals('123.4579', str);612 goog.i18n.NumberFormat.setEnforceAsciiDigits(false);613 str = fmt.format(123.45789179565757);614 assertEquals('BCD.EFHJ', str);615 } finally {616 goog.i18n.NumberFormatSymbols.ZERO_DIGIT = '0';617 }618}619function testFractionDigits() {620 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.DECIMAL);621 fmt.setMinimumFractionDigits(4);622 fmt.setMaximumFractionDigits(6);623 assertEquals('0.1230', fmt.format(0.123));624 assertEquals('0.123456', fmt.format(0.123456));625 assertEquals('0.123457', fmt.format(0.12345678));626}627function testFractionDigitsSetOutOfOrder() {628 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.DECIMAL);629 // First, setup basic min/max630 fmt.setMinimumFractionDigits(2);631 fmt.setMaximumFractionDigits(2);632 // Now change to a lower min & max, but change the max value first so that it633 // is temporarily less than the current "min" value. This makes sure that we634 // don't throw an error.635 fmt.setMaximumFractionDigits(1);636 fmt.setMinimumFractionDigits(1);637 assertEquals('2.3', fmt.format(2.34));638}639function testFractionDigitsInvalid() {640 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.DECIMAL);641 fmt.setMinimumFractionDigits(2);642 fmt.setMaximumFractionDigits(1);643 try {644 fmt.format(0.123);645 fail('Should have thrown exception.');646 } catch (e) {}647}648function testSignificantDigitsEqualToMax() {649 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.DECIMAL);650 fmt.setMinimumFractionDigits(0);651 fmt.setMaximumFractionDigits(2);652 fmt.setSignificantDigits(2);653 assertEquals('123', fmt.format(123.4));654 assertEquals('12', fmt.format(12.34));655 assertEquals('1.2', fmt.format(1.234));656 assertEquals('0.12', fmt.format(0.1234));657 assertEquals('0.13', fmt.format(0.1284));658}659function testSignificantDigitsLessThanMax() {660 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.DECIMAL);661 fmt.setMinimumFractionDigits(0);662 fmt.setMaximumFractionDigits(4);663 fmt.setSignificantDigits(1);664 assertEquals('123', fmt.format(123.4));665 assertEquals('12', fmt.format(12.34));666 assertEquals('1', fmt.format(1.234));667 assertEquals('0.1', fmt.format(0.1234));668 assertEquals('0.2', fmt.format(0.1834));669}670function testSignificantDigitsMoreThanMax() {671 // Max fractional digits should be absolute672 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.DECIMAL);673 fmt.setMinimumFractionDigits(0);674 fmt.setMaximumFractionDigits(2);675 fmt.setSignificantDigits(3);676 assertEquals('123', fmt.format(123.4));677 assertEquals('12.3', fmt.format(12.34));678 assertEquals('1.23', fmt.format(1.234));679 assertEquals('0.12', fmt.format(0.1234));680 assertEquals('0.13', fmt.format(0.1284));681}682function testSimpleCompactFrench() {683 // Switch to French.684 goog.i18n.NumberFormatSymbols = goog.i18n.NumberFormatSymbols_fr;685 goog.i18n.CompactNumberFormatSymbols =686 goog.i18n.CompactNumberFormatSymbols_fr;687 var fmt = new goog.i18n.NumberFormat(688 goog.i18n.NumberFormat.Format.COMPACT_SHORT);689 var str = fmt.format(123400000);690 assertEquals('123\u00A0M', str);691}692function testSimpleCompactGerman() {693 // Switch to German.694 goog.i18n.NumberFormatSymbols = goog.i18n.NumberFormatSymbols_de;695 goog.i18n.CompactNumberFormatSymbols =696 goog.i18n.CompactNumberFormatSymbols_de;697 var fmt = new goog.i18n.NumberFormat(698 goog.i18n.NumberFormat.Format.COMPACT_SHORT);699 // The german short compact decimal has a simple '0' for 1000's, which is700 // supposed to be interpreted as 'leave the number as-is'.701 // (The number itself will still be formatted with the '.', but no rounding)702 var str = fmt.format(1234);703 assertEquals('1,2\u00A0Tsd', str);704}705function testSimpleCompact1() {706 var fmt = new goog.i18n.NumberFormat(707 goog.i18n.NumberFormat.Format.COMPACT_SHORT);708 var str = fmt.format(1234);709 assertEquals('1.2K', str);710}711function testSimpleCompact2() {712 var fmt = new goog.i18n.NumberFormat(713 goog.i18n.NumberFormat.Format.COMPACT_SHORT);714 var str = fmt.format(12345);715 assertEquals('12K', str);716}717function testRoundingCompact() {718 var fmt = new goog.i18n.NumberFormat(719 goog.i18n.NumberFormat.Format.COMPACT_SHORT);720 var str = fmt.format(999999);721 assertEquals('1M', str); //as opposed to 1000k722}723function testRoundingCompactNegative() {724 var fmt = new goog.i18n.NumberFormat(725 goog.i18n.NumberFormat.Format.COMPACT_SHORT);726 var str = fmt.format(-999999);727 assertEquals('-1M', str);728}729function testCompactSmall() {730 var fmt = new goog.i18n.NumberFormat(731 goog.i18n.NumberFormat.Format.COMPACT_SHORT);732 var str = fmt.format(0.1234);733 assertEquals('0.12', str);734}735function testCompactLong() {736 var fmt = new goog.i18n.NumberFormat(737 goog.i18n.NumberFormat.Format.COMPACT_LONG);738 var str = fmt.format(12345);739 assertEquals('12 thousand', str);740}741function testCompactWithoutSignificant() {742 var fmt = new goog.i18n.NumberFormat(743 goog.i18n.NumberFormat.Format.COMPACT_SHORT);744 fmt.setSignificantDigits(0);745 fmt.setMinimumFractionDigits(2);746 fmt.setMaximumFractionDigits(2);747 assertEquals('1.23K', fmt.format(1234));748 assertEquals('1.00K', fmt.format(1000));749 assertEquals('123.46K', fmt.format(123456.7));750 assertEquals('999.99K', fmt.format(999994));751 assertEquals('1.00M', fmt.format(999995));752}753function testCompactWithoutSignificant2() {754 var fmt = new goog.i18n.NumberFormat(755 goog.i18n.NumberFormat.Format.COMPACT_SHORT);756 fmt.setSignificantDigits(0);757 fmt.setMinimumFractionDigits(0);758 fmt.setMaximumFractionDigits(2);759 assertEquals('1.23K', fmt.format(1234));760 assertEquals('1K', fmt.format(1000));761 assertEquals('123.46K', fmt.format(123456.7));762 assertEquals('999.99K', fmt.format(999994));763 assertEquals('1M', fmt.format(999995));764}765function testShowTrailingZerosWithSignificantDigits() {766 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.DECIMAL);767 fmt.setSignificantDigits(2);768 fmt.setShowTrailingZeros(true);769 assertEquals('2.0', fmt.format(2));770 assertEquals('2,000', fmt.format(2000));771 assertEquals('0.20', fmt.format(0.2));772 assertEquals('0.02', fmt.format(0.02));773 assertEquals('0.002', fmt.format(0.002));774 assertEquals('0.00', fmt.format(0));775 fmt.setShowTrailingZeros(false);776 assertEquals('2', fmt.format(2));777 assertEquals('0.2', fmt.format(0.2));778}779function testShowTrailingZerosWithSignificantDigitsCompactShort() {780 var fmt = new goog.i18n.NumberFormat(781 goog.i18n.NumberFormat.Format.COMPACT_SHORT);782 fmt.setSignificantDigits(2);783 fmt.setShowTrailingZeros(true);784 assertEquals('2.0', fmt.format(2));785 assertEquals('2.0K', fmt.format(2000));786 assertEquals('20', fmt.format(20));787}788function testCurrencyCodeOrder() {789 goog.i18n.NumberFormatSymbols = goog.i18n.NumberFormatSymbols_fr;790 goog.i18n.CompactNumberFormatSymbols =791 goog.i18n.CompactNumberFormatSymbols_fr;792 var fmt = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.CURRENCY);793 assertFalse(fmt.isCurrencyCodeBeforeValue());794 goog.i18n.NumberFormatSymbols = goog.i18n.NumberFormatSymbols_en;795 goog.i18n.CompactNumberFormatSymbols =796 goog.i18n.CompactNumberFormatSymbols_en;797 var fmt1 = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.CURRENCY);798 assertTrue(fmt1.isCurrencyCodeBeforeValue());799 // Check that we really have different formatters with different patterns800 assertFalse(fmt.isCurrencyCodeBeforeValue());801 // Using custom patterns instead of standard locale ones802 fmt = new goog.i18n.NumberFormat('\u00A4 #0');803 assertTrue(fmt.isCurrencyCodeBeforeValue());804 fmt = new goog.i18n.NumberFormat('\u00A4 0 and #');805 assertTrue(fmt.isCurrencyCodeBeforeValue());806 fmt = new goog.i18n.NumberFormat('#0 \u00A4');807 assertFalse(fmt.isCurrencyCodeBeforeValue());808 fmt = new goog.i18n.NumberFormat('0 and # \u00A4');809 assertFalse(fmt.isCurrencyCodeBeforeValue());810 fmt = new goog.i18n.NumberFormat('\u00A4 0');811 assertTrue(fmt.isCurrencyCodeBeforeValue());812 fmt = new goog.i18n.NumberFormat('0 \u00A4');813 assertFalse(fmt.isCurrencyCodeBeforeValue());814 fmt = new goog.i18n.NumberFormat('\u00A4 #');815 assertTrue(fmt.isCurrencyCodeBeforeValue());816 fmt = new goog.i18n.NumberFormat('# \u00A4');817 assertFalse(fmt.isCurrencyCodeBeforeValue());818 // Edge cases, should never happen (like #0 separated by currency symbol,819 // or missing currency symbol, or missing both # and 0, or missing all)820 // We still make sure we get reasonable results (as much as possible)821 fmt = new goog.i18n.NumberFormat('0 \u00A4 #');822 assertFalse(fmt.isCurrencyCodeBeforeValue());823 fmt = new goog.i18n.NumberFormat('# \u00A4 0');824 assertFalse(fmt.isCurrencyCodeBeforeValue());825 fmt = new goog.i18n.NumberFormat('\u00A4');826 assertTrue(fmt.isCurrencyCodeBeforeValue()); // currency first, en_US style827 fmt = new goog.i18n.NumberFormat('0');828 assertTrue(fmt.isCurrencyCodeBeforeValue()); // currency first, en_US style829 fmt = new goog.i18n.NumberFormat('#');830 assertTrue(fmt.isCurrencyCodeBeforeValue()); // currency first, en_US style831 fmt = new goog.i18n.NumberFormat('#0');832 assertTrue(fmt.isCurrencyCodeBeforeValue()); // currency first, en_US style833 fmt = new goog.i18n.NumberFormat('0 and #');834 assertTrue(fmt.isCurrencyCodeBeforeValue()); // currency first, en_US style835 fmt = new goog.i18n.NumberFormat('nothing');836 assertTrue(fmt.isCurrencyCodeBeforeValue()); // currency first, en_US style837}838function testCompactWithBaseFormattingNumber() {839 var fmt = new goog.i18n.NumberFormat(840 goog.i18n.NumberFormat.Format.COMPACT_SHORT);841 fmt.setBaseFormatting(1000);842 assertEquals('0.8K', fmt.format(800, 1000));843 fmt.setBaseFormatting(null);844 assertEquals('800', fmt.format(800, 1000));845 fmt.setBaseFormatting(1000);846 assertEquals('1,200K', fmt.format(1200000, 1000));847 assertEquals('0.01K', fmt.format(10, 1000));848 fmt.setSignificantDigits(0);849 fmt.setMinimumFractionDigits(2);850 assertEquals('0.00K', fmt.format(1, 1000));851}852function testCompactWithBaseFormattingFrench() {853 // Switch to French.854 stubs.set(goog.i18n, 'NumberFormatSymbols', goog.i18n.NumberFormatSymbols_fr);855 stubs.set(goog.i18n, 'CompactNumberFormatSymbols',856 goog.i18n.CompactNumberFormatSymbols_fr);857 var fmt = new goog.i18n.NumberFormat(858 goog.i18n.NumberFormat.Format.COMPACT_SHORT);859 assertEquals('123\u00A0M', fmt.format(123400000));860 fmt.setBaseFormatting(1000);861 assertEquals('123\u00A0400\u00A0k', fmt.format(123400000));862}863function testGetBaseFormattingNumber() {864 var fmt = new goog.i18n.NumberFormat(865 goog.i18n.NumberFormat.Format.COMPACT_SHORT);866 assertEquals(null, fmt.getBaseFormatting());867 fmt.setBaseFormatting(10000);868 assertEquals(10000, fmt.getBaseFormatting());869}870// Moved Polish, Romanian, other currencies to tier 2, check that it works now871function testPolish() {872 goog.i18n.NumberFormatSymbols = goog.i18n.NumberFormatSymbols_pl;873 var fmPl = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.CURRENCY);874 goog.i18n.NumberFormatSymbols = goog.i18n.NumberFormatSymbols_ro;875 var fmRo = new goog.i18n.NumberFormat(goog.i18n.NumberFormat.Format.CURRENCY);876 goog.i18n.NumberFormatSymbols = goog.i18n.NumberFormatSymbols_en;877 assertEquals('100.00\u00A0z\u0142', fmPl.format(100)); // 100.00 zÅ878 assertEquals('100.00\u00A0RON', fmRo.format(100));...
results_to_excel.py
Source:results_to_excel.py
...33#init workbook34workbook = xlsxwriter.Workbook(out_name)35worksheet = workbook.add_worksheet()36#define styles37values_format = workbook.add_format({'align': 'center','border': 1})38blank_format = workbook.add_format({'align': 'center','border': 1})39bestvalue_format = workbook.add_format({'align': 'center', 'bold':True, 'border':1, 'bg_color':'green'})40bestvalueSTD_format = workbook.add_format({'align': 'center', 'bold':True, 'border':1, 'bg_color':'blue'})41header_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'green'})42parameters_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'yellow'})43loss_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'red'})44accuracy_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'orange'})45f1_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'cyan'})46precision_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'lime'})47recall_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'magenta'})48strp_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'brown'})49rmse_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'orange'})50mae_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'cyan'})51percs_format = workbook.add_format({'align': 'center', 'bold':True,'border': 1, 'bg_color':'#800080'})52separation_border = workbook.add_format({'border': 1,'bottom': 6, 'bottom_color':'#ff0000'})53#define column names54exp_id_c = 055parameters_c = 156comment1_c = 257comment2_c = 358train_loss_c = 459val_loss_c = 560test_loss_c = 661train_loss_std_c = 762val_loss_std_c = 863test_loss_std_c = 964if task_type == 'regression':65 train_rmse_c = 1066 val_rmse_c = 1167 test_rmse_c = 1268 train_rmse_std_c = 1369 val_rmse_std_c = 1470 test_rmse_std_c = 1571 train_mae_c = 1672 val_mae_c = 1773 test_mae_c = 1874 train_mae_std_c = 1975 val_mae_std_c = 2076 test_mae_std_c = 2177 end_c = 2178 if multiconv_is_used:79 train_strp_c = 2280 val_strp_c = 2381 test_strp_c = 2482 end_c = 2483elif task_type == 'classification':84 train_acc_c = 1085 val_acc_c = 1186 test_acc_c = 1287 train_acc_std_c = 1388 val_acc_std_c = 1489 test_acc_std_c = 1590 train_f1_c = 1691 val_f1_c = 1792 test_f1_c = 1893 train_f1_std_c = 1994 val_f1_std_c = 2095 test_f1_std_c = 2196 train_precision_c = 2297 val_precision_c = 2398 test_precision_c = 2499 train_precision_std_c = 25100 val_precision_std_c = 26101 test_precision_std_c = 27102 train_recall_c = 28103 val_recall_c = 29104 test_recall_c = 30105 train_recall_std_c = 31106 val_recall_std_c = 32107 test_recall_std_c = 33108 end_c = 33109 if multiconv_is_used:110 train_strp_c = 34111 val_strp_c = 35112 test_strp_c = 36113 end_c = 36114v_offset = 2115v_end = v_offset + num_exps + 1116#write header117#title118worksheet.merge_range(v_offset-2, exp_id_c, v_offset-2, end_c, "RESULTS", header_format)119#parameters120worksheet.merge_range(v_offset-1,exp_id_c, v_offset-1, comment2_c, "PARAMETERS", parameters_format)121#mean and std acc, loss, f1, precision, recall122#loss123worksheet.merge_range(v_offset-1,train_loss_c, v_offset-1, test_loss_c, "MEAN LOSS", loss_format)124worksheet.merge_range(v_offset-1,train_loss_std_c, v_offset-1, test_loss_std_c, "LOSS STD", loss_format)125if task_type == 'regression':126 #rmse127 worksheet.merge_range(v_offset-1,train_rmse_c, v_offset-1, test_rmse_c, "MEAN RMSE", rmse_format)128 worksheet.merge_range(v_offset-1,train_rmse_std_c, v_offset-1, test_rmse_std_c, "RMSE STD", rmse_format)129 #mae130 worksheet.merge_range(v_offset-1,train_mae_c, v_offset-1, test_mae_c, "MEAN MAE", mae_format)131 worksheet.merge_range(v_offset-1,train_mae_std_c, v_offset-1, test_mae_std_c, "MAE STD", mae_format)132elif task_type == 'classification':133 #acc134 worksheet.merge_range(v_offset-1,train_acc_c, v_offset-1, test_acc_c, " MEAN ACCURACY", accuracy_format)135 worksheet.merge_range(v_offset-1,train_acc_std_c, v_offset-1, test_acc_std_c, "ACCURACY STD", accuracy_format)136 #f1137 worksheet.merge_range(v_offset-1,train_f1_c, v_offset-1, test_f1_c, " MEAN F1", f1_format)138 worksheet.merge_range(v_offset-1,train_f1_std_c, v_offset-1, test_f1_std_c, "F1 STD", f1_format)139 #precision140 worksheet.merge_range(v_offset-1,train_precision_c, v_offset-1, test_precision_c, " MEAN PRECISION", precision_format)141 worksheet.merge_range(v_offset-1,train_precision_std_c, v_offset-1, test_precision_std_c, "PRECISION STD", precision_format)142 #recall143 worksheet.merge_range(v_offset-1,train_recall_c, v_offset-1, test_recall_c, " MEAN RECALL", recall_format)144 worksheet.merge_range(v_offset-1,train_recall_std_c, v_offset-1, test_recall_std_c, "RECALL STD", recall_format)145if multiconv_is_used:146 worksheet.merge_range(v_offset-1,train_strp_c, v_offset-1, test_strp_c, "% USAGE MULTICONV", strp_format)147#write column names148worksheet.write(v_offset, exp_id_c, 'ID',parameters_format)149worksheet.set_column(exp_id_c,exp_id_c,6)150worksheet.write(v_offset, comment1_c, 'comment 1',parameters_format)151worksheet.set_column(comment1_c,comment1_c,35)152worksheet.write(v_offset, comment2_c, 'comment 2',parameters_format)153worksheet.set_column(comment2_c,comment2_c,35)154worksheet.write(v_offset, parameters_c, 'link to parameters',parameters_format)155worksheet.set_column(parameters_c,parameters_c,35)156worksheet.write(v_offset, train_loss_c, 'train',loss_format)157worksheet.write(v_offset, val_loss_c, 'val',loss_format)158worksheet.write(v_offset, test_loss_c, 'test',loss_format)159worksheet.write(v_offset, train_loss_std_c, 'train',loss_format)160worksheet.write(v_offset, val_loss_std_c, 'val',loss_format)161worksheet.write(v_offset, test_loss_std_c, 'test',loss_format)162if task_type == 'regression':163 worksheet.write(v_offset, train_rmse_c, 'train',rmse_format)164 worksheet.write(v_offset, val_rmse_c, 'val',rmse_format)165 worksheet.write(v_offset, test_rmse_c, 'test',rmse_format)166 worksheet.write(v_offset, train_mae_c, 'train',mae_format)167 worksheet.write(v_offset, val_mae_c, 'val',mae_format)168 worksheet.write(v_offset, test_mae_c, 'test',mae_format)169 worksheet.write(v_offset, train_rmse_std_c, 'train',rmse_format)170 worksheet.write(v_offset, val_rmse_std_c, 'val',rmse_format)171 worksheet.write(v_offset, test_rmse_std_c, 'test',rmse_format)172 worksheet.write(v_offset, train_mae_std_c, 'train',mae_format)173 worksheet.write(v_offset, val_mae_std_c, 'val',mae_format)174 worksheet.write(v_offset, test_mae_std_c, 'test',mae_format)175elif task_type == 'classification':176 worksheet.write(v_offset, train_acc_c, 'train',accuracy_format)177 worksheet.write(v_offset, val_acc_c, 'val',accuracy_format)178 worksheet.write(v_offset, test_acc_c, 'test',accuracy_format)179 worksheet.write(v_offset, train_f1_c, 'train',f1_format)180 worksheet.write(v_offset, val_f1_c, 'val',f1_format)181 worksheet.write(v_offset, test_f1_c, 'test',f1_format)182 worksheet.write(v_offset, train_precision_c, 'train',precision_format)183 worksheet.write(v_offset, val_precision_c, 'val',precision_format)184 worksheet.write(v_offset, test_precision_c, 'test',precision_format)185 worksheet.write(v_offset, train_recall_c, 'train',recall_format)186 worksheet.write(v_offset, val_recall_c, 'val',recall_format)187 worksheet.write(v_offset, test_recall_c, 'test',recall_format)188 worksheet.write(v_offset, train_acc_std_c, 'train',accuracy_format)189 worksheet.write(v_offset, val_acc_std_c, 'val',accuracy_format)190 worksheet.write(v_offset, test_acc_std_c, 'test',accuracy_format)191 worksheet.write(v_offset, train_f1_std_c, 'train',f1_format)192 worksheet.write(v_offset, val_f1_std_c, 'val',f1_format)193 worksheet.write(v_offset, test_f1_std_c, 'test',f1_format)194 worksheet.write(v_offset, train_precision_std_c, 'train',precision_format)195 worksheet.write(v_offset, val_precision_std_c, 'val',precision_format)196 worksheet.write(v_offset, test_precision_std_c, 'test',precision_format)197 worksheet.write(v_offset, train_recall_std_c, 'train',recall_format)198 worksheet.write(v_offset, val_recall_std_c, 'val',recall_format)199 worksheet.write(v_offset, test_recall_std_c, 'test',recall_format)200 worksheet.set_column(train_acc_c,test_loss_std_c,10)201if multiconv_is_used:202 worksheet.write(v_offset, train_strp_c, 'train',strp_format)203 worksheet.write(v_offset, val_strp_c, 'val',strp_format)204 worksheet.write(v_offset, test_strp_c, 'test',strp_format)205 worksheet.set_column(test_strp_c,test_strp_c,40)206#fill values207#iterate every experiment208for i in contents:209 if '.npy' in i:210 temp_path = os.path.join(in_folder, i)211 dict = np.load(temp_path, allow_pickle=True)212 dict = dict.item()213 keys = dict[0].keys()214 #print grobal parameters215 #write ID216 print ('cazzo')217 print (i)218 exp_ID = i.split('_')[-1].split('.')[0][3:]219 curr_row = int(exp_ID)+v_offset220 worksheet.write(curr_row, exp_id_c, exp_ID,values_format)221 #write comment222 parameters = dict['summary']['parameters'].split('/')223 comment_1 = '/'224 comment_2 = '/'225 for par in parameters:226 if 'comment_1' in par:227 comment_1 = par.split('=')[1].replace('"', '')228 if 'comment_2' in par:229 comment_2 = par.split('=')[1].replace('"', '')230 worksheet.write(curr_row, comment1_c, comment_1,values_format)231 worksheet.write(curr_row, comment2_c, comment_2,values_format)232 #write parameters link233 split_par = i.split('.')[0].split('_')234 curr_par_name = 'parameters/parameters_' + split_par[1] + '_' + split_par[2] + '_' + split_par[3] + '.txt'235 worksheet.write_url(curr_row, parameters_c, 'external:'+curr_par_name)236 #extract losses237 tr = dict['summary']['training']238 val = dict['summary']['validation']239 test = dict['summary']['test']240 tr_loss = tr['mean_loss']241 tr_loss_std = tr['loss_std']242 val_loss = val['mean_loss']243 val_loss_std = val['loss_std']244 test_loss = test['mean_loss']245 test_loss_std = test['loss_std']246 if task_type == 'regression':247 #training results248 tr_rmse = tr['mean_RMSE']249 tr_mae = tr['mean_MAE']250 tr_rmse_std = tr['RMSE_std']251 tr_mae_std = tr['MAE_std']252 #val results253 val_rmse = val['mean_RMSE']254 val_mae = val['mean_MAE']255 val_rmse_std = val['RMSE_std']256 val_mae_std = val['MAE_std']257 #test results258 test_rmse = test['mean_RMSE']259 test_mae = test['mean_MAE']260 test_rmse_std = test['RMSE_std']261 test_mae_std = test['MAE_std']262 elif task_type == 'classification':263 #extract results264 #training results265 tr_acc = tr['mean_acc']266 tr_f1 = tr['mean_f1']267 tr_precision = tr['mean_precision']268 tr_recall = tr['mean_recall']269 tr_acc_std = tr['acc_std']270 tr_f1_std = tr['f1_std']271 tr_precision_std = tr['precision_std']272 tr_recall_std = tr['recall_std']273 #validation results274 val_acc = val['mean_acc']275 val_f1 = val['mean_f1']276 val_precision = val['mean_precision']277 val_recall = val['mean_recall']278 val_acc_std = val['acc_std']279 val_f1_std = val['f1_std']280 val_precision_std = val['precision_std']281 val_recall_std = val['recall_std']282 #test results283 test_acc = test['mean_acc']284 test_f1 = test['mean_f1']285 test_precision = test['mean_precision']286 test_recall = test['mean_recall']287 test_acc_std = test['acc_std']288 test_f1_std = test['f1_std']289 test_precision_std = test['precision_std']290 test_recall_std = test['recall_std']291 train_strp = '/'292 val_strp = '/'293 test_strp = '/'294 try:295 #stretch percs296 train_strp = tr['mean_stretch_percs']297 val_strp = val['mean_stretch_percs']298 test_strp = val['mean_stretch_percs']299 except KeyError:300 pass301 #print results302 #loss303 worksheet.write(curr_row, train_loss_c, tr_loss,values_format)304 worksheet.write(curr_row, val_loss_c, val_loss,values_format)305 worksheet.write(curr_row, test_loss_c, test_loss,values_format)306 #loss std307 worksheet.write(curr_row, train_loss_std_c, tr_loss_std,values_format)308 worksheet.write(curr_row, val_loss_std_c, val_loss_std,values_format)309 worksheet.write(curr_row, test_loss_std_c, test_loss_std,values_format)310 if task_type == 'regression':311 #rmse312 worksheet.write(curr_row, train_rmse_c, tr_rmse,values_format)313 worksheet.write(curr_row, val_rmse_c, val_rmse,values_format)314 worksheet.write(curr_row, test_rmse_c, test_rmse,values_format)315 #rmse std316 worksheet.write(curr_row, train_rmse_std_c, tr_rmse_std,values_format)317 worksheet.write(curr_row, val_rmse_std_c, val_rmse_std,values_format)318 worksheet.write(curr_row, test_rmse_std_c, test_rmse_std,values_format)319 #mae320 worksheet.write(curr_row, train_mae_c, tr_mae,values_format)321 worksheet.write(curr_row, val_mae_c, val_mae,values_format)322 worksheet.write(curr_row, test_mae_c, test_mae,values_format)323 #mae std324 worksheet.write(curr_row, train_mae_std_c, tr_mae_std,values_format)325 worksheet.write(curr_row, val_mae_std_c, val_mae_std,values_format)326 worksheet.write(curr_row, test_mae_std_c, test_mae_std,values_format)327 elif task_type == 'classification':328 #acc329 worksheet.write(curr_row, train_acc_c, tr_acc,values_format)330 worksheet.write(curr_row, val_acc_c, val_acc,values_format)331 worksheet.write(curr_row, test_acc_c, test_acc,values_format)332 #acc std333 worksheet.write(curr_row, train_acc_std_c, tr_acc_std,values_format)334 worksheet.write(curr_row, val_acc_std_c, val_acc_std,values_format)335 worksheet.write(curr_row, test_acc_std_c, test_acc_std,values_format)336 #f1337 worksheet.write(curr_row, train_f1_c, tr_f1,values_format)338 worksheet.write(curr_row, val_f1_c, val_f1,values_format)339 worksheet.write(curr_row, test_f1_c, test_f1,values_format)340 #f1 std341 worksheet.write(curr_row, train_f1_std_c, tr_f1_std,values_format)342 worksheet.write(curr_row, val_f1_std_c, val_f1_std,values_format)343 worksheet.write(curr_row, test_f1_std_c, test_f1_std,values_format)344 #precision345 worksheet.write(curr_row, train_precision_c, tr_precision,values_format)346 worksheet.write(curr_row, val_precision_c, val_precision,values_format)347 worksheet.write(curr_row, test_precision_c, test_precision,values_format)348 #precision std349 worksheet.write(curr_row, train_precision_std_c, tr_precision_std,values_format)350 worksheet.write(curr_row, val_precision_std_c, val_precision_std,values_format)351 worksheet.write(curr_row, test_precision_std_c, test_precision_std,values_format)352 #recall353 worksheet.write(curr_row, train_recall_c, tr_recall,values_format)354 worksheet.write(curr_row, val_recall_c, val_recall,values_format)355 worksheet.write(curr_row, test_recall_c, test_recall,values_format)356 #recall std357 worksheet.write(curr_row, train_recall_std_c, tr_recall_std,values_format)358 worksheet.write(curr_row, val_recall_std_c, val_recall_std,values_format)359 worksheet.write(curr_row, test_recall_std_c, test_recall_std,values_format)360 #stretch percs361 if multiconv_is_used:362 worksheet.write(curr_row, train_strp_c, str(train_strp),values_format)363 worksheet.write(curr_row, val_strp_c, str(val_strp),values_format)364 worksheet.write(curr_row, test_strp_c, str(test_strp),values_format)365explist = list(range(1, num_exps+1))366endlist = []367#apply blank formatting to blank and non-ending lines368#this is necessary due to a bug369for end in explist:370 #if end not in endlist:371 if end not in []:372 worksheet.conditional_format( v_offset+end,0,v_offset+end,end_c, {'type': 'blanks','format': blank_format})373#highlight best values374#loss375worksheet.conditional_format(v_offset, train_loss_c, v_offset+num_exps, train_loss_c,376 {'type': 'bottom','value': '1','format': bestvalue_format})377worksheet.conditional_format(v_offset, val_loss_c, v_offset+num_exps, val_loss_c,378 {'type': 'bottom','value': '1','format': bestvalue_format})379worksheet.conditional_format(v_offset, test_loss_c, v_offset+num_exps, test_loss_c,380 {'type': 'bottom','value': '1','format': bestvalue_format})381#loss std382worksheet.conditional_format(v_offset, train_loss_std_c, v_offset+num_exps, train_loss_std_c,383 {'type': 'bottom','value': '1','format': bestvalueSTD_format})384worksheet.conditional_format(v_offset, val_loss_std_c, v_offset+num_exps, val_loss_std_c,385 {'type': 'bottom','value': '1','format': bestvalueSTD_format})386worksheet.conditional_format(v_offset, test_loss_std_c, v_offset+num_exps, test_loss_std_c,387 {'type': 'bottom','value': '1','format': bestvalueSTD_format})388if task_type == 'regression':389 #rmse390 worksheet.conditional_format(v_offset, train_rmse_c, v_offset+num_exps, train_rmse_c,391 {'type': 'bottom','value': '1','format': bestvalue_format})392 worksheet.conditional_format(v_offset, val_rmse_c, v_offset+num_exps, val_rmse_c,393 {'type': 'bottom','value': '1','format': bestvalue_format})394 worksheet.conditional_format(v_offset, test_rmse_c, v_offset+num_exps, test_rmse_c,395 {'type': 'bottom','value': '1','format': bestvalue_format})396 #rmse std397 worksheet.conditional_format(v_offset, train_rmse_std_c, v_offset+num_exps, train_rmse_std_c,398 {'type': 'bottom','value': '1','format': bestvalueSTD_format})399 worksheet.conditional_format(v_offset, val_rmse_std_c, v_offset+num_exps, val_rmse_std_c,400 {'type': 'bottom','value': '1','format': bestvalueSTD_format})401 worksheet.conditional_format(v_offset, test_rmse_std_c, v_offset+num_exps, test_rmse_std_c,402 {'type': 'bottom','value': '1','format': bestvalueSTD_format})403 #mae404 worksheet.conditional_format(v_offset, train_mae_c, v_offset+num_exps, train_mae_c,405 {'type': 'bottom','value': '1','format': bestvalue_format})406 worksheet.conditional_format(v_offset, val_mae_c, v_offset+num_exps, val_mae_c,407 {'type': 'bottom','value': '1','format': bestvalue_format})408 worksheet.conditional_format(v_offset, test_mae_c, v_offset+num_exps, test_mae_c,409 {'type': 'bottom','value': '1','format': bestvalue_format})410 #mae std411 worksheet.conditional_format(v_offset, train_mae_std_c, v_offset+num_exps, train_mae_std_c,412 {'type': 'bottom','value': '1','format': bestvalueSTD_format})413 worksheet.conditional_format(v_offset, val_mae_std_c, v_offset+num_exps, val_mae_std_c,414 {'type': 'bottom','value': '1','format': bestvalueSTD_format})415 worksheet.conditional_format(v_offset, test_mae_std_c, v_offset+num_exps, test_mae_std_c,416 {'type': 'bottom','value': '1','format': bestvalueSTD_format})417elif task_type == 'classification':418#acc419 worksheet.conditional_format(v_offset, train_acc_c, v_offset+num_exps, train_acc_c,420 {'type': 'top','value': '1','format': bestvalue_format})421 worksheet.conditional_format(v_offset, val_acc_c, v_offset+num_exps, val_acc_c,422 {'type': 'top','value': '1','format': bestvalue_format})423 worksheet.conditional_format(v_offset, test_acc_c, v_offset+num_exps, test_acc_c,424 {'type': 'top','value': '1','format': bestvalue_format})425 #acc std426 worksheet.conditional_format(v_offset, train_acc_std_c, v_offset+num_exps, train_acc_std_c,427 {'type': 'bottom','value': '1','format': bestvalueSTD_format})428 worksheet.conditional_format(v_offset, val_acc_std_c, v_offset+num_exps, val_acc_std_c,429 {'type': 'bottom','value': '1','format': bestvalueSTD_format})430 worksheet.conditional_format(v_offset, test_acc_std_c, v_offset+num_exps, test_acc_std_c,431 {'type': 'bottom','value': '1','format': bestvalueSTD_format})432 #f1433 worksheet.conditional_format(v_offset, train_f1_c, v_offset+num_exps, train_f1_c,434 {'type': 'top','value': '1','format': bestvalue_format})435 worksheet.conditional_format(v_offset, val_f1_c, v_offset+num_exps, val_f1_c,436 {'type': 'top','value': '1','format': bestvalue_format})437 worksheet.conditional_format(v_offset, test_f1_c, v_offset+num_exps, test_f1_c,438 {'type': 'top','value': '1','format': bestvalue_format})439 #f1 std440 worksheet.conditional_format(v_offset, train_f1_std_c, v_offset+num_exps, train_f1_std_c,441 {'type': 'bottom','value': '1','format': bestvalueSTD_format})442 worksheet.conditional_format(v_offset, val_f1_std_c, v_offset+num_exps, val_f1_std_c,443 {'type': 'bottom','value': '1','format': bestvalueSTD_format})444 worksheet.conditional_format(v_offset, test_f1_std_c, v_offset+num_exps, test_f1_std_c,445 {'type': 'bottom','value': '1','format': bestvalueSTD_format})446 #precision447 worksheet.conditional_format(v_offset, train_precision_c, v_offset+num_exps, train_precision_c,448 {'type': 'top','value': '1','format': bestvalue_format})449 worksheet.conditional_format(v_offset, val_precision_c, v_offset+num_exps, val_precision_c,450 {'type': 'top','value': '1','format': bestvalue_format})451 worksheet.conditional_format(v_offset, test_precision_c, v_offset+num_exps, test_precision_c,452 {'type': 'top','value': '1','format': bestvalue_format})453 #precision std454 worksheet.conditional_format(v_offset, train_precision_std_c, v_offset+num_exps, train_precision_std_c,455 {'type': 'bottom','value': '1','format': bestvalueSTD_format})456 worksheet.conditional_format(v_offset, val_precision_std_c, v_offset+num_exps, val_precision_std_c,457 {'type': 'bottom','value': '1','format': bestvalueSTD_format})458 worksheet.conditional_format(v_offset, test_precision_std_c, v_offset+num_exps, test_precision_std_c,459 {'type': 'bottom','value': '1','format': bestvalueSTD_format})460 #recall461 worksheet.conditional_format(v_offset, train_recall_c, v_offset+num_exps, train_recall_c,462 {'type': 'top','value': '1','format': bestvalue_format})463 worksheet.conditional_format(v_offset, val_recall_c, v_offset+num_exps, val_recall_c,464 {'type': 'top','value': '1','format': bestvalue_format})465 worksheet.conditional_format(v_offset, test_recall_c, v_offset+num_exps, test_recall_c,466 {'type': 'top','value': '1','format': bestvalue_format})467 #recall std468 worksheet.conditional_format(v_offset, train_recall_std_c, v_offset+num_exps, train_recall_std_c,469 {'type': 'bottom','value': '1','format': bestvalueSTD_format})470 worksheet.conditional_format(v_offset, val_recall_std_c, v_offset+num_exps, val_recall_std_c,471 {'type': 'bottom','value': '1','format': bestvalueSTD_format})472 worksheet.conditional_format(v_offset, test_recall_std_c, v_offset+num_exps, test_recall_std_c,473 {'type': 'bottom','value': '1','format': bestvalueSTD_format})...
format-test.js
Source:format-test.js
...5suite.addBatch({6 "format": {7 topic: load("format/format").expression("d3.format"),8 "returns a string": function(format) {9 assert.isString(format("d")(0));10 },11 "can zero fill": function(format) {12 var f = format("08d");13 assert.strictEqual(f(0), "00000000");14 assert.strictEqual(f(42), "00000042");15 assert.strictEqual(f(42000000), "42000000");16 assert.strictEqual(f(420000000), "420000000");17 assert.strictEqual(f(-4), "-0000004");18 assert.strictEqual(f(-42), "-0000042");19 assert.strictEqual(f(-4200000), "-4200000");20 assert.strictEqual(f(-42000000), "-42000000");21 },22 "can space fill": function(format) {23 var f = format("8d");24 assert.strictEqual(f(0), " 0");25 assert.strictEqual(f(42), " 42");26 assert.strictEqual(f(42000000), "42000000");27 assert.strictEqual(f(420000000), "420000000");28 assert.strictEqual(f(-4), " -4");29 assert.strictEqual(f(-42), " -42");30 assert.strictEqual(f(-4200000), "-4200000");31 assert.strictEqual(f(-42000000), "-42000000");32 },33 "can output fixed-point notation": function(format) {34 assert.strictEqual(format(".1f")(0.49), "0.5");35 assert.strictEqual(format(".2f")(0.449), "0.45");36 assert.strictEqual(format(".3f")(0.4449), "0.445");37 assert.strictEqual(format(".5f")(0.444449), "0.44445");38 assert.strictEqual(format(".1f")(100), "100.0");39 assert.strictEqual(format(".2f")(100), "100.00");40 assert.strictEqual(format(".3f")(100), "100.000");41 assert.strictEqual(format(".5f")(100), "100.00000");42 },43 "can output general notation": function(format) {44 assert.strictEqual(format(".1g")(0.049), "0.05");45 assert.strictEqual(format(".1g")(0.49), "0.5");46 assert.strictEqual(format(".2g")(0.449), "0.45");47 assert.strictEqual(format(".3g")(0.4449), "0.445");48 assert.strictEqual(format(".5g")(0.444449), "0.44445");49 assert.strictEqual(format(".1g")(100), "1e+2");50 assert.strictEqual(format(".2g")(100), "1.0e+2");51 assert.strictEqual(format(".3g")(100), "100");52 assert.strictEqual(format(".5g")(100), "100.00");53 assert.strictEqual(format(".5g")(100.2), "100.20");54 assert.strictEqual(format(".2g")(0.002), "0.0020");55 },56 "can output exponent notation ": function(format) {57 var f = format("e");58 assert.strictEqual(f(0), "0e+0");59 assert.strictEqual(f(42), "4.2e+1");60 assert.strictEqual(f(42000000), "4.2e+7");61 assert.strictEqual(f(420000000), "4.2e+8");62 assert.strictEqual(f(-4), "-4e+0");63 assert.strictEqual(f(-42), "-4.2e+1");64 assert.strictEqual(f(-4200000), "-4.2e+6");65 assert.strictEqual(f(-42000000), "-4.2e+7");66 assert.strictEqual(format(".0e")(42), "4e+1")67 assert.strictEqual(format(".3e")(42), "4.200e+1")68 },69 "can output SI prefix notation": function(format) {70 var f = format("s");71 assert.strictEqual(f(0), "0");72 assert.strictEqual(f(1), "1");73 assert.strictEqual(f(10), "10");74 assert.strictEqual(f(100), "100");75 assert.strictEqual(f(999.5), "999.5");76 assert.strictEqual(f(999500), "999.5k");77 assert.strictEqual(f(1000), "1k");78 assert.strictEqual(f(1400), "1.4k");79 assert.strictEqual(f(1500.5), "1.5005k");80 assert.strictEqual(f(0.000001), "1µ");81 },82 "can output SI prefix notation with appropriate rounding": function(format) {83 var f = format(".3s");84 assert.strictEqual(f(0), "0.00");85 assert.strictEqual(f(1), "1.00");86 assert.strictEqual(f(10), "10.0");87 assert.strictEqual(f(100), "100");88 assert.strictEqual(f(999.5), "1.00k");89 assert.strictEqual(f(999500), "1.00M");90 assert.strictEqual(f(1000), "1.00k");91 assert.strictEqual(f(1500.5), "1.50k");92 assert.strictEqual(f(145500000), "146M");93 assert.strictEqual(f(145999999.999999347), "146M");94 assert.strictEqual(f(1e26), "100Y");95 assert.strictEqual(f(0.000001), "1.00µ");96 assert.strictEqual(f(0.009995), "10.0m");97 var f = format(".4s");98 assert.strictEqual(f(999.5), "999.5");99 assert.strictEqual(f(999500), "999.5k");100 assert.strictEqual(f(0.009995), "9.995m");101 },102 "can output SI prefix notation with appropriate rounding and currency symbol": function(format) {103 var f = format("$.3s");104 assert.strictEqual(f(0), "$0.00");105 assert.strictEqual(f(1), "$1.00");106 assert.strictEqual(f(10), "$10.0");107 assert.strictEqual(f(100), "$100");108 assert.strictEqual(f(999.5), "$1.00k");109 assert.strictEqual(f(999500), "$1.00M");110 assert.strictEqual(f(1000), "$1.00k");111 assert.strictEqual(f(1500.5), "$1.50k");112 assert.strictEqual(f(145500000), "$146M");113 assert.strictEqual(f(145999999.999999347), "$146M");114 assert.strictEqual(f(1e26), "$100Y");115 assert.strictEqual(f(0.000001), "$1.00µ");116 assert.strictEqual(f(0.009995), "$10.0m");117 var f = format("$.4s");118 assert.strictEqual(f(999.5), "$999.5");119 assert.strictEqual(f(999500), "$999.5k");120 assert.strictEqual(f(0.009995), "$9.995m");121 },122 "SI prefix notation precision is consistent for small and large numbers": function(format) {123 assert.deepEqual(124 [ 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e-0, 1e1, 1e2, 1e3, 1e4, 1e5].map(format("s")),125 [ '10µ', '100µ', '1m', '10m', '100m', '1', '10', '100', '1k', '10k', '100k']);126 assert.deepEqual(127 [ 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e-0, 1e1, 1e2, 1e3, 1e4, 1e5].map(format(".4s")),128 ['10.00µ', '100.0µ', '1.000m', '10.00m', '100.0m', '1.000', '10.00', '100.0', '1.000k', '10.00k', '100.0k']);129 },130 "can output a currency": function(format) {131 var f = format("$");132 assert.strictEqual(f(0), "$0");133 assert.strictEqual(f(0.042), "$0.042");134 assert.strictEqual(f(0.42), "$0.42");135 assert.strictEqual(f(4.2), "$4.2");136 assert.strictEqual(f(-0.042), "-$0.042");137 assert.strictEqual(f(-0.42), "-$0.42");138 assert.strictEqual(f(-4.2), "-$4.2");139 },140 "can output a currency with comma-grouping and sign": function(format) {141 var f = format("+$,.2f");142 assert.strictEqual(f(0), "+$0.00");143 assert.strictEqual(f(0.429), "+$0.43");144 assert.strictEqual(f(-0.429), "-$0.43");145 assert.strictEqual(f(-1), "-$1.00");146 assert.strictEqual(f(1e4), "+$10,000.00");147 },148 "can output a currency with si-prefix notation": function(format) {149 var f = format("$.2s");150 assert.strictEqual(f(0), "$0.0");151 assert.strictEqual(f(2.5e5), "$250k");152 assert.strictEqual(f(-2.5e8), "-$250M");153 assert.strictEqual(f(2.5e11), "$250G");154 },155 "can output a percentage": function(format) {156 var f = format("%");157 assert.strictEqual(f(0), "0%");158 assert.strictEqual(f(0.042), "4%");159 assert.strictEqual(f(0.42), "42%");160 assert.strictEqual(f(4.2), "420%");161 assert.strictEqual(f(-0.042), "-4%");162 assert.strictEqual(f(-0.42), "-42%");163 assert.strictEqual(f(-4.2), "-420%");164 },165 "can output a percentage with rounding and sign": function(format) {166 var f = format("+.2p");167 assert.strictEqual(f(0.00123), "+0.12%");168 assert.strictEqual(f(0.0123), "+1.2%");169 assert.strictEqual(f(0.123), "+12%");170 assert.strictEqual(f(1.23), "+120%");171 assert.strictEqual(f(-0.00123), "-0.12%");172 assert.strictEqual(f(-0.0123), "-1.2%");173 assert.strictEqual(f(-0.123), "-12%");174 assert.strictEqual(f(-1.23), "-120%");175 },176 "can round to significant digits": function(format) {177 assert.strictEqual(format(".2r")(0), "0.0");178 assert.strictEqual(format(".1r")(0.049), "0.05");179 assert.strictEqual(format(".1r")(-0.049), "-0.05");180 assert.strictEqual(format(".1r")(0.49), "0.5");181 assert.strictEqual(format(".1r")(-0.49), "-0.5");182 assert.strictEqual(format(".2r")(0.449), "0.45");183 assert.strictEqual(format(".3r")(0.4449), "0.445");184 assert.strictEqual(format(".3r")(1.00), "1.00");185 assert.strictEqual(format(".3r")(0.9995), "1.00");186 assert.strictEqual(format(".5r")(0.444449), "0.44445");187 assert.strictEqual(format("r")(123.45), "123.45");188 assert.strictEqual(format(".1r")(123.45), "100");189 assert.strictEqual(format(".2r")(123.45), "120");190 assert.strictEqual(format(".3r")(123.45), "123");191 assert.strictEqual(format(".4r")(123.45), "123.5");192 assert.strictEqual(format(".5r")(123.45), "123.45");193 assert.strictEqual(format(".6r")(123.45), "123.450");194 assert.strictEqual(format(".1r")(0.9), "0.9");195 assert.strictEqual(format(".1r")(0.09), "0.09");196 assert.strictEqual(format(".1r")(0.949), "0.9");197 assert.strictEqual(format(".1r")(0.0949), "0.09");198 assert.strictEqual(format(".10r")(0.9999999999), "0.9999999999");199 assert.strictEqual(format(".15r")(0.999999999999999), "0.999999999999999");200 },201 "can round very small numbers": function(format) {202 var f = format(".2r");203 assert.strictEqual(f(1e-22), "0.00000000000000000000");204 },205 "can group thousands": function(format) {206 var f = format(",d");207 assert.strictEqual(f(0), "0");208 assert.strictEqual(f(42), "42");209 assert.strictEqual(f(42000000), "42,000,000");210 assert.strictEqual(f(420000000), "420,000,000");211 assert.strictEqual(f(-4), "-4");212 assert.strictEqual(f(-42), "-42");213 assert.strictEqual(f(-4200000), "-4,200,000");214 assert.strictEqual(f(-42000000), "-42,000,000");215 assert.strictEqual(f(1e21), "1e+21");216 },217 "can group thousands and zero fill": function(format) {218 assert.strictEqual(format("01,d")(0), "0");219 assert.strictEqual(format("01,d")(0), "0");220 assert.strictEqual(format("02,d")(0), "00");221 assert.strictEqual(format("03,d")(0), "000");222 assert.strictEqual(format("04,d")(0), "0,000");223 assert.strictEqual(format("05,d")(0), "0,000");224 assert.strictEqual(format("06,d")(0), "00,000");225 assert.strictEqual(format("08,d")(0), "0,000,000");226 assert.strictEqual(format("013,d")(0), "0,000,000,000");227 assert.strictEqual(format("021,d")(0), "0,000,000,000,000,000");228 assert.strictEqual(format("013,d")(-42000000), "-0,042,000,000");229 assert.strictEqual(format("012,d")(1e21), "0,000,001e+21");230 assert.strictEqual(format("013,d")(1e21), "0,000,001e+21");231 assert.strictEqual(format("014,d")(1e21), "00,000,001e+21");232 assert.strictEqual(format("015,d")(1e21), "000,000,001e+21");233 },234 "can group thousands and zero fill with overflow": function(format) {235 assert.strictEqual(format("01,d")(1), "1");236 assert.strictEqual(format("01,d")(1), "1");237 assert.strictEqual(format("02,d")(12), "12");238 assert.strictEqual(format("03,d")(123), "123");239 assert.strictEqual(format("05,d")(12345), "12,345");240 assert.strictEqual(format("08,d")(12345678), "12,345,678");241 assert.strictEqual(format("013,d")(1234567890123), "1,234,567,890,123");242 },243 "can group thousands and space fill": function(format) {244 assert.strictEqual(format("1,d")(0), "0");245 assert.strictEqual(format("1,d")(0), "0");246 assert.strictEqual(format("2,d")(0), " 0");247 assert.strictEqual(format("3,d")(0), " 0");248 assert.strictEqual(format("5,d")(0), " 0");249 assert.strictEqual(format("8,d")(0), " 0");250 assert.strictEqual(format("13,d")(0), " 0");251 assert.strictEqual(format("21,d")(0), " 0");252 },253 "can group thousands and space fill with overflow": function(format) {254 assert.strictEqual(format("1,d")(1), "1");255 assert.strictEqual(format("1,d")(1), "1");256 assert.strictEqual(format("2,d")(12), "12");257 assert.strictEqual(format("3,d")(123), "123");258 assert.strictEqual(format("5,d")(12345), "12,345");259 assert.strictEqual(format("8,d")(12345678), "12,345,678");260 assert.strictEqual(format("13,d")(1234567890123), "1,234,567,890,123");261 },262 "can group thousands with general notation": function(format) {263 var f = format(",g");264 assert.strictEqual(f(0), "0");265 assert.strictEqual(f(42), "42");266 assert.strictEqual(f(42000000), "42,000,000");267 assert.strictEqual(f(420000000), "420,000,000");268 assert.strictEqual(f(-4), "-4");269 assert.strictEqual(f(-42), "-42");270 assert.strictEqual(f(-4200000), "-4,200,000");271 assert.strictEqual(f(-42000000), "-42,000,000");272 },273 "can group thousands, space fill, and round to significant digits": function(format) {274 assert.strictEqual(format("10,.1f")(123456.49), " 123,456.5");275 assert.strictEqual(format("10,.2f")(1234567.449), "1,234,567.45");276 assert.strictEqual(format("10,.3f")(12345678.4449), "12,345,678.445");277 assert.strictEqual(format("10,.5f")(123456789.444449), "123,456,789.44445");278 assert.strictEqual(format("10,.1f")(123456), " 123,456.0");279 assert.strictEqual(format("10,.2f")(1234567), "1,234,567.00");280 assert.strictEqual(format("10,.3f")(12345678), "12,345,678.000");281 assert.strictEqual(format("10,.5f")(123456789), "123,456,789.00000");282 },283 "can display integers in fixed-point notation": function(format) {284 assert.strictEqual(format("f")(42), "42");285 },286 "will not display non-integers in integer format": function(format) {287 assert.strictEqual(format("d")(4.2), "");288 },289 "unicode character": function(format) {290 assert.strictEqual(format("c")(9731), "â");291 },292 "binary": function(format) {293 assert.strictEqual(format("b")(10), "1010");294 },295 "binary with prefix": function(format) {296 assert.strictEqual(format("#b")(10), "0b1010");297 },298 "octal": function(format) {299 assert.strictEqual(format("o")(10), "12");300 },301 "octal with prefix": function(format) {302 assert.strictEqual(format("#o")(10), "0o12");303 },304 "hexadecimal (lowercase)": function(format) {305 assert.strictEqual(format("x")(3735928559), "deadbeef");306 },307 "hexadecimal (lowercase) with prefix": function(format) {308 assert.strictEqual(format("#x")(3735928559), "0xdeadbeef");309 },310 "hexadecimal (uppercase)": function(format) {311 assert.strictEqual(format("X")(3735928559), "DEADBEEF");312 },313 "hexadecimal (uppercase) with prefix": function(format) {314 assert.strictEqual(format("#X")(3735928559), "0xDEADBEEF");315 },316 "fill respects prefix": function(format) {317 assert.strictEqual(format("#20x")(3735928559), " 0xdeadbeef");318 },319 "align left": function(format) {320 assert.strictEqual(format("<1,d")(0), "0");321 assert.strictEqual(format("<1,d")(0), "0");322 assert.strictEqual(format("<2,d")(0), "0 ");323 assert.strictEqual(format("<3,d")(0), "0 ");324 assert.strictEqual(format("<5,d")(0), "0 ");325 assert.strictEqual(format("<8,d")(0), "0 ");326 assert.strictEqual(format("<13,d")(0), "0 ");327 assert.strictEqual(format("<21,d")(0), "0 ");328 },329 "align right": function(format) {330 assert.strictEqual(format(">1,d")(0), "0");331 assert.strictEqual(format(">1,d")(0), "0");332 assert.strictEqual(format(">2,d")(0), " 0");333 assert.strictEqual(format(">3,d")(0), " 0");334 assert.strictEqual(format(">5,d")(0), " 0");335 assert.strictEqual(format(">8,d")(0), " 0");336 assert.strictEqual(format(">13,d")(0), " 0");337 assert.strictEqual(format(">21,d")(0), " 0");338 assert.strictEqual(format(">21,d")(1000), " 1,000");339 assert.strictEqual(format(">21,d")(1e21), " 1e+21");340 },341 "align center": function(format) {342 assert.strictEqual(format("^1,d")(0), "0");343 assert.strictEqual(format("^1,d")(0), "0");344 assert.strictEqual(format("^2,d")(0), " 0");345 assert.strictEqual(format("^3,d")(0), " 0 ");346 assert.strictEqual(format("^5,d")(0), " 0 ");347 assert.strictEqual(format("^8,d")(0), " 0 ");348 assert.strictEqual(format("^13,d")(0), " 0 ");349 assert.strictEqual(format("^21,d")(0), " 0 ");350 assert.strictEqual(format("^21,d")(1000), " 1,000 ");351 assert.strictEqual(format("^21,d")(1e21), " 1e+21 ");352 },353 "pad after sign": function(format) {354 assert.strictEqual(format("=+1,d")(0), "+0");355 assert.strictEqual(format("=+1,d")(0), "+0");356 assert.strictEqual(format("=+2,d")(0), "+0");357 assert.strictEqual(format("=+3,d")(0), "+ 0");358 assert.strictEqual(format("=+5,d")(0), "+ 0");359 assert.strictEqual(format("=+8,d")(0), "+ 0");360 assert.strictEqual(format("=+13,d")(0), "+ 0");361 assert.strictEqual(format("=+21,d")(0), "+ 0");362 assert.strictEqual(format("=+21,d")(1e21), "+ 1e+21");363 },364 "pad after sign with currency": function(format) {365 assert.strictEqual(format("=+$1,d")(0), "+$0");366 assert.strictEqual(format("=+$1,d")(0), "+$0");367 assert.strictEqual(format("=+$2,d")(0), "+$0");368 assert.strictEqual(format("=+$3,d")(0), "+$0");369 assert.strictEqual(format("=+$5,d")(0), "+$ 0");370 assert.strictEqual(format("=+$8,d")(0), "+$ 0");371 assert.strictEqual(format("=+$13,d")(0), "+$ 0");372 assert.strictEqual(format("=+$21,d")(0), "+$ 0");373 assert.strictEqual(format("=+$21,d")(1e21), "+$ 1e+21");374 },375 "a space can denote positive numbers": function(format) {376 assert.strictEqual(format(" 1,d")(-1), "-1");377 assert.strictEqual(format(" 1,d")(0), " 0");378 assert.strictEqual(format(" 2,d")(0), " 0");379 assert.strictEqual(format(" 3,d")(0), " 0");380 assert.strictEqual(format(" 5,d")(0), " 0");381 assert.strictEqual(format(" 8,d")(0), " 0");382 assert.strictEqual(format(" 13,d")(0), " 0");383 assert.strictEqual(format(" 21,d")(0), " 0");384 assert.strictEqual(format(" 21,d")(1e21), " 1e+21");385 },386 "explicitly only use a sign for negative numbers": function(format) {387 assert.strictEqual(format("-1,d")(-1), "-1");388 assert.strictEqual(format("-1,d")(0), "0");389 assert.strictEqual(format("-2,d")(0), " 0");390 assert.strictEqual(format("-3,d")(0), " 0");391 assert.strictEqual(format("-5,d")(0), " 0");392 assert.strictEqual(format("-8,d")(0), " 0");393 assert.strictEqual(format("-13,d")(0), " 0");394 assert.strictEqual(format("-21,d")(0), " 0");395 },396 "can format negative zero": function(format) {397 assert.strictEqual(format("1d")(-0), "-0");398 assert.strictEqual(format("1f")(-0), "-0");399 },400 "supports \"n\" as an alias for \",g\"": function(format) {401 var f = format("n");402 assert.strictEqual(f(0.0042), "0.0042");403 assert.strictEqual(f(0.42), "0.42");404 assert.strictEqual(f(0), "0");405 assert.strictEqual(f(42), "42");406 assert.strictEqual(f(42000000), "42,000,000");407 assert.strictEqual(f(420000000), "420,000,000");408 assert.strictEqual(f(-4), "-4");409 assert.strictEqual(f(-42), "-42");410 assert.strictEqual(f(-4200000), "-4,200,000");411 assert.strictEqual(f(-42000000), "-42,000,000");412 assert.strictEqual(f(1e21), "1e+21");413 },414 "\"n\" with zero padding": function(format) {415 assert.strictEqual(format("01n")(0), "0");416 assert.strictEqual(format("01n")(0), "0");417 assert.strictEqual(format("02n")(0), "00");418 assert.strictEqual(format("03n")(0), "000");419 assert.strictEqual(format("05n")(0), "0,000");420 assert.strictEqual(format("08n")(0), "0,000,000");421 assert.strictEqual(format("013n")(0), "0,000,000,000");422 assert.strictEqual(format("021n")(0), "0,000,000,000,000,000");423 assert.strictEqual(format("013n")(-42000000), "-0,042,000,000");424 },425 "unreasonable precision values are clamped to reasonable values": function(format) {426 assert.strictEqual(format(".30f")(0), "0.00000000000000000000");427 assert.strictEqual(format(".0g")(1), "1");428 assert.strictEqual(format(",.-1f")(12345), "12,345");429 assert.strictEqual(format("+,.-1%")(123.45), "+12,345%");430 }431 }432});...
test_str.py
Source:test_str.py
...30 self.assertRaises(OverflowError, '%c'.__mod__, 0x1234)31 @test_support.cpython_only32 def test_formatting_huge_precision(self):33 from _testcapi import INT_MAX34 format_string = "%.{}f".format(INT_MAX + 1)35 with self.assertRaises(ValueError):36 result = format_string % 2.3437 def test_formatting_huge_width(self):38 format_string = "%{}f".format(sys.maxsize + 1)39 with self.assertRaises(ValueError):40 result = format_string % 2.3441 def test_conversion(self):42 # Make sure __str__() behaves properly43 class Foo0:44 def __unicode__(self):45 return u"foo"46 class Foo1:47 def __str__(self):48 return "foo"49 class Foo2(object):50 def __str__(self):51 return "foo"52 class Foo3(object):53 def __str__(self):54 return u"foo"55 class Foo4(unicode):56 def __str__(self):57 return u"foo"58 class Foo5(str):59 def __str__(self):60 return u"foo"61 class Foo6(str):62 def __str__(self):63 return "foos"64 def __unicode__(self):65 return u"foou"66 class Foo7(unicode):67 def __str__(self):68 return "foos"69 def __unicode__(self):70 return u"foou"71 class Foo8(str):72 def __new__(cls, content=""):73 return str.__new__(cls, 2*content)74 def __str__(self):75 return self76 class Foo9(str):77 def __str__(self):78 return "string"79 def __unicode__(self):80 return "not unicode"81 self.assertTrue(str(Foo0()).startswith("<")) # this is different from __unicode__82 self.assertEqual(str(Foo1()), "foo")83 self.assertEqual(str(Foo2()), "foo")84 self.assertEqual(str(Foo3()), "foo")85 self.assertEqual(str(Foo4("bar")), "foo")86 self.assertEqual(str(Foo5("bar")), "foo")87 self.assertEqual(str(Foo6("bar")), "foos")88 self.assertEqual(str(Foo7("bar")), "foos")89 self.assertEqual(str(Foo8("foo")), "foofoo")90 self.assertEqual(str(Foo9("foo")), "string")91 self.assertEqual(unicode(Foo9("foo")), u"not unicode")92 # This test only affects 32-bit platforms because expandtabs can only take93 # an int as the max value, not a 64-bit C long. If expandtabs is changed94 # to take a 64-bit long, this test should apply to all platforms.95 @unittest.skipIf(sys.maxint > (1 << 32) or struct.calcsize('P') != 4,96 'only applies to 32-bit platforms')97 def test_expandtabs_overflows_gracefully(self):98 self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxint)99 def test__format__(self):100 def test(value, format, expected):101 # test both with and without the trailing 's'102 self.assertEqual(value.__format__(format), expected)103 self.assertEqual(value.__format__(format + 's'), expected)104 test('', '', '')105 test('abc', '', 'abc')106 test('abc', '.3', 'abc')107 test('ab', '.3', 'ab')108 test('abcdef', '.3', 'abc')109 test('abcdef', '.0', '')110 test('abc', '3.3', 'abc')111 test('abc', '2.3', 'abc')112 test('abc', '2.2', 'ab')113 test('abc', '3.2', 'ab ')114 test('result', 'x<0', 'result')115 test('result', 'x<5', 'result')116 test('result', 'x<6', 'result')117 test('result', 'x<7', 'resultx')118 test('result', 'x<8', 'resultxx')119 test('result', ' <7', 'result ')120 test('result', '<7', 'result ')121 test('result', '>7', ' result')122 test('result', '>8', ' result')123 test('result', '^8', ' result ')124 test('result', '^9', ' result ')125 test('result', '^10', ' result ')126 test('a', '10000', 'a' + ' ' * 9999)127 test('', '10000', ' ' * 10000)128 test('', '10000000', ' ' * 10000000)129 def test_format(self):130 self.assertEqual(''.format(), '')131 self.assertEqual('a'.format(), 'a')132 self.assertEqual('ab'.format(), 'ab')133 self.assertEqual('a{{'.format(), 'a{')134 self.assertEqual('a}}'.format(), 'a}')135 self.assertEqual('{{b'.format(), '{b')136 self.assertEqual('}}b'.format(), '}b')137 self.assertEqual('a{{b'.format(), 'a{b')138 # examples from the PEP:139 import datetime140 self.assertEqual("My name is {0}".format('Fred'), "My name is Fred")141 self.assertEqual("My name is {0[name]}".format(dict(name='Fred')),142 "My name is Fred")143 self.assertEqual("My name is {0} :-{{}}".format('Fred'),144 "My name is Fred :-{}")145 d = datetime.date(2007, 8, 18)146 self.assertEqual("The year is {0.year}".format(d),147 "The year is 2007")148 # classes we'll use for testing149 class C:150 def __init__(self, x=100):151 self._x = x152 def __format__(self, spec):153 return spec154 class D:155 def __init__(self, x):156 self.x = x157 def __format__(self, spec):158 return str(self.x)159 # class with __str__, but no __format__160 class E:161 def __init__(self, x):162 self.x = x163 def __str__(self):164 return 'E(' + self.x + ')'165 # class with __repr__, but no __format__ or __str__166 class F:167 def __init__(self, x):168 self.x = x169 def __repr__(self):170 return 'F(' + self.x + ')'171 # class with __format__ that forwards to string, for some format_spec's172 class G:173 def __init__(self, x):174 self.x = x175 def __str__(self):176 return "string is " + self.x177 def __format__(self, format_spec):178 if format_spec == 'd':179 return 'G(' + self.x + ')'180 return object.__format__(self, format_spec)181 # class that returns a bad type from __format__182 class H:183 def __format__(self, format_spec):184 return 1.0185 class I(datetime.date):186 def __format__(self, format_spec):187 return self.strftime(format_spec)188 class J(int):189 def __format__(self, format_spec):190 return int.__format__(self * 2, format_spec)191 self.assertEqual(''.format(), '')192 self.assertEqual('abc'.format(), 'abc')193 self.assertEqual('{0}'.format('abc'), 'abc')194 self.assertEqual('{0:}'.format('abc'), 'abc')195 self.assertEqual('X{0}'.format('abc'), 'Xabc')196 self.assertEqual('{0}X'.format('abc'), 'abcX')197 self.assertEqual('X{0}Y'.format('abc'), 'XabcY')198 self.assertEqual('{1}'.format(1, 'abc'), 'abc')199 self.assertEqual('X{1}'.format(1, 'abc'), 'Xabc')200 self.assertEqual('{1}X'.format(1, 'abc'), 'abcX')201 self.assertEqual('X{1}Y'.format(1, 'abc'), 'XabcY')202 self.assertEqual('{0}'.format(-15), '-15')203 self.assertEqual('{0}{1}'.format(-15, 'abc'), '-15abc')204 self.assertEqual('{0}X{1}'.format(-15, 'abc'), '-15Xabc')205 self.assertEqual('{{'.format(), '{')206 self.assertEqual('}}'.format(), '}')207 self.assertEqual('{{}}'.format(), '{}')208 self.assertEqual('{{x}}'.format(), '{x}')209 self.assertEqual('{{{0}}}'.format(123), '{123}')210 self.assertEqual('{{{{0}}}}'.format(), '{{0}}')211 self.assertEqual('}}{{'.format(), '}{')212 self.assertEqual('}}x{{'.format(), '}x{')213 # weird field names214 self.assertEqual("{0[foo-bar]}".format({'foo-bar':'baz'}), 'baz')215 self.assertEqual("{0[foo bar]}".format({'foo bar':'baz'}), 'baz')216 self.assertEqual("{0[ ]}".format({' ':3}), '3')217 self.assertEqual('{foo._x}'.format(foo=C(20)), '20')218 self.assertEqual('{1}{0}'.format(D(10), D(20)), '2010')219 self.assertEqual('{0._x.x}'.format(C(D('abc'))), 'abc')220 self.assertEqual('{0[0]}'.format(['abc', 'def']), 'abc')221 self.assertEqual('{0[1]}'.format(['abc', 'def']), 'def')222 self.assertEqual('{0[1][0]}'.format(['abc', ['def']]), 'def')223 self.assertEqual('{0[1][0].x}'.format(['abc', [D('def')]]), 'def')224 # strings225 self.assertEqual('{0:.3s}'.format('abc'), 'abc')226 self.assertEqual('{0:.3s}'.format('ab'), 'ab')227 self.assertEqual('{0:.3s}'.format('abcdef'), 'abc')228 self.assertEqual('{0:.0s}'.format('abcdef'), '')229 self.assertEqual('{0:3.3s}'.format('abc'), 'abc')230 self.assertEqual('{0:2.3s}'.format('abc'), 'abc')231 self.assertEqual('{0:2.2s}'.format('abc'), 'ab')232 self.assertEqual('{0:3.2s}'.format('abc'), 'ab ')233 self.assertEqual('{0:x<0s}'.format('result'), 'result')234 self.assertEqual('{0:x<5s}'.format('result'), 'result')235 self.assertEqual('{0:x<6s}'.format('result'), 'result')236 self.assertEqual('{0:x<7s}'.format('result'), 'resultx')237 self.assertEqual('{0:x<8s}'.format('result'), 'resultxx')238 self.assertEqual('{0: <7s}'.format('result'), 'result ')239 self.assertEqual('{0:<7s}'.format('result'), 'result ')240 self.assertEqual('{0:>7s}'.format('result'), ' result')241 self.assertEqual('{0:>8s}'.format('result'), ' result')242 self.assertEqual('{0:^8s}'.format('result'), ' result ')243 self.assertEqual('{0:^9s}'.format('result'), ' result ')244 self.assertEqual('{0:^10s}'.format('result'), ' result ')245 self.assertEqual('{0:10000}'.format('a'), 'a' + ' ' * 9999)246 self.assertEqual('{0:10000}'.format(''), ' ' * 10000)247 self.assertEqual('{0:10000000}'.format(''), ' ' * 10000000)248 # format specifiers for user defined type249 self.assertEqual('{0:abc}'.format(C()), 'abc')250 # !r and !s coercions251 self.assertEqual('{0!s}'.format('Hello'), 'Hello')252 self.assertEqual('{0!s:}'.format('Hello'), 'Hello')253 self.assertEqual('{0!s:15}'.format('Hello'), 'Hello ')254 self.assertEqual('{0!s:15s}'.format('Hello'), 'Hello ')255 self.assertEqual('{0!r}'.format('Hello'), "'Hello'")256 self.assertEqual('{0!r:}'.format('Hello'), "'Hello'")257 self.assertEqual('{0!r}'.format(F('Hello')), 'F(Hello)')258 # test fallback to object.__format__259 self.assertEqual('{0}'.format({}), '{}')260 self.assertEqual('{0}'.format([]), '[]')261 self.assertEqual('{0}'.format([1]), '[1]')262 self.assertEqual('{0}'.format(E('data')), 'E(data)')263 self.assertEqual('{0:d}'.format(G('data')), 'G(data)')264 self.assertEqual('{0!s}'.format(G('data')), 'string is data')265 msg = 'object.__format__ with a non-empty format string is deprecated'266 with test_support.check_warnings((msg, PendingDeprecationWarning)):267 self.assertEqual('{0:^10}'.format(E('data')), ' E(data) ')268 self.assertEqual('{0:^10s}'.format(E('data')), ' E(data) ')269 self.assertEqual('{0:>15s}'.format(G('data')), ' string is data')270 self.assertEqual("{0:date: %Y-%m-%d}".format(I(year=2007,271 month=8,272 day=27)),273 "date: 2007-08-27")274 # test deriving from a builtin type and overriding __format__275 self.assertEqual("{0}".format(J(10)), "20")276 # string format specifiers277 self.assertEqual('{0:}'.format('a'), 'a')278 # computed format specifiers279 self.assertEqual("{0:.{1}}".format('hello world', 5), 'hello')280 self.assertEqual("{0:.{1}s}".format('hello world', 5), 'hello')281 self.assertEqual("{0:.{precision}s}".format('hello world', precision=5), 'hello')282 self.assertEqual("{0:{width}.{precision}s}".format('hello world', width=10, precision=5), 'hello ')283 self.assertEqual("{0:{width}.{precision}s}".format('hello world', width='10', precision='5'), 'hello ')284 # test various errors285 self.assertRaises(ValueError, '{'.format)286 self.assertRaises(ValueError, '}'.format)287 self.assertRaises(ValueError, 'a{'.format)288 self.assertRaises(ValueError, 'a}'.format)289 self.assertRaises(ValueError, '{a'.format)290 self.assertRaises(ValueError, '}a'.format)291 self.assertRaises(IndexError, '{0}'.format)292 self.assertRaises(IndexError, '{1}'.format, 'abc')293 self.assertRaises(KeyError, '{x}'.format)294 self.assertRaises(ValueError, "}{".format)295 self.assertRaises(ValueError, "{".format)296 self.assertRaises(ValueError, "}".format)297 self.assertRaises(ValueError, "abc{0:{}".format)298 self.assertRaises(ValueError, "{0".format)299 self.assertRaises(IndexError, "{0.}".format)300 self.assertRaises(ValueError, "{0.}".format, 0)301 self.assertRaises(IndexError, "{0[}".format)302 self.assertRaises(ValueError, "{0[}".format, [])303 self.assertRaises(KeyError, "{0]}".format)304 self.assertRaises(ValueError, "{0.[]}".format, 0)305 self.assertRaises(ValueError, "{0..foo}".format, 0)306 self.assertRaises(ValueError, "{0[0}".format, 0)307 self.assertRaises(ValueError, "{0[0:foo}".format, 0)308 self.assertRaises(KeyError, "{c]}".format)309 self.assertRaises(ValueError, "{{ {{{0}}".format, 0)310 self.assertRaises(ValueError, "{0}}".format, 0)311 self.assertRaises(KeyError, "{foo}".format, bar=3)312 self.assertRaises(ValueError, "{0!x}".format, 3)313 self.assertRaises(ValueError, "{0!}".format, 0)314 self.assertRaises(ValueError, "{0!rs}".format, 0)315 self.assertRaises(ValueError, "{!}".format)316 self.assertRaises(IndexError, "{:}".format)317 self.assertRaises(IndexError, "{:s}".format)318 self.assertRaises(IndexError, "{}".format)319 # issue 6089320 self.assertRaises(ValueError, "{0[0]x}".format, [None])321 self.assertRaises(ValueError, "{0[0](10)}".format, [None])322 # can't have a replacement on the field name portion323 self.assertRaises(TypeError, '{0[{1}]}'.format, 'abcdefg', 4)324 # exceed maximum recursion depth325 self.assertRaises(ValueError, "{0:{1:{2}}}".format, 'abc', 's', '')326 self.assertRaises(ValueError, "{0:{1:{2:{3:{4:{5:{6}}}}}}}".format,327 0, 1, 2, 3, 4, 5, 6, 7)328 # string format spec errors329 self.assertRaises(ValueError, "{0:-s}".format, '')330 self.assertRaises(ValueError, format, "", "-")331 self.assertRaises(ValueError, "{0:=s}".format, '')332 def test_format_huge_precision(self):333 format_string = ".{}f".format(sys.maxsize + 1)334 with self.assertRaises(ValueError):335 result = format(2.34, format_string)336 def test_format_huge_width(self):337 format_string = "{}f".format(sys.maxsize + 1)338 with self.assertRaises(ValueError):339 result = format(2.34, format_string)340 def test_format_huge_item_number(self):341 format_string = "{{{}:.6f}}".format(sys.maxsize + 1)342 with self.assertRaises(ValueError):343 result = format_string.format(2.34)344 def test_format_auto_numbering(self):345 class C:346 def __init__(self, x=100):347 self._x = x348 def __format__(self, spec):349 return spec350 self.assertEqual('{}'.format(10), '10')351 self.assertEqual('{:5}'.format('s'), 's ')352 self.assertEqual('{!r}'.format('s'), "'s'")353 self.assertEqual('{._x}'.format(C(10)), '10')354 self.assertEqual('{[1]}'.format([1, 2]), '2')355 self.assertEqual('{[a]}'.format({'a':4, 'b':2}), '4')356 self.assertEqual('a{}b{}c'.format(0, 1), 'a0b1c')357 self.assertEqual('a{:{}}b'.format('x', '^10'), 'a x b')358 self.assertEqual('a{:{}x}b'.format(20, '#'), 'a0x14b')359 # can't mix and match numbering and auto-numbering360 self.assertRaises(ValueError, '{}{1}'.format, 1, 2)361 self.assertRaises(ValueError, '{1}{}'.format, 1, 2)362 self.assertRaises(ValueError, '{:{1}}'.format, 1, 2)363 self.assertRaises(ValueError, '{0:{}}'.format, 1, 2)364 # can mix and match auto-numbering and named365 self.assertEqual('{f}{}'.format(4, f='test'), 'test4')366 self.assertEqual('{}{f}'.format(4, f='test'), '4test')367 self.assertEqual('{:{f}}{g}{}'.format(1, 3, g='g', f=2), ' 1g3')368 self.assertEqual('{f:{}}{}{g}'.format(2, 4, f=1, g='g'), ' 14g')369 def test_buffer_is_readonly(self):370 self.assertRaises(TypeError, sys.stdin.readinto, b"")371 def test_encode_and_decode_kwargs(self):372 self.assertEqual('abcde'.encode('ascii', 'replace'),373 'abcde'.encode('ascii', errors='replace'))374 self.assertEqual('abcde'.encode('ascii', 'ignore'),375 'abcde'.encode(encoding='ascii', errors='ignore'))376 self.assertEqual('Andr\202 x'.decode('ascii', 'ignore'),377 'Andr\202 x'.decode('ascii', errors='ignore'))378 self.assertEqual('Andr\202 x'.decode('ascii', 'replace'),379 'Andr\202 x'.decode(encoding='ascii', errors='replace'))380 def test_startswith_endswith_errors(self):381 with self.assertRaises(UnicodeDecodeError):382 '\xff'.startswith(u'x')...
PixelFormat.js
Source:PixelFormat.js
1define([2 '../Renderer/PixelDatatype',3 './freezeObject',4 './WebGLConstants'5 ], function(6 PixelDatatype,7 freezeObject,8 WebGLConstants) {9 'use strict';1011 /**12 * The format of a pixel, i.e., the number of components it has and what they represent.13 *14 * @exports PixelFormat15 */16 var PixelFormat = {17 /**18 * A pixel format containing a depth value.19 *20 * @type {Number}21 * @constant22 */23 DEPTH_COMPONENT : WebGLConstants.DEPTH_COMPONENT,2425 /**26 * A pixel format containing a depth and stencil value, most often used with {@link PixelDatatype.UNSIGNED_INT_24_8}.27 *28 * @type {Number}29 * @constant30 */31 DEPTH_STENCIL : WebGLConstants.DEPTH_STENCIL,3233 /**34 * A pixel format containing an alpha channel.35 *36 * @type {Number}37 * @constant38 */39 ALPHA : WebGLConstants.ALPHA,4041 /**42 * A pixel format containing red, green, and blue channels.43 *44 * @type {Number}45 * @constant46 */47 RGB : WebGLConstants.RGB,4849 /**50 * A pixel format containing red, green, blue, and alpha channels.51 *52 * @type {Number}53 * @constant54 */55 RGBA : WebGLConstants.RGBA,5657 /**58 * A pixel format containing a luminance (intensity) channel.59 *60 * @type {Number}61 * @constant62 */63 LUMINANCE : WebGLConstants.LUMINANCE,6465 /**66 * A pixel format containing luminance (intensity) and alpha channels.67 *68 * @type {Number}69 * @constant70 */71 LUMINANCE_ALPHA : WebGLConstants.LUMINANCE_ALPHA,7273 /**74 * A pixel format containing red, green, and blue channels that is DXT1 compressed.75 *76 * @type {Number}77 * @constant78 */79 RGB_DXT1 : WebGLConstants.COMPRESSED_RGB_S3TC_DXT1_EXT,8081 /**82 * A pixel format containing red, green, blue, and alpha channels that is DXT1 compressed.83 *84 * @type {Number}85 * @constant86 */87 RGBA_DXT1 : WebGLConstants.COMPRESSED_RGBA_S3TC_DXT1_EXT,8889 /**90 * A pixel format containing red, green, blue, and alpha channels that is DXT3 compressed.91 *92 * @type {Number}93 * @constant94 */95 RGBA_DXT3 : WebGLConstants.COMPRESSED_RGBA_S3TC_DXT3_EXT,9697 /**98 * A pixel format containing red, green, blue, and alpha channels that is DXT5 compressed.99 *100 * @type {Number}101 * @constant102 */103 RGBA_DXT5 : WebGLConstants.COMPRESSED_RGBA_S3TC_DXT5_EXT,104105 /**106 * A pixel format containing red, green, and blue channels that is PVR 4bpp compressed.107 *108 * @type {Number}109 * @constant110 */111 RGB_PVRTC_4BPPV1 : WebGLConstants.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,112113 /**114 * A pixel format containing red, green, and blue channels that is PVR 2bpp compressed.115 *116 * @type {Number}117 * @constant118 */119 RGB_PVRTC_2BPPV1 : WebGLConstants.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,120121 /**122 * A pixel format containing red, green, blue, and alpha channels that is PVR 4bpp compressed.123 *124 * @type {Number}125 * @constant126 */127 RGBA_PVRTC_4BPPV1 : WebGLConstants.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,128129 /**130 * A pixel format containing red, green, blue, and alpha channels that is PVR 2bpp compressed.131 *132 * @type {Number}133 * @constant134 */135 RGBA_PVRTC_2BPPV1 : WebGLConstants.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,136137 /**138 * A pixel format containing red, green, and blue channels that is ETC1 compressed.139 *140 * @type {Number}141 * @constant142 */143 RGB_ETC1 : WebGLConstants.COMPRESSED_RGB_ETC1_WEBGL,144145 /**146 * @private147 */148 componentsLength : function(pixelFormat) {149 switch (pixelFormat) {150 // Many GPUs store RGB as RGBA internally151 // https://devtalk.nvidia.com/default/topic/699479/general-graphics-programming/rgb-auto-converted-to-rgba/post/4142379/#4142379152 case PixelFormat.RGB:153 case PixelFormat.RGBA:154 return 4;155 case PixelFormat.LUMINANCE_ALPHA:156 return 2;157 case PixelFormat.ALPHA:158 case PixelFormat.LUMINANCE:159 return 1;160 default:161 return 1;162 }163 },164165 /**166 * @private167 */168 validate : function(pixelFormat) {169 return pixelFormat === PixelFormat.DEPTH_COMPONENT ||170 pixelFormat === PixelFormat.DEPTH_STENCIL ||171 pixelFormat === PixelFormat.ALPHA ||172 pixelFormat === PixelFormat.RGB ||173 pixelFormat === PixelFormat.RGBA ||174 pixelFormat === PixelFormat.LUMINANCE ||175 pixelFormat === PixelFormat.LUMINANCE_ALPHA ||176 pixelFormat === PixelFormat.RGB_DXT1 ||177 pixelFormat === PixelFormat.RGBA_DXT1 ||178 pixelFormat === PixelFormat.RGBA_DXT3 ||179 pixelFormat === PixelFormat.RGBA_DXT5 ||180 pixelFormat === PixelFormat.RGB_PVRTC_4BPPV1 ||181 pixelFormat === PixelFormat.RGB_PVRTC_2BPPV1 ||182 pixelFormat === PixelFormat.RGBA_PVRTC_4BPPV1 ||183 pixelFormat === PixelFormat.RGBA_PVRTC_2BPPV1 ||184 pixelFormat === PixelFormat.RGB_ETC1;185 },186187 /**188 * @private189 */190 isColorFormat : function(pixelFormat) {191 return pixelFormat === PixelFormat.ALPHA ||192 pixelFormat === PixelFormat.RGB ||193 pixelFormat === PixelFormat.RGBA ||194 pixelFormat === PixelFormat.LUMINANCE ||195 pixelFormat === PixelFormat.LUMINANCE_ALPHA;196 },197198 /**199 * @private200 */201 isDepthFormat : function(pixelFormat) {202 return pixelFormat === PixelFormat.DEPTH_COMPONENT ||203 pixelFormat === PixelFormat.DEPTH_STENCIL;204 },205206 /**207 * @private208 */209 isCompressedFormat : function(pixelFormat) {210 return pixelFormat === PixelFormat.RGB_DXT1 ||211 pixelFormat === PixelFormat.RGBA_DXT1 ||212 pixelFormat === PixelFormat.RGBA_DXT3 ||213 pixelFormat === PixelFormat.RGBA_DXT5 ||214 pixelFormat === PixelFormat.RGB_PVRTC_4BPPV1 ||215 pixelFormat === PixelFormat.RGB_PVRTC_2BPPV1 ||216 pixelFormat === PixelFormat.RGBA_PVRTC_4BPPV1 ||217 pixelFormat === PixelFormat.RGBA_PVRTC_2BPPV1 ||218 pixelFormat === PixelFormat.RGB_ETC1;219 },220221 /**222 * @private223 */224 isDXTFormat : function(pixelFormat) {225 return pixelFormat === PixelFormat.RGB_DXT1 ||226 pixelFormat === PixelFormat.RGBA_DXT1 ||227 pixelFormat === PixelFormat.RGBA_DXT3 ||228 pixelFormat === PixelFormat.RGBA_DXT5;229 },230231 /**232 * @private233 */234 isPVRTCFormat : function(pixelFormat) {235 return pixelFormat === PixelFormat.RGB_PVRTC_4BPPV1 ||236 pixelFormat === PixelFormat.RGB_PVRTC_2BPPV1 ||237 pixelFormat === PixelFormat.RGBA_PVRTC_4BPPV1 ||238 pixelFormat === PixelFormat.RGBA_PVRTC_2BPPV1;239 },240241 /**242 * @private243 */244 isETC1Format : function(pixelFormat) {245 return pixelFormat === PixelFormat.RGB_ETC1;246 },247248 /**249 * @private250 */251 compressedTextureSizeInBytes : function(pixelFormat, width, height) {252 switch (pixelFormat) {253 case PixelFormat.RGB_DXT1:254 case PixelFormat.RGBA_DXT1:255 case PixelFormat.RGB_ETC1:256 return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 8;257258 case PixelFormat.RGBA_DXT3:259 case PixelFormat.RGBA_DXT5:260 return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 16;261262 case PixelFormat.RGB_PVRTC_4BPPV1:263 case PixelFormat.RGBA_PVRTC_4BPPV1:264 return Math.floor((Math.max(width, 8) * Math.max(height, 8) * 4 + 7) / 8);265266 case PixelFormat.RGB_PVRTC_2BPPV1:267 case PixelFormat.RGBA_PVRTC_2BPPV1:268 return Math.floor((Math.max(width, 16) * Math.max(height, 8) * 2 + 7) / 8);269270 default:271 return 0;272 }273 },274275 /**276 * @private277 */278 textureSizeInBytes : function(pixelFormat, pixelDatatype, width, height) {279 var componentsLength = PixelFormat.componentsLength(pixelFormat);280 if (PixelDatatype.isPacked(pixelDatatype)) {281 componentsLength = 1;282 }283 return componentsLength * PixelDatatype.sizeInBytes(pixelDatatype) * width * height;284 }285 };286287 return freezeObject(PixelFormat);
...
u_format_table.py
Source:u_format_table.py
1#!/usr/bin/env python2'''3/**************************************************************************4 *5 * Copyright 2010 VMware, Inc.6 * All Rights Reserved.7 *8 * Permission is hereby granted, free of charge, to any person obtaining a9 * copy of this software and associated documentation files (the10 * "Software"), to deal in the Software without restriction, including11 * without limitation the rights to use, copy, modify, merge, publish,12 * distribute, sub license, and/or sell copies of the Software, and to13 * permit persons to whom the Software is furnished to do so, subject to14 * the following conditions:15 *16 * The above copyright notice and this permission notice (including the17 * next paragraph) shall be included in all copies or substantial portions18 * of the Software.19 *20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.23 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR24 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.27 *28 **************************************************************************/29'''30import sys31from u_format_parse import *32import u_format_pack33def layout_map(layout):34 return 'UTIL_FORMAT_LAYOUT_' + str(layout).upper()35def colorspace_map(colorspace):36 return 'UTIL_FORMAT_COLORSPACE_' + str(colorspace).upper()37colorspace_channels_map = {38 'rgb': ['r', 'g', 'b', 'a'],39 'srgb': ['sr', 'sg', 'sb', 'a'],40 'zs': ['z', 's'],41 'yuv': ['y', 'u', 'v'],42}43type_map = {44 VOID: "UTIL_FORMAT_TYPE_VOID",45 UNSIGNED: "UTIL_FORMAT_TYPE_UNSIGNED",46 SIGNED: "UTIL_FORMAT_TYPE_SIGNED",47 FIXED: "UTIL_FORMAT_TYPE_FIXED",48 FLOAT: "UTIL_FORMAT_TYPE_FLOAT",49}50def bool_map(value):51 if value:52 return "TRUE"53 else:54 return "FALSE"55swizzle_map = {56 SWIZZLE_X: "UTIL_FORMAT_SWIZZLE_X",57 SWIZZLE_Y: "UTIL_FORMAT_SWIZZLE_Y",58 SWIZZLE_Z: "UTIL_FORMAT_SWIZZLE_Z",59 SWIZZLE_W: "UTIL_FORMAT_SWIZZLE_W",60 SWIZZLE_0: "UTIL_FORMAT_SWIZZLE_0",61 SWIZZLE_1: "UTIL_FORMAT_SWIZZLE_1",62 SWIZZLE_NONE: "UTIL_FORMAT_SWIZZLE_NONE",63}64def write_format_table(formats):65 print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */'66 print67 # This will print the copyright message on the top of this file68 print __doc__.strip()69 print70 print '#include "u_format.h"'71 print '#include "u_format_s3tc.h"'72 print73 74 u_format_pack.generate(formats)75 76 for format in formats:77 print 'const struct util_format_description'78 print 'util_format_%s_description = {' % (format.short_name(),)79 print " %s," % (format.name,)80 print " \"%s\"," % (format.name,)81 print " \"%s\"," % (format.short_name(),)82 print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())83 print " %s," % (layout_map(format.layout),)84 print " %u,\t/* nr_channels */" % (format.nr_channels(),)85 print " %s,\t/* is_array */" % (bool_map(format.is_array()),)86 print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)87 print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)88 print " {"89 for i in range(4):90 channel = format.channels[i]91 if i < 3:92 sep = ","93 else:94 sep = ""95 if channel.size:96 print " {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name)97 else:98 print " {0, 0, 0}%s" % (sep,)99 print " },"100 print " {"101 for i in range(4):102 swizzle = format.swizzles[i]103 if i < 3:104 sep = ","105 else:106 sep = ""107 try:108 comment = colorspace_channels_map[format.colorspace][i]109 except (KeyError, IndexError):110 comment = 'ignored'111 print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)112 print " },"113 print " %s," % (colorspace_map(format.colorspace),)114 if format.colorspace != ZS:115 print " &util_format_%s_unpack_rgba_8unorm," % format.short_name() 116 print " &util_format_%s_pack_rgba_8unorm," % format.short_name() 117 if format.layout == 's3tc':118 print " &util_format_%s_fetch_rgba_8unorm," % format.short_name()119 else:120 print " NULL, /* fetch_rgba_8unorm */" 121 print " &util_format_%s_unpack_rgba_float," % format.short_name() 122 print " &util_format_%s_pack_rgba_float," % format.short_name() 123 print " &util_format_%s_fetch_rgba_float," % format.short_name()124 else:125 print " NULL, /* unpack_rgba_8unorm */" 126 print " NULL, /* pack_rgba_8unorm */" 127 print " NULL, /* fetch_rgba_8unorm */" 128 print " NULL, /* unpack_rgba_float */" 129 print " NULL, /* pack_rgba_float */" 130 print " NULL, /* fetch_rgba_float */" 131 if format.colorspace == ZS and format.swizzles[0] != SWIZZLE_NONE:132 print " &util_format_%s_unpack_z_32unorm," % format.short_name() 133 print " &util_format_%s_pack_z_32unorm," % format.short_name() 134 print " &util_format_%s_unpack_z_float," % format.short_name() 135 print " &util_format_%s_pack_z_float," % format.short_name() 136 else:137 print " NULL, /* unpack_z_32unorm */" 138 print " NULL, /* pack_z_32unorm */" 139 print " NULL, /* unpack_z_float */" 140 print " NULL, /* pack_z_float */" 141 if format.colorspace == ZS and format.swizzles[1] != SWIZZLE_NONE:142 print " &util_format_%s_unpack_s_8uscaled," % format.short_name() 143 print " &util_format_%s_pack_s_8uscaled" % format.short_name() 144 else:145 print " NULL, /* unpack_s_8uscaled */" 146 print " NULL /* pack_s_8uscaled */" 147 print "};"148 print149 150 print "const struct util_format_description *"151 print "util_format_description(enum pipe_format format)"152 print "{"153 print " if (format >= PIPE_FORMAT_COUNT) {"154 print " return NULL;"155 print " }"156 print157 print " switch (format) {"158 for format in formats:159 print " case %s:" % format.name160 print " return &util_format_%s_description;" % (format.short_name(),)161 print " default:"162 print " return NULL;"163 print " }"164 print "}"165 print166def main():167 formats = []168 for arg in sys.argv[1:]:169 formats.extend(parse(arg))170 write_format_table(formats)171if __name__ == '__main__':...
bootstrap-table-zh-CN.js
Source:bootstrap-table-zh-CN.js
1/**2 * Bootstrap Table Chinese translation3 * Author: Zhixin Wen<wenzhixin2010@gmail.com>4 */5$.fn.bootstrapTable.locales['zh-CN'] = {6 formatShowSearch: function formatShowSearch() {7 return 'éè/æ¾ç¤ºæç´¢';8 },9 formatPageGo: function formatPageGo() {10 return '跳转';11 },12 formatCopyRows: function formatCopyRows() {13 return 'å¤å¶è¡';14 },15 formatPrint: function formatPrint() {16 return 'æå°';17 },18 formatLoadingMessage: function formatLoadingMessage() {19 return 'æ£å¨åªåå°å è½½æ°æ®ä¸ï¼è¯·ç¨å';20 },21 formatRecordsPerPage: function formatRecordsPerPage(pageNumber) {22 return "æ¯é¡µæ¾ç¤º ".concat(pageNumber, " æ¡è®°å½");23 },24 formatShowingRows: function formatShowingRows(pageFrom, pageTo, totalRows, totalNotFiltered) {25 if (totalNotFiltered !== undefined && totalNotFiltered > 0 && totalNotFiltered > totalRows) {26 return "æ¾ç¤ºç¬¬ ".concat(pageFrom, " å°ç¬¬ ").concat(pageTo, " æ¡è®°å½ï¼æ»å
± ").concat(totalRows, " æ¡è®°å½ï¼ä» ").concat(totalNotFiltered, " æ»è®°å½ä¸è¿æ»¤ï¼");27 }28 return "æ¾ç¤ºç¬¬ ".concat(pageFrom, " å°ç¬¬ ").concat(pageTo, " æ¡è®°å½ï¼æ»å
± ").concat(totalRows, " æ¡è®°å½");29 },30 formatSRPaginationPreText: function formatSRPaginationPreText() {31 return 'ä¸ä¸é¡µ';32 },33 formatSRPaginationPageText: function formatSRPaginationPageText(page) {34 return "第".concat(page, "页");35 },36 formatSRPaginationNextText: function formatSRPaginationNextText() {37 return 'ä¸ä¸é¡µ';38 },39 formatDetailPagination: function formatDetailPagination(totalRows) {40 return "æ»å
± ".concat(totalRows, " æ¡è®°å½");41 },42 formatClearSearch: function formatClearSearch() {43 return 'æ¸
空è¿æ»¤';44 },45 formatSearch: function formatSearch() {46 return 'æç´¢';47 },48 formatNoMatches: function formatNoMatches() {49 return '没ææ¾å°å¹é
çè®°å½';50 },51 formatPaginationSwitch: function formatPaginationSwitch() {52 return 'éè/æ¾ç¤ºå页';53 },54 formatPaginationSwitchDown: function formatPaginationSwitchDown() {55 return 'æ¾ç¤ºå页';56 },57 formatPaginationSwitchUp: function formatPaginationSwitchUp() {58 return 'éèå页';59 },60 formatRefresh: function formatRefresh() {61 return 'å·æ°';62 },63 formatToggle: function formatToggle() {64 return 'åæ¢';65 },66 formatToggleOn: function formatToggleOn() {67 return 'æ¾ç¤ºå¡çè§å¾';68 },69 formatToggleOff: function formatToggleOff() {70 return 'éèå¡çè§å¾';71 },72 formatColumns: function formatColumns() {73 return 'å';74 },75 formatColumnsToggleAll: function formatColumnsToggleAll() {76 return 'åæ¢ææ';77 },78 formatFullscreen: function formatFullscreen() {79 return 'å
¨å±';80 },81 formatAllRows: function formatAllRows() {82 return 'ææ';83 },84 formatAutoRefresh: function formatAutoRefresh() {85 return 'èªå¨å·æ°';86 },87 formatExport: function formatExport() {88 return '导åºæ°æ®';89 },90 formatJumpTo: function formatJumpTo() {91 return '跳转';92 },93 formatAdvancedSearch: function formatAdvancedSearch() {94 return 'é«çº§æç´¢';95 },96 formatAdvancedCloseButton: function formatAdvancedCloseButton() {97 return 'å
³é';98 },99 formatFilterControlSwitch: function formatFilterControlSwitch() {100 return 'éè/æ¾ç¤ºè¿æ»¤æ§å¶';101 },102 formatFilterControlSwitchHide: function formatFilterControlSwitchHide() {103 return 'éèè¿æ»¤æ§å¶';104 },105 formatFilterControlSwitchShow: function formatFilterControlSwitchShow() {106 return 'æ¾ç¤ºè¿æ»¤æ§å¶';107 }108};...
Using AI Code Generation
1var wpt = require('webpagetest');2var test = wpt('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status: ' + data.statusText);5 console.log('Test ID: ' + data.data.testId);6 console.log('Test URL: ' + data.data.userUrl);7 console.log('Test results: ' + data.data.summary);8 console.log('Test results: ' + data.data.median.firstView.loadTime);9 console.log('Test results: ' + data.data.median.firstView.SpeedIndex);10 console.log('Test results: ' + data.data.median.firstView.TTFB);11 console.log('Test results: ' + data.data.median.firstView.render);12 console.log('Test results: ' + data.data.median.firstView.fullyLoaded);13 console.log('Test results: ' + data.data.median.firstView.docTime);14 console.log('Test results: ' + data.data.median.firstView.bytesIn);15 console.log('Test results: ' + data.data.median.firstView.bytesOut);16 console.log('Test results: ' + data.data.median.firstView.requests);17 console.log('Test results: ' + data.data.median.firstView.domElements);18 console.log('Test results: ' + data.data.median.firstView.score_cache);19 console.log('Test results: ' + data.data.median.firstView.score_cdn);20 console.log('Test results: ' + data.data.median.firstView.score_gzip);21 console.log('Test results: ' + data.data.median.firstView.score_cookies);22 console.log('Test results: ' + data.data.median.firstView.score_keep-alive);23 console.log('Test results: ' + data.data.median.firstView.score_minify);24 console.log('Test results: ' + data.data.median.firstView.score_combine);25 console.log('Test results: ' + data.data.median.firstView.score_compress);26 console.log('Test results: ' + data.data.median.firstView.score_etags);27 console.log('Test results: ' + data.data.median.firstView.score_progressive_jpeg);28 console.log('Test results: ' + data.data.median.firstView.score_dns);29 console.log('Test results: ' + data.data.median.firstView.score_gzip);30 console.log('Test results: ' + data.data.median.first
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, resp) {4 console.log(resp);5});6var wptools = require('wptools');
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3var format = require('util').format;4var options = {5};6var page = wptools.page('Albert Einstein', options)7 .get(function(err, info) {
Using AI Code Generation
1var wptools = require('wptools');2var article = wptools.page('Barack Obama');3article.get(function(err, page) {4 console.log(page.infobox());5 console.log(page.images());6 console.log(page.links());7 console.log(page.categories());8 console.log(page.coordinates());9 console.log(page.extlinks());10 console.log(page.langlinks());11 console.log(page.revision());12 console.log(page.templates());13 console.log(page.text());14 console.log(page.html());15 console.log(page.references());16 console.log(page.summary());17 console.log(page.imageinfo());18 console.log(page.data());19 console.log(page.json());20 console.log(page.html());21 console.log(page.html({section: 0}));22 console.log(page.html({section: 1}));23 console.log(page.html({section: 2}));24 console.log(page.html({section: 3}));25 console.log(page.html({section: 4}));26 console.log(page.html({section: 5}));27 console.log(page.html({section: 6}));28 console.log(page.html({section: 7}));29 console.log(page.html({section: 8}));30 console.log(page.html({section: 9}));31 console.log(page.html({section: 10}));32 console.log(page.html({section: 11}));33 console.log(page.html({section: 12}));34 console.log(page.html({section: 13}));35 console.log(page.html({section: 14}));36 console.log(page.html({section: 15}));37 console.log(page.html({section: 16}));38 console.log(page.html({section: 17}));39 console.log(page.html({section: 18}));40 console.log(page.html({section: 19}));41 console.log(page.html({section: 20}));42 console.log(page.html({section: 21}));43 console.log(page.html({section: 22}));44 console.log(page.html({section: 23}));45 console.log(page.html({section: 24}));46 console.log(page.html({section: 25}));47 console.log(page.html({section: 26}));48 console.log(page.html({section: 27}));49 console.log(page.html({section: 28}));50 console.log(page.html({section: 29}));51 console.log(page.html({section: 30}));52 console.log(page.html({section: 31}));53 console.log(page.html({section
Using AI Code Generation
1const wptools = require('wptools');2const page = wptools.page('United States');3page.getParse((err, info) => {4 if (err) {5 console.log('Error:', err);6 } else {7 console.log(info);8 }9});10{11 parse: {12 revision: {13 },14 text: {
Using AI Code Generation
1const wpt = require('webpagetest');2const wptAPI = wpt('www.webpagetest.org');3const fs = require('fs');4const location = 'Dulles:Chrome';5wptAPI.runTest(url, { location }, (err, data) => {6 if (err) console.log(err);7 const { data: { testId } } = data;8 wptAPI.getTestResults(testId, (err, data) => {9 if (err) console.log(err);10 const { data: { median: { firstView: { SpeedIndex } } } } = data;11 fs.appendFile('test.txt', `SpeedIndex: ${SpeedIndex} \n`, (err) => {12 if (err) console.log(err);13 });
Using AI Code Generation
1var Wptb = require('wptb');2var wptb = new Wptb();3var data = {4};5var template = "My name is {name}. I am {age} years old, and I live in {city}.";6var result = wptb.format(template, data);7### 2.2. Use wptb.format() with a callback function8var Wptb = require('wptb');9var wptb = new Wptb();10var data = {11};12var template = "My name is {name}. I am {age} years old, and I live in {city}.";13var result = wptb.format(template, data, function (err, result) {14 if (err) {15 console.log(err);16 } else {17 }18});19## 3. Use wptb.formatFile()20### 3.1. Use wptb.formatFile() with a callback function21var Wptb = require('wptb');22var wptb = new Wptb();23var data = {24};25wptb.formatFile('test.html', data, function (err, result) {26 if (err) {27 console.log(err);28 } else {29 console.log(result);30 }31});32### 3.2. Use wptb.formatFile() with a callback function33var Wptb = require('wptb');34var wptb = new Wptb();35var data = {
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!