소스 검색

PDF.js version 1.8.406 - See mozilla/pdf.js@45933545f15056b13eec0f2babfe0cdbf4b6385f

pdfjsbot 8 년 전
부모
커밋
c9a004b903

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.8.404",
+  "version": "1.8.406",
   "main": [
     "build/pdf.js",
     "build/pdf.worker.js"

+ 6 - 6
build/pdf.combined.js

@@ -12809,8 +12809,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '1.8.404';
-  exports.build = build = 'bd288df9';
+  exports.version = version = '1.8.406';
+  exports.build = build = '45933545';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
@@ -28147,8 +28147,8 @@ if (!_util.globalScope.PDFJS) {
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.404';
-  PDFJS.build = 'bd288df9';
+  PDFJS.version = '1.8.406';
+  PDFJS.build = '45933545';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
@@ -46762,8 +46762,8 @@ exports.TilingPattern = TilingPattern;
 "use strict";
 
 
-var pdfjsVersion = '1.8.404';
-var pdfjsBuild = 'bd288df9';
+var pdfjsVersion = '1.8.406';
+var pdfjsBuild = '45933545';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
 var pdfjsDisplayAPI = __w_pdfjs_require__(10);

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
build/pdf.combined.js.map


+ 6 - 6
build/pdf.js

@@ -3538,8 +3538,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '1.8.404';
-  exports.build = build = 'bd288df9';
+  exports.version = version = '1.8.406';
+  exports.build = build = '45933545';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
@@ -5512,8 +5512,8 @@ if (!_util.globalScope.PDFJS) {
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.404';
-  PDFJS.build = 'bd288df9';
+  PDFJS.version = '1.8.406';
+  PDFJS.build = '45933545';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
@@ -11052,8 +11052,8 @@ exports.TilingPattern = TilingPattern;
 "use strict";
 
 
-var pdfjsVersion = '1.8.404';
-var pdfjsBuild = 'bd288df9';
+var pdfjsVersion = '1.8.406';
+var pdfjsBuild = '45933545';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
 var pdfjsDisplayAPI = __w_pdfjs_require__(3);

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
build/pdf.js.map


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
build/pdf.min.js


+ 2 - 2
build/pdf.worker.js

@@ -40061,8 +40061,8 @@ exports.Type1Parser = Type1Parser;
 "use strict";
 
 
-var pdfjsVersion = '1.8.404';
-var pdfjsBuild = 'bd288df9';
+var pdfjsVersion = '1.8.406';
+var pdfjsBuild = '45933545';
 var pdfjsCoreWorker = __w_pdfjs_require__(8);
 {
   __w_pdfjs_require__(19);

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
build/pdf.worker.js.map


+ 2 - 2
lib/display/api.js

@@ -1418,8 +1418,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '1.8.404';
-  exports.build = build = 'bd288df9';
+  exports.version = version = '1.8.406';
+  exports.build = build = '45933545';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;

+ 2 - 2
lib/display/global.js

@@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.404';
-  PDFJS.build = 'bd288df9';
+  PDFJS.version = '1.8.406';
+  PDFJS.build = '45933545';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {

+ 2 - 2
lib/pdf.js

@@ -14,8 +14,8 @@
  */
 'use strict';
 
-var pdfjsVersion = '1.8.404';
-var pdfjsBuild = 'bd288df9';
+var pdfjsVersion = '1.8.406';
+var pdfjsBuild = '45933545';
 var pdfjsSharedUtil = require('./shared/util.js');
 var pdfjsDisplayGlobal = require('./display/global.js');
 var pdfjsDisplayAPI = require('./display/api.js');

+ 2 - 2
lib/pdf.worker.js

@@ -14,8 +14,8 @@
  */
 'use strict';
 
-var pdfjsVersion = '1.8.404';
-var pdfjsBuild = 'bd288df9';
+var pdfjsVersion = '1.8.406';
+var pdfjsBuild = '45933545';
 var pdfjsCoreWorker = require('./core/worker.js');
 {
   require('./core/network.js');

+ 5 - 4
lib/web/annotation_layer_builder.js

@@ -38,6 +38,7 @@ var AnnotationLayerBuilder = function () {
     this.renderInteractiveForms = options.renderInteractiveForms;
     this.linkService = options.linkService;
     this.downloadManager = options.downloadManager;
+    this.l10n = options.l10n || _ui_utils.NullL10n;
     this.div = null;
   }
 
@@ -69,9 +70,7 @@ var AnnotationLayerBuilder = function () {
           _this.pageDiv.appendChild(_this.div);
           parameters.div = _this.div;
           _pdf.AnnotationLayer.render(parameters);
-          if (typeof _ui_utils.mozL10n !== 'undefined') {
-            _ui_utils.mozL10n.translate(_this.div);
-          }
+          _this.l10n.translate(_this.div);
         }
       });
     }
@@ -97,12 +96,14 @@ var DefaultAnnotationLayerFactory = function () {
     key: 'createAnnotationLayerBuilder',
     value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
       var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
+      var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
 
       return new AnnotationLayerBuilder({
         pageDiv: pageDiv,
         pdfPage: pdfPage,
         renderInteractiveForms: renderInteractiveForms,
-        linkService: new _pdf_link_service.SimpleLinkService()
+        linkService: new _pdf_link_service.SimpleLinkService(),
+        l10n: l10n
       });
     }
   }]);

+ 66 - 38
lib/web/app.js

