From 9b8b3bd25f91152c7fb471cbf5b78e0f39df43cb Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 30 Apr 2012 15:29:05 -0500 Subject: [PATCH 01/27] Initial localization --- make.js | 9 ++- test/test.py | 3 +- web/locale.properties | 89 +++++++++++++++++++++++ web/viewer-snippet-firefox-extension.html | 1 + web/viewer-snippet.html | 1 + web/viewer.html | 42 +++++------ web/viewer.js | 34 ++++++--- 7 files changed, 145 insertions(+), 34 deletions(-) create mode 100644 web/locale.properties diff --git a/make.js b/make.js index b28682053..c8cd49610 100755 --- a/make.js +++ b/make.js @@ -40,8 +40,13 @@ target.web = function() { echo(); echo('### Creating web site'); + var GH_PAGES_SRC_FILES = [ + 'web/*', + 'external/webL10n/l10n.js' + ]; + cp(BUILD_TARGET, GH_PAGES_DIR + BUILD_TARGET); - cp('-R', 'web/*', GH_PAGES_DIR + '/web'); + cp('-R', GH_PAGES_SRC_FILES, GH_PAGES_DIR + '/web'); cp(FIREFOX_BUILD_DIR + '/*.xpi', FIREFOX_BUILD_DIR + '/*.rdf', GH_PAGES_DIR + EXTENSION_SRC_DIR + 'firefox/'); cp(GH_PAGES_DIR + '/web/index.html.template', GH_PAGES_DIR + '/index.html'); @@ -175,6 +180,8 @@ var EXTENSION_WEB_FILES = 'web/viewer.css', 'web/viewer.js', 'web/viewer.html', + 'external/webL10n/l10n.js', + 'web/locale.properties', 'web/viewer-production.html'], EXTENSION_BASE_VERSION = 'f0f0418a9c6637981fe1182b9212c2d592774c7d', EXTENSION_VERSION_PREFIX = '0.3.', diff --git a/test/test.py b/test/test.py index d5b473107..5dcc77298 100644 --- a/test/test.py +++ b/test/test.py @@ -73,7 +73,8 @@ MIMEs = { '.gif': 'image/gif', '.ico': 'image/x-icon', '.png': 'image/png', - '.log': 'text/plain' + '.log': 'text/plain', + '.properties': 'text/plain' } class State: diff --git a/web/locale.properties b/web/locale.properties new file mode 100644 index 000000000..d5c9dae37 --- /dev/null +++ b/web/locale.properties @@ -0,0 +1,89 @@ +[*] +bookmark.title=Current view (copy or open in new window) +bookmark_icon.alt=Bookmark +previous_label=Previous +next_label=Next +print_label=Print +download_label=Download +zoom_out.title=Zoom Out +zoom_in.title=Zoom In +error_more_info=More Information +error_less_info=Less Information +error_close=Close +error_build=PDF.JS Build: {{build}} +error_message=Message: {{message}} +error_stack=Stack: {{stack}} +error_file=File: {{file}} +error_line=Line: {{line}} +page_scale_width=Page Width +page_scale_fit=Page Fit +page_scale_auto=Auto +thumbs.title=Show Thumbnails +thumbs_icon.alt=Thumbs +outline.title=Show Document Outline +outline_icon.alt=Document Outline +loading=Loading... {{percent}}% +loading_error_indicator=Error +loading_error=An error occurred while loading the PDF. +rendering_error=An error occurred while rendering the page. + +[ru] +bookmark.title=Ссылка на текущий вид (скопировать или открыть в новом окне) +bookmark_icon.alt=Закладка +previous_label=Предыдущая +next_label=Следующая +print_label=Печать +download_label=Загрузить +zoom_out.title=Уменьшить +zoom_in.title=Увеличить +error_more_info=Больше информации +error_less_info=Меньше информации +error_close=Закрыть +error_build=PDF.JS компиляция: {{build}} +error_message=Сообщение: {{message}} +error_stack=Стeк: {{stack}} +error_file=Файл: {{file}} +error_line=Строка: {{line}} +page_scale_width=Ширина страницы +page_scale_fit=Вся страница +page_scale_auto=Автоматически +thumbs.title=Показать уменьшенные изображения +thumbs_icon.alt=Уменьшенные изображения +outline.title=Показать содержание документа +outline_icon.alt=Содержание документа +loading=Загрузка... {{percent}}% +loading_error_indicator=Ошибка +loading_error=Произошла ошибка во время загрузки PDF. +rendering_error=Произошла ошибка во время создания страницы. + +loading=Загрузка... {{percent}}% + +[xx] +bookmark.title=<<<_¢ȗггεпţ ṿiεẂ (¢OÞӳ Oг OÞεп iп пεẂ ẂiпÐOẂ)_>>> +bookmark_icon.alt=<<<_ьOOқмãгқ_>>> +previous_label=<<<_ÞгεṿiOȗ§_>>> +next_label=<<<_пεӾţ_>>> +print_label=<<<_Þгiпţ_>>> +download_label=<<<_ÐOẂпḻOãÐ_>>> +zoom_out.title=<<<_ƩOOм Oȗţ_>>> +zoom_in.title=<<<_ƩOOм iп_>>> +error_more_info=<<<_мOгε iп£OгмãţiOп_>>> +error_less_info=<<<_ḻ姧 iп£OгмãţiOп_>>> +error_close=<<<_¢ḻO§ε_>>> +error_build=<<<_ÞУ.ʃ§ ьȗiḻÐ: {{ьȗiḻÐ}}_>>> +error_message=<<<_м姧ãģε: {{м姧ãģε}}_>>> +error_stack=<<<_§ţã¢қ: {{§ţã¢қ}}_>>> +error_file=<<<_£iḻε: {{£iḻε}}_>>> +error_line=<<<_ḻiпε: {{ḻiпε}}_>>> +page_scale_width=<<<_Þãģε ẂiÐţН_>>> +page_scale_fit=<<<_Þãģε £iţ_>>> +page_scale_auto=<<<_ãȗţO_>>> +thumbs.title=<<<_§НOẂ ţНȗмьпãiḻ§_>>> +thumbs_icon.alt=<<<_ţНȗмь§_>>> +outline.title=<<<_§НOẂ ÐO¢ȗмεпţ Oȗţḻiпε_>>> +outline_icon.alt=<<<_ÐO¢ȗмεпţ Oȗţḻiпε_>>> +loading=<<<_ḻOãÐiпģ... {{Þεг¢εпţ}}%_>>> +loading_error_indicator=<<<_εггOг_>>> +loading_error=<<<_ãп εггOг O¢¢ȗггεÐ ẂНiḻε ḻOãÐiпģ ţНε ÞУ._>>> +rendering_error=<<<_ãп εггOг O¢¢ȗггεÐ ẂНiḻε гεпÐεгiпģ ţНε Þãģε._>>> + diff --git a/web/viewer-snippet-firefox-extension.html b/web/viewer-snippet-firefox-extension.html index a3d3502a8..72cf3f095 100644 --- a/web/viewer-snippet-firefox-extension.html +++ b/web/viewer-snippet-firefox-extension.html @@ -1,5 +1,6 @@ + @@ -33,22 +34,21 @@ + - -
@@ -60,10 +60,10 @@
- - @@ -77,21 +77,21 @@ - - - + + +
@@ -100,23 +100,23 @@
- - Bookmark + + Bookmark
- -
-
Loading... 0%
+
Loading... 0%
diff --git a/web/viewer.js b/web/viewer.js index 340cf2005..49571e9f8 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -15,6 +15,8 @@ var kMaxScale = 4.0; var kImageDirectory = './images/'; var kSettingsMemory = 20; +var mozL10n = document.mozL10n || document.webL10n; + function getFileName(url) { var anchor = url.indexOf('#'); var query = url.indexOf('?'); @@ -326,11 +328,11 @@ var PDFView = { }, function getDocumentError(message, exception) { var loadingIndicator = document.getElementById('loading'); - loadingIndicator.textContent = 'Error'; + loadingIndicator.textContent = mozL10n.get('loading_error_indicator'); var moreInfo = { message: message }; - self.error('An error occurred while loading the PDF.', moreInfo); + self.error(mozL10n.get('loading_error'), moreInfo); self.loading = false; }, function getDocumentProgress(progressData) { @@ -437,17 +439,24 @@ var PDFView = { }; moreInfoButton.removeAttribute('hidden'); lessInfoButton.setAttribute('hidden', 'true'); - errorMoreInfo.value = 'PDF.JS Build: ' + PDFJS.build + '\n'; + errorMoreInfo.value = + mozL10n.get('error_build', {build: PDFJS.build}) + '\n'; if (moreInfo) { - errorMoreInfo.value += 'Message: ' + moreInfo.message; + errorMoreInfo.value += + mozL10n.get('error_message', {message: moreInfo.message}); if (moreInfo.stack) { - errorMoreInfo.value += '\n' + 'Stack: ' + moreInfo.stack; + errorMoreInfo.value += '\n' + + mozL10n.get('error_stack', {stack: moreInfo.stack}); } else { - if (moreInfo.filename) - errorMoreInfo.value += '\n' + 'File: ' + moreInfo.filename; - if (moreInfo.lineNumber) - errorMoreInfo.value += '\n' + 'Line: ' + moreInfo.lineNumber; + if (moreInfo.filename) { + errorMoreInfo.value += '\n' + + mozL10n.get('error_file', {file: moreInfo.filename}); + } + if (moreInfo.lineNumber) { + errorMoreInfo.value += '\n' + + mozL10n.get('error_line', {line: moreInfo.lineNumber}); + } } } errorMoreInfo.rows = errorMoreInfo.value.split('\n').length - 1; @@ -456,7 +465,7 @@ var PDFView = { progress: function pdfViewProgress(level) { var percent = Math.round(level * 100); var loadingIndicator = document.getElementById('loading'); - loadingIndicator.textContent = 'Loading... ' + percent + '%'; + loadingIndicator.textContent = mozL10n.get('loading', {percent: percent}); PDFView.loadingBar.percent = percent; }, @@ -992,7 +1001,7 @@ var PageView = function pageView(container, pdfPage, id, scale, } if (error) - PDFView.error('An error occurred while rendering the page.', error); + PDFView.error(mozL10n.get('rendering_error'), error); self.stats = pdfPage.stats; self.updateStats(); @@ -1309,6 +1318,9 @@ window.addEventListener('load', function webViewerLoad(evt) { if ('disableWorker' in hashParams) PDFJS.disableWorker = (hashParams['disableWorker'] === 'true'); + if ('locale' in hashParams) + mozL10n.language.code = hashParams['locale']; + if ('disableTextLayer' in hashParams) PDFJS.disableTextLayer = (hashParams['disableTextLayer'] === 'true'); From 7859ba89c31eb1e11edd7ff2ce38fb95ea98142c Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 30 Apr 2012 15:33:37 -0500 Subject: [PATCH 02/27] Missing webL10n library files --- external/webL10n/README.md | 3 + external/webL10n/l10n.js | 304 +++++++++++++++++++++++++++++++++++++ 2 files changed, 307 insertions(+) create mode 100644 external/webL10n/README.md create mode 100644 external/webL10n/l10n.js diff --git a/external/webL10n/README.md b/external/webL10n/README.md new file mode 100644 index 000000000..52995522c --- /dev/null +++ b/external/webL10n/README.md @@ -0,0 +1,3 @@ +The source code for the library can be found at + + https://github.com/fabi1cazenave/webL10n diff --git a/external/webL10n/l10n.js b/external/webL10n/l10n.js new file mode 100644 index 000000000..fedf70cde --- /dev/null +++ b/external/webL10n/l10n.js @@ -0,0 +1,304 @@ +/* Copyright (c) 2011-2012 Fabien Cazenave, Mozilla. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +'use strict'; + +(function(window) { + var gL10nData = {}; + var gTextData = ''; + var gLanguage = ''; + + // parser + + function evalString(text) { + return text.replace(/\\\\/g, '\\') + .replace(/\\n/g, '\n') + .replace(/\\r/g, '\r') + .replace(/\\t/g, '\t') + .replace(/\\b/g, '\b') + .replace(/\\f/g, '\f') + .replace(/\\{/g, '{') + .replace(/\\}/g, '}') + .replace(/\\"/g, '"') + .replace(/\\'/g, "'"); + } + + function parseProperties(text, lang) { + var reBlank = /^\s*|\s*$/; + var reComment = /^\s*#|^\s*$/; + var reSection = /^\s*\[(.*)\]\s*$/; + var reImport = /^\s*@import\s+url\((.*)\)\s*$/i; + + // parse the *.properties file into an associative array + var currentLang = '*'; + var supportedLang = []; + var skipLang = false; + var data = []; + var match = ''; + var entries = text.replace(reBlank, '').split(/[\r\n]+/); + for (var i = 0; i < entries.length; i++) { + var line = entries[i]; + + // comment or blank line? + if (reComment.test(line)) + continue; + + // section start? + if (reSection.test(line)) { + match = reSection.exec(line); + currentLang = match[1]; + skipLang = (currentLang != lang) && (currentLang != '*'); + continue; + } else if (skipLang) { + continue; + } + + // @import rule? + if (reImport.test(line)) { + match = reImport.exec(line); + } + + // key-value pair + var tmp = line.split('='); + if (tmp.length > 1) + data[tmp[0]] = evalString(tmp[1]); + } + + // find the attribute descriptions, if any + for (var key in data) { + var id, prop, index = key.lastIndexOf('.'); + if (index > 0) { // attribute + id = key.substring(0, index); + prop = key.substr(index + 1); + } else { // textContent, could be innerHTML as well + id = key; + prop = 'textContent'; + } + if (!gL10nData[id]) + gL10nData[id] = {}; + gL10nData[id][prop] = data[key]; + } + } + + function parse(text, lang) { + gTextData += text; + // we only support *.properties files at the moment + return parseProperties(text, lang); + } + + // load and parse the specified resource file + function loadResource(href, lang, onSuccess, onFailure) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', href, true); + xhr.overrideMimeType('text/plain; charset=utf-8'); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4) { + if (xhr.status == 200 || xhr.status == 0) { + parse(xhr.responseText, lang); + if (onSuccess) + onSuccess(); + } else { + if (onFailure) + onFailure(); + } + } + }; + xhr.send(null); + } + + // load and parse all resources for the specified locale + function loadLocale(lang, callback) { + clear(); + + // check all nodes + // and load the resource files + var langLinks = document.querySelectorAll('link[type="application/l10n"]'); + var langCount = langLinks.length; + + // start the callback when all resources are loaded + var onResourceLoaded = null; + var gResourceCount = 0; + onResourceLoaded = function() { + gResourceCount++; + if (gResourceCount >= langCount) { + // execute the [optional] callback + if (callback) + callback(); + // fire a 'localized' DOM event + var evtObject = document.createEvent('Event'); + evtObject.initEvent('localized', false, false); + evtObject.language = lang; + window.dispatchEvent(evtObject); + } + } + + // load all resource files + function l10nResourceLink(link) { + var href = link.href; + var type = link.type; + this.load = function(lang, callback) { + var applied = lang; + loadResource(href, lang, callback, function() { + console.warn(href + ' not found.'); + applied = ''; + }); + return applied; // return lang if found, an empty string if not found + }; + } + + gLanguage = lang; + for (var i = 0; i < langCount; i++) { + var resource = new l10nResourceLink(langLinks[i]); + var rv = resource.load(lang, onResourceLoaded); + if (rv != lang) // lang not found, used default resource instead + gLanguage = ''; + } + } + + // fetch an l10n object, warn if not found + function getL10nData(key) { + var data = gL10nData[key]; + if (!data) + console.warn('[l10n] #' + key + ' missing for [' + gLanguage + ']'); + return data; + } + + // replace {{arguments}} with their values + function substArguments(str, args) { + var reArgs = /\{\{\s*([a-zA-Z\.]+)\s*\}\}/; + var match = reArgs.exec(str); + while (match) { + if (!match || match.length < 2) + return str; // argument key not found + + var arg = match[1]; + var sub = ''; + if (arg in args) { + sub = args[arg]; + } else if (arg in gL10nData) { + sub = gL10nData[arg].textContent; + } else { + console.warn('[l10n] could not find argument {{' + arg + '}}'); + return str; + } + + str = str.substring(0, match.index) + sub + + str.substr(match.index + match[0].length); + match = reArgs.exec(str); + } + return str; + } + + // translate a string + function translateString(key, args) { + var data = getL10nData(key); + if (!data) + return '{{' + key + '}}'; + return substArguments(data.textContent, args); + } + + // translate an HTML element + function translateElement(element) { + if (!element || !element.dataset) + return; + + // get the related l10n object + var key = element.dataset.l10nId; + var data = getL10nData(key); + if (!data) + return; + + // get arguments (if any) + // TODO: more flexible parser? + var args; + if (element.dataset.l10nArgs) try { + args = JSON.parse(element.dataset.l10nArgs); + } catch (e) { + console.warn('[l10n] could not parse arguments for #' + key + ''); + } + + // translate element + // TODO: security check? + for (var k in data) + element[k] = substArguments(data[k], args); + } + + // translate an HTML subtree + function translateFragment(element) { + element = element || document.querySelector('html'); + + // check all translatable children (= w/ a `data-l10n-id' attribute) + var children = element.querySelectorAll('*[data-l10n-id]'); + var elementCount = children.length; + for (var i = 0; i < elementCount; i++) + translateElement(children[i]); + + // translate element itself if necessary + if (element.dataset.l10nId) + translateElement(element); + } + + // clear all l10n data + function clear() { + gL10nData = {}; + gTextData = ''; + gLanguage = ''; + } + + // load the default locale on startup + window.addEventListener('DOMContentLoaded', function() { + var lang = navigator.language; + if (navigator.mozSettings) { + var req = navigator.mozSettings.getLock().get('language.current'); + req.onsuccess = function() { + loadLocale(req.result['language.current'] || lang, translateFragment); + }; + req.onerror = function() { + loadLocale(lang, translateFragment); + }; + } else { + loadLocale(lang, translateFragment); + } + }); + + // Public API + document.mozL10n = { + // get a localized string + get: translateString, + + // get|set the document language and direction + get language() { + return { + // get|set the document language (ISO-639-1) + get code() { return gLanguage; }, + set code(lang) { loadLocale(lang, translateFragment); }, + + // get the direction (ltr|rtl) of the current language + get direction() { + // http://www.w3.org/International/questions/qa-scripts + // Arabic, Hebrew, Farsi, Pashto, Urdu + var rtlList = ['ar', 'he', 'fa', 'ps', 'ur']; + return (rtlList.indexOf(gLanguage) >= 0) ? 'rtl' : 'ltr'; + } + }; + } + }; +})(this); From 08daef9c72ae98dca9d545c204fe7212eaf0b7fd Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 30 Apr 2012 18:38:10 -0500 Subject: [PATCH 03/27] Fix ru language --- web/locale.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/locale.properties b/web/locale.properties index 328e00538..bad40715a 100644 --- a/web/locale.properties +++ b/web/locale.properties @@ -46,8 +46,9 @@ error_file=Файл: {{file}} error_line=Строка: {{line}} page_scale_width=Ширина страницы page_scale_fit=Вся страница -page_scale_auto=Автоматически +page_scale_auto=Автоматический page_scale_actual=Настоящий размер +toggle_slider.title=Открыть/закрыть вспомогательную панель thumbs.title=Показать уменьшенные изображения outline.title=Показать содержание документа loading=Загрузка... {{percent}}% From 72eb2d2e5b27ceea29d791bcd9bbe1d7451eceb4 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 30 Apr 2012 18:47:10 -0500 Subject: [PATCH 04/27] Localize 'No outline' message --- web/locale.properties | 3 +++ web/viewer.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/locale.properties b/web/locale.properties index bad40715a..20f70915a 100644 --- a/web/locale.properties +++ b/web/locale.properties @@ -27,6 +27,7 @@ loading_error=An error occurred while loading the PDF. rendering_error=An error occurred while rendering the page. page_label=Page: page_of=of {{pageCount}} +no_outline=No Outline Available [ru] bookmark.title=Ссылка на текущий вид (скопировать или открыть в новом окне) @@ -57,6 +58,7 @@ loading_error=Произошла ошибка во время загрузки P rendering_error=Произошла ошибка во время создания страницы. page_label=Страница: page_of=из {{pageCount}} +no_outline=Содержание не доступно [xx] bookmark.title=<<<_¢ȗггεпţ ṿiεẂ (¢OÞӳ Oг OÞεп iп пεẂ ẂiпÐOẂ)_>>> @@ -87,3 +89,4 @@ loading_error=<<<_ãп εггOг O¢¢ȗггεÐ ẂНiḻε ḻOãÐiпģ ţН rendering_error=<<<_ãп εггOг O¢¢ȗггεÐ ẂНiḻε гεпÐεгiпģ ţНε Þãģε._>>> page_label=Þãģε: page_of=<<<_O£ {{pageCount}}_>>> +no_outline=<<<_пO Oȗţḻiпε ãṿãiḻãьḻε_>>> \ No newline at end of file diff --git a/web/viewer.js b/web/viewer.js index eb18b881b..bc235aac9 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -1163,7 +1163,7 @@ var DocumentOutlineView = function documentOutlineView(outline) { if (!outline) { var noOutline = document.createElement('div'); noOutline.classList.add('noOutline'); - noOutline.textContent = 'No Outline Available'; + noOutline.textContent = mozL10n.get('no_outline'); outlineView.appendChild(noOutline); return; } From 00543a1c89cfb1a5bfadea64271d23ff3e42fa37 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 30 Apr 2012 21:55:21 -0500 Subject: [PATCH 05/27] Embed locale.properties in the viewer.html for extension --- external/webL10n/l10n.js | 12 ++++++++++-- make.js | 4 ++++ web/viewer-snippet-firefox-extension.html | 14 +++++++++++++- web/viewer-snippet.html | 1 + web/viewer.html | 3 ++- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/external/webL10n/l10n.js b/external/webL10n/l10n.js index fedf70cde..bb847ee10 100644 --- a/external/webL10n/l10n.js +++ b/external/webL10n/l10n.js @@ -131,7 +131,10 @@ // check all nodes // and load the resource files var langLinks = document.querySelectorAll('link[type="application/l10n"]'); - var langCount = langLinks.length; + var langLinksCount = langLinks.length; + var langScripts = document.querySelectorAll('script[type="application/l10n"]'); + var langScriptCount = langScripts.length; + var langCount = langLinksCount + langScriptCount; // start the callback when all resources are loaded var onResourceLoaded = null; @@ -165,12 +168,17 @@ } gLanguage = lang; - for (var i = 0; i < langCount; i++) { + for (var i = 0; i < langLinksCount; i++) { var resource = new l10nResourceLink(langLinks[i]); var rv = resource.load(lang, onResourceLoaded); if (rv != lang) // lang not found, used default resource instead gLanguage = ''; } + for (var i = 0; i < langScriptCount; i++) { + var scriptText = langScripts[i].text; + parse(scriptText, lang); + onResourceLoaded(); + } } // fetch an l10n object, warn if not found diff --git a/make.js b/make.js index c8cd49610..36f4ef073 100755 --- a/make.js +++ b/make.js @@ -252,6 +252,8 @@ target.firefox = function() { FIREFOX_EXTENSION_NAME = 'pdf.js.xpi', FIREFOX_AMO_EXTENSION_NAME = 'pdf.js.amo.xpi'; + var LOCALE_CONTENT = cat('web/locale.properties'); + target.production(); target.buildnumber(); cd(ROOT_DIR); @@ -278,6 +280,8 @@ target.firefox = function() { // Modify the viewer so it does all the extension-only stuff. cd(FIREFOX_BUILD_CONTENT_DIR + '/web'); sed('-i', /.*PDFJSSCRIPT_INCLUDE_BUNDLE.*\n/, cat(ROOT_DIR + BUILD_TARGET), 'viewer-snippet-firefox-extension.html'); + sed('-i', /.*PDFJSSCRIPT_OTHER_SCRIPTS.*\n/, cat(ROOT_DIR + 'external/webL10n/l10n.js'), 'viewer-snippet-firefox-extension.html'); + sed('-i', /PDFJSSCRIPT_LOCALE_DATA/, JSON.stringify({text: LOCALE_CONTENT}), 'viewer-snippet-firefox-extension.html'); sed('-i', /.*PDFJSSCRIPT_REMOVE_CORE.*\n/g, '', 'viewer.html'); sed('-i', /.*PDFJSSCRIPT_REMOVE_FIREFOX_EXTENSION.*\n/g, '', 'viewer.html'); sed('-i', /.*PDFJSSCRIPT_INCLUDE_FIREFOX_EXTENSION.*\n/, cat('viewer-snippet-firefox-extension.html'), 'viewer.html'); diff --git a/web/viewer-snippet-firefox-extension.html b/web/viewer-snippet-firefox-extension.html index 72cf3f095..d3faaae51 100644 --- a/web/viewer-snippet-firefox-extension.html +++ b/web/viewer-snippet-firefox-extension.html @@ -1,6 +1,18 @@ - + From bc094a84f4cfd020fbcb77ed94dc280904585b8e Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 30 Apr 2012 22:06:54 -0500 Subject: [PATCH 06/27] Keeping l10n.js file reference; removing temp/unused files --- make.js | 3 ++- web/viewer-snippet-firefox-extension.html | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/make.js b/make.js index 36f4ef073..8c1319554 100755 --- a/make.js +++ b/make.js @@ -280,7 +280,6 @@ target.firefox = function() { // Modify the viewer so it does all the extension-only stuff. cd(FIREFOX_BUILD_CONTENT_DIR + '/web'); sed('-i', /.*PDFJSSCRIPT_INCLUDE_BUNDLE.*\n/, cat(ROOT_DIR + BUILD_TARGET), 'viewer-snippet-firefox-extension.html'); - sed('-i', /.*PDFJSSCRIPT_OTHER_SCRIPTS.*\n/, cat(ROOT_DIR + 'external/webL10n/l10n.js'), 'viewer-snippet-firefox-extension.html'); sed('-i', /PDFJSSCRIPT_LOCALE_DATA/, JSON.stringify({text: LOCALE_CONTENT}), 'viewer-snippet-firefox-extension.html'); sed('-i', /.*PDFJSSCRIPT_REMOVE_CORE.*\n/g, '', 'viewer.html'); sed('-i', /.*PDFJSSCRIPT_REMOVE_FIREFOX_EXTENSION.*\n/g, '', 'viewer.html'); @@ -289,6 +288,8 @@ target.firefox = function() { // We don't need pdf.js anymore since its inlined rm('-Rf', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR); + rm(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer-snippet-firefox-extension.html'); + rm(FIREFOX_BUILD_CONTENT_DIR + '/web/locale.properties'); // Remove '.DS_Store' and other hidden files find(FIREFOX_BUILD_DIR).forEach(function(file) { if (file.match(/^\./)) diff --git a/web/viewer-snippet-firefox-extension.html b/web/viewer-snippet-firefox-extension.html index d3faaae51..a5c0da0a5 100644 --- a/web/viewer-snippet-firefox-extension.html +++ b/web/viewer-snippet-firefox-extension.html @@ -10,9 +10,8 @@ script.text = localeData.text; document.getElementsByTagName('head')[0].appendChild(script); })(); - -/* PDFJSSCRIPT_OTHER_SCRIPTS */ +