@@ -116,6 +116,7 @@ var PDFViewerApplication = {
   toolbar: null,
   secondaryToolbar: null,
   eventBus: null,
+  l10n: null,
   pageRotation: 0,
   isInitialViewSet: false,
   viewerPrefs: {
@@ -140,11 +141,14 @@ var PDFViewerApplication = {
     configure(_pdf.PDFJS);
     this.appConfig = appConfig;
     return this._readPreferences().then(function () {
+      return _this._initializeL10n();
+    }).then(function () {
       return _this._initializeViewerComponents();
     }).then(function () {
       _this.bindEvents();
       _this.bindWindowEvents();
-      _ui_utils.localized.then(function () {
+      var appContainer = appConfig.appContainer || document.documentElement;
+      _this.l10n.translate(appContainer).then(function () {
         _this.eventBus.dispatch('localized');
       });
       if (_this.isViewerEmbedded && !_pdf.PDFJS.isExternalLinkTargetSet()) {
@@ -208,6 +212,19 @@ var PDFViewerApplication = {
       viewerPrefs['enablePrintAutoRotate'] = value;
     })]).catch(function (reason) {});
   },
+  _initializeL10n: function _initializeL10n() {
+    if (this.viewerPrefs['pdfBugEnabled']) {
+      var hash = document.location.hash.substring(1);
+      var hashParams = (0, _ui_utils.parseQueryString)(hash);
+      if ('locale' in hashParams) {
+        _pdf.PDFJS.locale = hashParams['locale'];
+      }
+    }
+    this.l10n = this.externalServices.createL10n();
+    return this.l10n.getDirection().then(function (dir) {
+      document.getElementsByTagName('html')[0].dir = dir;
+    });
+  },
   _initializeViewerComponents: function _initializeViewerComponents() {
     var _this2 = this;
 
@@ -233,6 +250,7 @@ var PDFViewerApplication = {
         linkService: pdfLinkService,
         downloadManager: downloadManager,
         renderer: _this2.viewerPrefs['renderer'],
+        l10n: _this2.l10n,
         enhanceTextSelection: _this2.viewerPrefs['enhanceTextSelection'],
         renderInteractiveForms: _this2.viewerPrefs['renderInteractiveForms'],
         enablePrintAutoRotate: _this2.viewerPrefs['enablePrintAutoRotate']
@@ -243,7 +261,8 @@ var PDFViewerApplication = {
       _this2.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
         container: thumbnailContainer,
         renderingQueue: pdfRenderingQueue,
-        linkService: pdfLinkService
+        linkService: pdfLinkService,
+        l10n: _this2.l10n
       });
       pdfRenderingQueue.setThumbnailViewer(_this2.pdfThumbnailViewer);
       _this2.pdfHistory = new _pdf_history.PDFHistory({
@@ -272,14 +291,14 @@ var PDFViewerApplication = {
       var findBarConfig = Object.create(appConfig.findBar);
       findBarConfig.findController = _this2.findController;
       findBarConfig.eventBus = eventBus;
-      _this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig);
-      _this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this2.overlayManager);
+      _this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, _this2.l10n);
+      _this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this2.overlayManager, _this2.l10n);
       _this2.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
         container: container,
         eventBus: eventBus,
         preferences: _this2.preferences
       });
-      _this2.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus);
+      _this2.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus, _this2.l10n);
       _this2.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
       if (_this2.supportsFullscreen) {
         _this2.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
@@ -290,7 +309,7 @@ var PDFViewerApplication = {
           contextMenuItems: appConfig.fullscreen
         });
       }
-      _this2.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this2.overlayManager);
+      _this2.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this2.overlayManager, _this2.l10n);
       _this2.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
         container: appConfig.sidebar.outlineView,
         eventBus: eventBus,
@@ -306,7 +325,7 @@ var PDFViewerApplication = {
       sidebarConfig.pdfThumbnailViewer = _this2.pdfThumbnailViewer;
       sidebarConfig.pdfOutlineViewer = _this2.pdfOutlineViewer;
       sidebarConfig.eventBus = eventBus;
-      _this2.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig);
+      _this2.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, _this2.l10n);
       _this2.pdfSidebar.onToggled = _this2.forceRendering.bind(_this2);
       resolve(undefined);
     });
@@ -479,16 +498,20 @@ var PDFViewerApplication = {
       _this3.load(pdfDocument, scale);
     }, function (exception) {
       var message = exception && exception.message;
-      var loadingErrorMessage = _ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
+      var loadingErrorMessage = void 0;
       if (exception instanceof _pdf.InvalidPDFException) {
-        loadingErrorMessage = _ui_utils.mozL10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
+        loadingErrorMessage = _this3.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
       } else if (exception instanceof _pdf.MissingPDFException) {
-        loadingErrorMessage = _ui_utils.mozL10n.get('missing_file_error', null, 'Missing PDF file.');
+        loadingErrorMessage = _this3.l10n.get('missing_file_error', null, 'Missing PDF file.');
       } else if (exception instanceof _pdf.UnexpectedResponseException) {
-        loadingErrorMessage = _ui_utils.mozL10n.get('unexpected_response_error', null, 'Unexpected server response.');
+        loadingErrorMessage = _this3.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
+      } else {
+        loadingErrorMessage = _this3.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
       }
-      _this3.error(loadingErrorMessage, { message: message });
-      throw new Error(loadingErrorMessage);
+      return loadingErrorMessage.then(function (msg) {
+        _this3.error(msg, { message: message });
+        throw new Error(msg);
+      });
     });
   },
 
@@ -517,20 +540,20 @@ var PDFViewerApplication = {
   },
   fallback: function pdfViewFallback(featureId) {},
   error: function pdfViewError(message, moreInfo) {
-    var moreInfoText = _ui_utils.mozL10n.get('error_version_info', {
+    var moreInfoText = [this.l10n.get('error_version_info', {
       version: _pdf.version || '?',
       build: _pdf.build || '?'
-    }, 'PDF.js v{{version}} (build: {{build}})') + '\n';
+    }, 'PDF.js v{{version}} (build: {{build}})')];
     if (moreInfo) {
-      moreInfoText += _ui_utils.mozL10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}');
+      moreInfoText.push(this.l10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}'));
       if (moreInfo.stack) {
-        moreInfoText += '\n' + _ui_utils.mozL10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}');
+        moreInfoText.push(this.l10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}'));
       } else {
         if (moreInfo.filename) {
-          moreInfoText += '\n' + _ui_utils.mozL10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}');
+          moreInfoText.push(this.l10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}'));
         }
         if (moreInfo.lineNumber) {
-          moreInfoText += '\n' + _ui_utils.mozL10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}');
+          moreInfoText.push(this.l10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}'));
         }
       }
     }
@@ -562,7 +585,9 @@ var PDFViewerApplication = {
     closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
     moreInfoButton.removeAttribute('hidden');
     lessInfoButton.setAttribute('hidden', 'true');
-    errorMoreInfo.value = moreInfoText;
+    Promise.all(moreInfoText).then(function (parts) {
+      errorMoreInfo.value = parts.join('\n');
+    });
   },
   progress: function pdfViewProgress(level) {
     var _this4 = this;
@@ -799,22 +824,26 @@ var PDFViewerApplication = {
     this.pdfRenderingQueue.renderHighestPriority();
   },
   beforePrint: function pdfViewSetupBeforePrint() {
+    var _this6 = this;
+
     if (this.printService) {
       return;
     }
     if (!this.supportsPrinting) {
-      var printMessage = _ui_utils.mozL10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by this browser.');
-      this.error(printMessage);
+      this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
+        _this6.error(printMessage);
+      });
       return;
     }
     if (!this.pdfViewer.pageViewsReady) {
-      var notReadyMessage = _ui_utils.mozL10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.');
-      window.alert(notReadyMessage);
+      this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
+        window.alert(notReadyMessage);
+      });
       return;
     }
     var pagesOverview = this.pdfViewer.getPagesOverview();
     var printContainer = this.appConfig.printContainer;
-    var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer);
+    var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
     this.printService = printService;
     this.forceRendering();
     printService.layout();
@@ -925,9 +954,9 @@ var validateFileURL;
       }
     } catch (e) {
       var message = e && e.message;
-      var loadingErrorMessage = _ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
-      var moreInfo = { message: message };
-      PDFViewerApplication.error(loadingErrorMessage, moreInfo);
+      PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
+        PDFViewerApplication.error(loadingErrorMessage, { message: message });
+      });
       throw e;
     }
   };
@@ -1004,9 +1033,6 @@ function webViewerInitialized() {
     if ('ignorecurrentpositiononzoom' in hashParams) {
       _pdf.PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
     }
-    if ('locale' in hashParams) {
-      _pdf.PDFJS.locale = hashParams['locale'];
-    }
     if ('textlayer' in hashParams) {
       switch (hashParams['textlayer']) {
         case 'off':
@@ -1027,7 +1053,6 @@ function webViewerInitialized() {
       waitForBeforeOpening.push(loadAndEnablePDFBug(enabled));
     }
   }
-  _ui_utils.mozL10n.setLanguage(_pdf.PDFJS.locale);
   if (!PDFViewerApplication.supportsPrinting) {
     appConfig.toolbar.print.classList.add('hidden');
     appConfig.secondaryToolbar.printButton.classList.add('hidden');
@@ -1050,7 +1075,9 @@ function webViewerInitialized() {
   Promise.all(waitForBeforeOpening).then(function () {
     webViewerOpenFileViaURL(file);
   }).catch(function (reason) {
-    PDFViewerApplication.error(_ui_utils.mozL10n.get('loading_error', null, 'An error occurred while opening.'), reason);
+    PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while opening.').then(function (msg) {
+      PDFViewerApplication.error(msg, reason);
+    });
   });
 }
 var webViewerOpenFileViaURL;
@@ -1067,7 +1094,9 @@ var webViewerOpenFileViaURL;
         xhr.responseType = 'arraybuffer';
         xhr.send();
       } catch (e) {
-        PDFViewerApplication.error(_ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.'), e);
+        PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
+          PDFViewerApplication.error(msg, e);
+        });
       }
       return;
     }
@@ -1094,7 +1123,9 @@ function webViewerPageRendered(e) {
     Stats.add(pageNumber, pageView.stats);
   }
   if (pageView.error) {
-    PDFViewerApplication.error(_ui_utils.mozL10n.get('rendering_error', null, 'An error occurred while rendering the page.'), pageView.error);
+    PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
+      PDFViewerApplication.error(msg, pageView.error);
+    });
   }
 }
 function webViewerTextLayerRendered(e) {}
@@ -1575,9 +1606,6 @@ function webViewerKeyDown(evt) {
     evt.preventDefault();
   }
 }
-_ui_utils.localized.then(function webViewerLocalized() {
-  document.getElementsByTagName('html')[0].dir = _ui_utils.mozL10n.getDirection();
-});
 var PDFPrintServiceFactory = {
   instance: {
     supportsPrinting: false,

+ 5 - 0
lib/web/chromecom.js

@@ -27,6 +27,8 @@ var _preferences = require('./preferences');
 
 var _download_manager = require('./download_manager');
 
+var _genericl10n = require('./genericl10n');
+
 var _pdf = require('../pdf');
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -311,5 +313,8 @@ ChromeExternalServices.createDownloadManager = function () {
 ChromeExternalServices.createPreferences = function () {
   return new ChromePreferences();
 };
+ChromeExternalServices.createL10n = function () {
+  return new _genericl10n.GenericL10n(navigator.language);
+};
 _app.PDFViewerApplication.externalServices = ChromeExternalServices;
 exports.ChromeCom = ChromeCom;

+ 34 - 0
lib/web/firefoxcom.js

@@ -23,6 +23,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
 
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
+require('../extensions/firefox/tools/l10n');
+
 var _pdf = require('../pdf');
 
 var _preferences = require('./preferences');
@@ -146,6 +148,34 @@ var FirefoxPreferences = function (_BasePreferences) {
   return FirefoxPreferences;
 }(_preferences.BasePreferences);
 
+var MozL10n = function () {
+  function MozL10n(mozL10n) {
+    _classCallCheck(this, MozL10n);
+
+    this.mozL10n = mozL10n;
+  }
+
+  _createClass(MozL10n, [{
+    key: 'getDirection',
+    value: function getDirection() {
+      return Promise.resolve(this.mozL10n.getDirection());
+    }
+  }, {
+    key: 'get',
+    value: function get(property, args, fallback) {
+      return Promise.resolve(this.mozL10n.get(property, args, fallback));
+    }
+  }, {
+    key: 'translate',
+    value: function translate(element) {
+      this.mozL10n.translate(element);
+      return Promise.resolve();
+    }
+  }]);
+
+  return MozL10n;
+}();
+
 (function listenFindEvents() {
   var events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange'];
   var handleEvent = function handleEvent(evt) {
@@ -234,6 +264,10 @@ _app.PDFViewerApplication.externalServices = {
   createPreferences: function createPreferences() {
     return new FirefoxPreferences();
   },
+  createL10n: function createL10n() {
+    var mozL10n = document.mozL10n;
+    return new MozL10n(mozL10n);
+  },
 
   get supportsIntegratedFind() {
     var support = FirefoxCom.requestSync('supportsIntegratedFind');

+ 7 - 0
lib/web/genericcom.js

@@ -27,6 +27,10 @@ var _preferences = require('./preferences');
 
 var _download_manager = require('./download_manager');
 
+var _genericl10n = require('./genericl10n');
+
+var _pdf = require('../pdf');
+
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@@ -73,5 +77,8 @@ GenericExternalServices.createDownloadManager = function () {
 GenericExternalServices.createPreferences = function () {
   return new GenericPreferences();
 };
+GenericExternalServices.createL10n = function () {
+  return new _genericl10n.GenericL10n(_pdf.PDFJS.locale);
+};
 _app.PDFViewerApplication.externalServices = GenericExternalServices;
 exports.GenericCom = GenericCom;

+ 68 - 0
lib/web/genericl10n.js

@@ -0,0 +1,68 @@
+/* Copyright 2017 Mozilla Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.GenericL10n = undefined;
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+require('../external/webL10n/l10n');
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var webL10n = document.webL10n;
+
+var GenericL10n = function () {
+  function GenericL10n(lang) {
+    _classCallCheck(this, GenericL10n);
+
+    this._lang = lang;
+    this._ready = new Promise(function (resolve, reject) {
+      webL10n.setLanguage(lang, function () {
+        resolve(webL10n);
+      });
+    });
+  }
+
+  _createClass(GenericL10n, [{
+    key: 'getDirection',
+    value: function getDirection() {
+      return this._ready.then(function (l10n) {
+        return l10n.getDirection();
+      });
+    }
+  }, {
+    key: 'get',
+    value: function get(property, args, fallback) {
+      return this._ready.then(function (l10n) {
+        return l10n.get(property, args, fallback);
+      });
+    }
+  }, {
+    key: 'translate',
+    value: function translate(element) {
+      return this._ready.then(function (l10n) {
+        return l10n.translate(element);
+      });
+    }
+  }]);
+
+  return GenericL10n;
+}();
+
+exports.GenericL10n = GenericL10n;

+ 20 - 0
lib/web/interfaces.js

@@ -118,8 +118,28 @@ var IPDFAnnotationLayerFactory = function () {
     key: 'createAnnotationLayerBuilder',
     value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
       var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
+      var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
     }
   }]);
 
   return IPDFAnnotationLayerFactory;
+}();
+
+var IL10n = function () {
+  function IL10n() {
+    _classCallCheck(this, IL10n);
+  }
+
+  _createClass(IL10n, [{
+    key: 'getDirection',
+    value: function getDirection() {}
+  }, {
+    key: 'get',
+    value: function get(key, args, fallback) {}
+  }, {
+    key: 'translate',
+    value: function translate(element) {}
+  }]);
+
+  return IL10n;
 }();

+ 10 - 3
lib/web/password_prompt.js

@@ -31,6 +31,8 @@ var PasswordPrompt = function () {
   function PasswordPrompt(options, overlayManager) {
     var _this = this;
 
+    var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
+
     _classCallCheck(this, PasswordPrompt);
 
     this.overlayName = options.overlayName;
@@ -40,6 +42,7 @@ var PasswordPrompt = function () {
     this.submitButton = options.submitButton;
     this.cancelButton = options.cancelButton;
     this.overlayManager = overlayManager;
+    this.l10n = l10n;
     this.updateCallback = null;
     this.reason = null;
     this.submitButton.addEventListener('click', this.verify.bind(this));
@@ -59,11 +62,15 @@ var PasswordPrompt = function () {
 
       this.overlayManager.open(this.overlayName).then(function () {
         _this2.input.focus();
-        var promptString = _ui_utils.mozL10n.get('password_label', null, 'Enter the password to open this PDF file.');
+        var promptString = void 0;
         if (_this2.reason === _pdf.PasswordResponses.INCORRECT_PASSWORD) {
-          promptString = _ui_utils.mozL10n.get('password_invalid', null, 'Invalid password. Please try again.');
+          promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
+        } else {
+          promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
         }
-        _this2.label.textContent = promptString;
+        promptString.then(function (msg) {
+          _this2.label.textContent = msg;
+        });
       });
     }
   }, {

+ 25 - 10
lib/web/pdf_document_properties.js

@@ -19,6 +19,8 @@ Object.defineProperty(exports, "__esModule", {
 });
 exports.PDFDocumentProperties = undefined;
 
+var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
+
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
 var _ui_utils = require('./ui_utils');
@@ -35,6 +37,7 @@ var PDFDocumentProperties = function () {
         fields = _ref.fields,
         container = _ref.container,
         closeButton = _ref.closeButton;
+    var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
 
     _classCallCheck(this, PDFDocumentProperties);
 
@@ -42,6 +45,7 @@ var PDFDocumentProperties = function () {
     this.fields = fields;
     this.container = container;
     this.overlayManager = overlayManager;
+    this.l10n = l10n;
     this._reset();
     if (closeButton) {
       closeButton.addEventListener('click', this.close.bind(this));
@@ -71,15 +75,24 @@ var PDFDocumentProperties = function () {
           var info = _ref2.info,
               metadata = _ref2.metadata;
 
+          return Promise.all([info, metadata, _this._parseFileSize(_this.maybeFileSize), _this._parseDate(info.CreationDate), _this._parseDate(info.ModDate)]);
+        }).then(function (_ref3) {
+          var _ref4 = _slicedToArray(_ref3, 5),
+              info = _ref4[0],
+              metadata = _ref4[1],
+              fileSize = _ref4[2],
+              creationDate = _ref4[3],
+              modificationDate = _ref4[4];
+
           freezeFieldData({
             'fileName': (0, _ui_utils.getPDFFileNameFromURL)(_this.url),
-            'fileSize': _this._parseFileSize(_this.maybeFileSize),
+            'fileSize': fileSize,
             'title': info.Title,
             'author': info.Author,
             'subject': info.Subject,
             'keywords': info.Keywords,
-            'creationDate': _this._parseDate(info.CreationDate),
-            'modificationDate': _this._parseDate(info.ModDate),
+            'creationDate': creationDate,
+            'modificationDate': modificationDate,
             'creator': info.Creator,
             'producer': info.Producer,
             'version': info.PDFFormatVersion,
@@ -87,11 +100,13 @@ var PDFDocumentProperties = function () {
           });
           _this._updateUI();
           return _this.pdfDocument.getDownloadInfo();
-        }).then(function (_ref3) {
-          var length = _ref3.length;
+        }).then(function (_ref5) {
+          var length = _ref5.length;
 
+          return _this._parseFileSize(length);
+        }).then(function (fileSize) {
           var data = (0, _ui_utils.cloneObj)(_this.fieldData);
-          data['fileSize'] = _this._parseFileSize(length);
+          data['fileSize'] = fileSize;
           freezeFieldData(data);
           _this._updateUI();
         });
@@ -158,14 +173,14 @@ var PDFDocumentProperties = function () {
 
       var kb = fileSize / 1024;
       if (!kb) {
-        return;
+        return Promise.resolve(undefined);
       } else if (kb < 1024) {
-        return _ui_utils.mozL10n.get('document_properties_kb', {
+        return this.l10n.get('document_properties_kb', {
           size_kb: (+kb.toPrecision(3)).toLocaleString(),
           size_b: fileSize.toLocaleString()
         }, '{{size_kb}} KB ({{size_b}} bytes)');
       }
-      return _ui_utils.mozL10n.get('document_properties_mb', {
+      return this.l10n.get('document_properties_mb', {
         size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
         size_b: fileSize.toLocaleString()
       }, '{{size_mb}} MB ({{size_b}} bytes)');
@@ -199,7 +214,7 @@ var PDFDocumentProperties = function () {
       var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
       var dateString = date.toLocaleDateString();
       var timeString = date.toLocaleTimeString();
-      return _ui_utils.mozL10n.get('document_properties_date_string', {
+      return this.l10n.get('document_properties_date_string', {
         date: dateString,
         time: timeString
       }, '{{date}}, {{time}}');

+ 11 - 4
lib/web/pdf_find_bar.js

@@ -31,6 +31,8 @@ var PDFFindBar = function () {
   function PDFFindBar(options) {
     var _this = this;
 
+    var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
+
     _classCallCheck(this, PDFFindBar);
 
     this.opened = false;
@@ -46,6 +48,7 @@ var PDFFindBar = function () {
     this.findNextButton = options.findNextButton || null;
     this.findController = options.findController || null;
     this.eventBus = options.eventBus;
+    this.l10n = l10n;
     if (this.findController === null) {
       throw new Error('PDFFindBar cannot be used without a ' + 'PDFFindController instance.');
     }
@@ -103,6 +106,8 @@ var PDFFindBar = function () {
   }, {
     key: 'updateUIState',
     value: function updateUIState(state, previous, matchCount) {
+      var _this2 = this;
+
       var notFound = false;
       var findMsg = '';
       var status = '';
@@ -113,14 +118,14 @@ var PDFFindBar = function () {
           status = 'pending';
           break;
         case _pdf_find_controller.FindStates.FIND_NOTFOUND:
-          findMsg = _ui_utils.mozL10n.get('find_not_found', null, 'Phrase not found');
+          findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
           notFound = true;
           break;
         case _pdf_find_controller.FindStates.FIND_WRAPPED:
           if (previous) {
-            findMsg = _ui_utils.mozL10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
+            findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
           } else {
-            findMsg = _ui_utils.mozL10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
+            findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
           }
           break;
       }
@@ -130,7 +135,9 @@ var PDFFindBar = function () {
         this.findField.classList.remove('notFound');
       }
       this.findField.setAttribute('data-status', status);
-      this.findMsg.textContent = findMsg;
+      Promise.resolve(findMsg).then(function (msg) {
+        _this2.findMsg.textContent = msg;
+      });
       this.updateResultsCount(matchCount);
       this._adjustWidth();
     }

+ 2 - 1
lib/web/pdf_page_view.js

@@ -54,6 +54,7 @@ var PDFPageView = function () {
     this.textLayerFactory = options.textLayerFactory;
     this.annotationLayerFactory = options.annotationLayerFactory;
     this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
+    this.l10n = options.l10n || _ui_utils.NullL10n;
     this.paintTask = null;
     this.paintedViewportMap = new WeakMap();
     this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
@@ -378,7 +379,7 @@ var PDFPageView = function () {
       });
       if (this.annotationLayerFactory) {
         if (!this.annotationLayer) {
-          this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms);
+          this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n);
         }
         this.annotationLayer.render(this.viewport, 'display');
       }

+ 10 - 7
lib/web/pdf_print_service.js

@@ -55,10 +55,11 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
     };
   });
 }
-function PDFPrintService(pdfDocument, pagesOverview, printContainer) {
+function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
   this.pdfDocument = pdfDocument;
   this.pagesOverview = pagesOverview;
   this.printContainer = printContainer;
+  this.l10n = l10n || _ui_utils.NullL10n;
   this.currentPage = -1;
   this.scratchCanvas = document.createElement('canvas');
 }
@@ -104,12 +105,12 @@ PDFPrintService.prototype = {
     var renderNextPage = function renderNextPage(resolve, reject) {
       _this.throwIfInactive();
       if (++_this.currentPage >= pageCount) {
-        renderProgress(pageCount, pageCount);
+        renderProgress(pageCount, pageCount, _this.l10n);
         resolve();
         return;
       }
       var index = _this.currentPage;
-      renderProgress(index, pageCount);
+      renderProgress(index, pageCount, _this.l10n);
       renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
         renderNextPage(resolve, reject);
       }, reject);
@@ -206,13 +207,15 @@ function abort() {
     dispatchEvent('afterprint');
   }
 }
-function renderProgress(index, total) {
+function renderProgress(index, total, l10n) {
   var progressContainer = document.getElementById('printServiceOverlay');
   var progress = Math.round(100 * index / total);
   var progressBar = progressContainer.querySelector('progress');
   var progressPerc = progressContainer.querySelector('.relative-progress');
   progressBar.value = progress;
-  progressPerc.textContent = _ui_utils.mozL10n.get('print_progress_percent', { progress: progress }, progress + '%');
+  l10n.get('print_progress_percent', { progress: progress }, progress + '%').then(function (msg) {
+    progressPerc.textContent = msg;
+  });
 }
 var hasAttachEvent = !!document.attachEvent;
 window.addEventListener('keydown', function (event) {
@@ -262,11 +265,11 @@ function ensureOverlay() {
 }
 _app.PDFPrintServiceFactory.instance = {
   supportsPrinting: true,
-  createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer) {
+  createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
     if (activeService) {
       throw new Error('The print service is created and active.');
     }
-    activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer);
+    activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
     return activeService;
   }
 };

+ 31 - 22
lib/web/pdf_sidebar.js

@@ -37,6 +37,8 @@ var SidebarView = {
 
 var PDFSidebar = function () {
   function PDFSidebar(options) {
+    var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
+
     _classCallCheck(this, PDFSidebar);
 
     this.isOpen = false;
@@ -57,6 +59,7 @@ var PDFSidebar = function () {
     this.outlineView = options.outlineView;
     this.attachmentsView = options.attachmentsView;
     this.disableNotification = options.disableNotification || false;
+    this.l10n = l10n;
     this._addEventListeners();
   }
 
@@ -224,10 +227,14 @@ var PDFSidebar = function () {
   }, {
     key: '_showUINotification',
     value: function _showUINotification(view) {
+      var _this = this;
+
       if (this.disableNotification) {
         return;
       }
-      this.toggleButton.title = _ui_utils.mozL10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)');
+      this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
+        _this.toggleButton.title = msg;
+      });
       if (!this.isOpen) {
         this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
       } else if (view === this.active) {
@@ -245,7 +252,7 @@ var PDFSidebar = function () {
   }, {
     key: '_hideUINotification',
     value: function _hideUINotification(view) {
-      var _this = this;
+      var _this2 = this;
 
       if (this.disableNotification) {
         return;
@@ -253,10 +260,10 @@ var PDFSidebar = function () {
       var removeNotification = function removeNotification(view) {
         switch (view) {
           case SidebarView.OUTLINE:
-            _this.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
+            _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
             break;
           case SidebarView.ATTACHMENTS:
-            _this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
+            _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
             break;
         }
       };
@@ -271,51 +278,53 @@ var PDFSidebar = function () {
       for (view in SidebarView) {
         removeNotification(SidebarView[view]);
       }
-      this.toggleButton.title = _ui_utils.mozL10n.get('toggle_sidebar.title', null, 'Toggle Sidebar');
+      this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
+        _this2.toggleButton.title = msg;
+      });
     }
   }, {
     key: '_addEventListeners',
     value: function _addEventListeners() {
-      var _this2 = this;
+      var _this3 = this;
 
       this.mainContainer.addEventListener('transitionend', function (evt) {
-        if (evt.target === _this2.mainContainer) {
-          _this2.outerContainer.classList.remove('sidebarMoving');
+        if (evt.target === _this3.mainContainer) {
+          _this3.outerContainer.classList.remove('sidebarMoving');
         }
       });
       this.thumbnailButton.addEventListener('click', function () {
-        _this2.switchView(SidebarView.THUMBS);
+        _this3.switchView(SidebarView.THUMBS);
       });
       this.outlineButton.addEventListener('click', function () {
-        _this2.switchView(SidebarView.OUTLINE);
+        _this3.switchView(SidebarView.OUTLINE);
       });
       this.outlineButton.addEventListener('dblclick', function () {
-        _this2.pdfOutlineViewer.toggleOutlineTree();
+        _this3.pdfOutlineViewer.toggleOutlineTree();
       });
       this.attachmentsButton.addEventListener('click', function () {
-        _this2.switchView(SidebarView.ATTACHMENTS);
+        _this3.switchView(SidebarView.ATTACHMENTS);
       });
       this.eventBus.on('outlineloaded', function (evt) {
         var outlineCount = evt.outlineCount;
-        _this2.outlineButton.disabled = !outlineCount;
+        _this3.outlineButton.disabled = !outlineCount;
         if (outlineCount) {
-          _this2._showUINotification(SidebarView.OUTLINE);
-        } else if (_this2.active === SidebarView.OUTLINE) {
-          _this2.switchView(SidebarView.THUMBS);
+          _this3._showUINotification(SidebarView.OUTLINE);
+        } else if (_this3.active === SidebarView.OUTLINE) {
+          _this3.switchView(SidebarView.THUMBS);
         }
       });
       this.eventBus.on('attachmentsloaded', function (evt) {
         var attachmentsCount = evt.attachmentsCount;
-        _this2.attachmentsButton.disabled = !attachmentsCount;
+        _this3.attachmentsButton.disabled = !attachmentsCount;
         if (attachmentsCount) {
-          _this2._showUINotification(SidebarView.ATTACHMENTS);
-        } else if (_this2.active === SidebarView.ATTACHMENTS) {
-          _this2.switchView(SidebarView.THUMBS);
+          _this3._showUINotification(SidebarView.ATTACHMENTS);
+        } else if (_this3.active === SidebarView.ATTACHMENTS) {
+          _this3.switchView(SidebarView.THUMBS);
         }
       });
       this.eventBus.on('presentationmodechanged', function (evt) {
-        if (!evt.active && !evt.switchInProgress && _this2.isThumbnailViewVisible) {
-          _this2._updateThumbnailViewer();
+        if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
+          _this3._updateThumbnailViewer();
         }
       });
     }

+ 33 - 20
lib/web/pdf_thumbnail_view.js

@@ -83,9 +83,12 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
     this.canvasWidth = THUMBNAIL_WIDTH;
     this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
     this.scale = this.canvasWidth / this.pageWidth;
+    this.l10n = options.l10n || _ui_utils.NullL10n;
     var anchor = document.createElement('a');
     anchor.href = linkService.getAnchorUrl('#page=' + id);
-    anchor.title = _ui_utils.mozL10n.get('thumb_page_title', { page: id }, 'Page {{page}}');
+    this.l10n.get('thumb_page_title', { page: id }, 'Page {{page}}').then(function (msg) {
+      anchor.title = msg;
+    });
     anchor.onclick = function stopNavigation() {
       linkService.page = id;
       return false;
@@ -177,6 +180,8 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
       return ctx;
     },
     _convertCanvasToImage: function PDFThumbnailView_convertCanvasToImage() {
+      var _this = this;
+
       if (!this.canvas) {
         return;
       }
@@ -185,11 +190,12 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
       }
       var id = this.renderingId;
       var className = 'thumbnailImage';
-      var ariaLabel = _ui_utils.mozL10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}');
       if (this.disableCanvasToImageConversion) {
         this.canvas.id = id;
         this.canvas.className = className;
-        this.canvas.setAttribute('aria-label', ariaLabel);
+        this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
+          _this.canvas.setAttribute('aria-label', msg);
+        });
         this.div.setAttribute('data-loaded', true);
         this.ring.appendChild(this.canvas);
         return;
@@ -197,7 +203,9 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
       var image = document.createElement('img');
       image.id = id;
       image.className = className;
-      image.setAttribute('aria-label', ariaLabel);
+      this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
+        image.setAttribute('aria-label', msg);
+      });
       image.style.width = this.canvasWidth + 'px';
       image.style.height = this.canvasHeight + 'px';
       image.src = this.canvas.toDataURL();
@@ -209,7 +217,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
       delete this.canvas;
     },
     draw: function draw() {
-      var _this = this;
+      var _this2 = this;
 
       if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
         console.error('Must be in new state before drawing');
@@ -218,15 +226,15 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
       this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
       var renderCapability = (0, _pdf.createPromiseCapability)();
       var finishRenderTask = function finishRenderTask(error) {
-        if (renderTask === _this.renderTask) {
-          _this.renderTask = null;
+        if (renderTask === _this2.renderTask) {
+          _this2.renderTask = null;
         }
         if (error === 'cancelled' || error instanceof _pdf.RenderingCancelledException) {
           renderCapability.resolve(undefined);
           return;
         }
-        _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
-        _this._convertCanvasToImage();
+        _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
+        _this2._convertCanvasToImage();
         if (!error) {
           renderCapability.resolve(undefined);
         } else {
@@ -236,10 +244,10 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
       var ctx = this._getPageDrawContext();
       var drawViewport = this.viewport.clone({ scale: this.scale });
       var renderContinueCallback = function renderContinueCallback(cont) {
-        if (!_this.renderingQueue.isHighestPriority(_this)) {
-          _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
-          _this.resume = function () {
-            _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
+        if (!_this2.renderingQueue.isHighestPriority(_this2)) {
+          _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
+          _this2.resume = function () {
+            _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
             cont();
           };
           return;
@@ -301,17 +309,22 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
       return this.pageLabel !== null ? this.pageLabel : this.id;
     },
     setPageLabel: function PDFThumbnailView_setPageLabel(label) {
+      var _this3 = this;
+
       this.pageLabel = typeof label === 'string' ? label : null;
-      this.anchor.title = _ui_utils.mozL10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}');
+      this.l10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}').then(function (msg) {
+        _this3.anchor.title = msg;
+      });
       if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
         return;
       }
-      var ariaLabel = _ui_utils.mozL10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}');
-      if (this.image) {
-        this.image.setAttribute('aria-label', ariaLabel);
-      } else if (this.disableCanvasToImageConversion && this.canvas) {
-        this.canvas.setAttribute('aria-label', ariaLabel);
-      }
+      this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
+        if (_this3.image) {
+          _this3.image.setAttribute('aria-label', ariaLabel);
+        } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
+          _this3.canvas.setAttribute('aria-label', ariaLabel);
+        }
+      });
     }
   };
   PDFThumbnailView.cleanup = function () {

+ 3 - 1
lib/web/pdf_thumbnail_viewer.js

@@ -29,6 +29,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
     this.container = options.container;
     this.renderingQueue = options.renderingQueue;
     this.linkService = options.linkService;
+    this.l10n = options.l10n || _ui_utils.NullL10n;
     this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
     this._resetView();
   }
@@ -102,7 +103,8 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
             defaultViewport: viewport.clone(),
             linkService: _this.linkService,
             renderingQueue: _this.renderingQueue,
-            disableCanvasToImageConversion: false
+            disableCanvasToImageConversion: false,
+            l10n: _this.l10n
           });
           _this.thumbnails.push(thumbnail);
         }

+ 3 - 0
lib/web/pdf_viewer.component.js

@@ -24,6 +24,7 @@ var pdfjsWebPDFHistory = require('./pdf_history.js');
 var pdfjsWebPDFFindController = require('./pdf_find_controller.js');
 var pdfjsWebUIUtils = require('./ui_utils.js');
 var pdfjsWebDownloadManager = require('./download_manager.js');
+var pdfjsWebGenericL10n = require('./genericl10n.js');
 var PDFJS = pdfjsLib.PDFJS;
 PDFJS.PDFViewer = pdfjsWebPDFViewer.PDFViewer;
 PDFJS.PDFPageView = pdfjsWebPDFPageView.PDFPageView;
@@ -37,4 +38,6 @@ PDFJS.PDFFindController = pdfjsWebPDFFindController.PDFFindController;
 PDFJS.EventBus = pdfjsWebUIUtils.EventBus;
 PDFJS.DownloadManager = pdfjsWebDownloadManager.DownloadManager;
 PDFJS.ProgressBar = pdfjsWebUIUtils.ProgressBar;
+PDFJS.GenericL10n = pdfjsWebGenericL10n.GenericL10n;
+PDFJS.NullL10n = pdfjsWebUIUtils.NullL10n;
 exports.PDFJS = PDFJS;

+ 6 - 2
lib/web/pdf_viewer.js

@@ -85,6 +85,7 @@ var PDFViewer = function pdfViewer() {
     this.renderInteractiveForms = options.renderInteractiveForms || false;
     this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
     this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
+    this.l10n = options.l10n || _ui_utils.NullL10n;
     this.defaultRenderingQueue = !options.renderingQueue;
     if (this.defaultRenderingQueue) {
       this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
@@ -260,7 +261,8 @@ var PDFViewer = function pdfViewer() {
             annotationLayerFactory: _this,
             enhanceTextSelection: _this.enhanceTextSelection,
             renderInteractiveForms: _this.renderInteractiveForms,
-            renderer: _this.renderer
+            renderer: _this.renderer,
+            l10n: _this.l10n
           });
           bindOnAfterAndBeforeDraw(pageView);
           _this._pages.push(pageView);
@@ -680,13 +682,15 @@ var PDFViewer = function pdfViewer() {
     },
     createAnnotationLayerBuilder: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
       var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
+      var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
 
       return new _annotation_layer_builder.AnnotationLayerBuilder({
         pageDiv: pageDiv,
         pdfPage: pdfPage,
         renderInteractiveForms: renderInteractiveForms,
         linkService: this.linkService,
-        downloadManager: this.downloadManager
+        downloadManager: this.downloadManager,
+        l10n: l10n
       });
     },
     setFindController: function setFindController(findController) {

+ 25 - 10
lib/web/toolbar.js

@@ -26,9 +26,12 @@ var SCALE_SELECT_CONTAINER_PADDING = 8;
 var SCALE_SELECT_PADDING = 22;
 var Toolbar = function ToolbarClosure() {
   function Toolbar(options, mainContainer, eventBus) {
+    var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
+
     this.toolbar = options.container;
     this.mainContainer = mainContainer;
     this.eventBus = eventBus;
+    this.l10n = l10n;
     this.items = options;
     this._wasLocalized = false;
     this.reset();
@@ -61,6 +64,8 @@ var Toolbar = function ToolbarClosure() {
     },
 
     _bindListeners: function Toolbar_bindClickListeners() {
+      var _this = this;
+
       var eventBus = this.eventBus;
       var self = this;
       var items = this.items;
@@ -107,7 +112,9 @@ var Toolbar = function ToolbarClosure() {
         eventBus.dispatch('download');
       });
       items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
-      _ui_utils.localized.then(this._localized.bind(this));
+      eventBus.on('localized', function (evt) {
+        _this._localized();
+      });
     },
     _localized: function Toolbar_localized() {
       this._wasLocalized = true;
@@ -115,7 +122,12 @@ var Toolbar = function ToolbarClosure() {
       this._updateUIState(true);
     },
     _updateUIState: function Toolbar_updateUIState(resetNumPages) {
-      function selectScaleOption(value, scale) {
+      var _this2 = this;
+
+      if (!this._wasLocalized) {
+        return;
+      }
+      var selectScaleOption = function selectScaleOption(value, scale) {
         var options = items.scaleSelect.options;
         var predefinedValueFound = false;
         for (var i = 0, ii = options.length; i < ii; i++) {
@@ -129,13 +141,12 @@ var Toolbar = function ToolbarClosure() {
         }
         if (!predefinedValueFound) {
           var customScale = Math.round(scale * 10000) / 100;
-          items.customScaleOption.textContent = _ui_utils.mozL10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%');
+          _this2.l10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%').then(function (msg) {
+            items.customScaleOption.textContent = msg;
+          });
           items.customScaleOption.selected = true;
         }
-      }
-      if (!this._wasLocalized) {
-        return;
-      }
+      };
       var pageNumber = this.pageNumber;
       var scaleValue = (this.pageScaleValue || this.pageScale).toString();
       var scale = this.pageScale;
@@ -146,16 +157,20 @@ var Toolbar = function ToolbarClosure() {
           items.pageNumber.type = 'text';
         } else {
           items.pageNumber.type = 'number';
-          items.numPages.textContent = _ui_utils.mozL10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}');
+          this.l10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}').then(function (msg) {
+            items.numPages.textContent = msg;
+          });
         }
         items.pageNumber.max = pagesCount;
       }
       if (this.hasPageLabels) {
         items.pageNumber.value = this.pageLabel;
-        items.numPages.textContent = _ui_utils.mozL10n.get('page_of_pages', {
+        this.l10n.get('page_of_pages', {
           pageNumber: pageNumber,
           pagesCount: pagesCount
-        }, '({{pageNumber}} of {{pagesCount}})');
+        }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
+          items.numPages.textContent = msg;
+        });
       } else {
         items.pageNumber.value = pageNumber;
       }

+ 20 - 15
lib/web/ui_utils.js

@@ -17,7 +17,7 @@
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
-exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
+exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
 
 var _pdf = require('../pdf');
 
@@ -34,7 +34,22 @@ var RendererType = {
   CANVAS: 'canvas',
   SVG: 'svg'
 };
-var mozL10n = typeof document !== 'undefined' ? document.mozL10n || document.webL10n : undefined;
+function formatL10nValue(text, args) {
+  if (!args) {
+    return text;
+  }
+  return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
+    return name in args ? args[name] : '{{' + name + '}}';
+  });
+}
+var NullL10n = {
+  get: function get(property, args, fallback) {
+    return Promise.resolve(formatL10nValue(fallback, args));
+  },
+  translate: function translate(element) {
+    return Promise.resolve();
+  }
+};
 _pdf.PDFJS.disableFullscreen = _pdf.PDFJS.disableFullscreen === undefined ? false : _pdf.PDFJS.disableFullscreen;
 _pdf.PDFJS.useOnlyCssZoom = _pdf.PDFJS.useOnlyCssZoom === undefined ? false : _pdf.PDFJS.useOnlyCssZoom;
 _pdf.PDFJS.maxCanvasPixels = _pdf.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdf.PDFJS.maxCanvasPixels;
@@ -301,19 +316,8 @@ function cloneObj(obj) {
 var animationStarted = new Promise(function (resolve) {
   window.requestAnimationFrame(resolve);
 });
-var localized = new Promise(function (resolve, reject) {
-  if (!mozL10n) {
-    resolve();
-    return;
-  }
-  if (mozL10n.getReadyState() !== 'loading') {
-    resolve();
-    return;
-  }
-  window.addEventListener('localized', function localized(evt) {
-    resolve();
-  });
-});
+var mozL10n;
+var localized = Promise.resolve();
 var EventBus = function EventBusClosure() {
   function EventBus() {
     this._listeners = Object.create(null);
@@ -421,6 +425,7 @@ exports.VERTICAL_PADDING = VERTICAL_PADDING;
 exports.cloneObj = cloneObj;
 exports.RendererType = RendererType;
 exports.mozL10n = mozL10n;
+exports.NullL10n = NullL10n;
 exports.EventBus = EventBus;
 exports.ProgressBar = ProgressBar;
 exports.getPDFFileNameFromURL = getPDFFileNameFromURL;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.8.404",
+  "version": "1.8.406",
   "main": "build/pdf.js",
   "description": "Generic build of Mozilla's PDF.js library.",
   "keywords": [

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 835 - 29
web/pdf_viewer.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
web/pdf_viewer.js.map


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.