Merge pull request #1636 from mozilla/l10n

Using webL10n library to localize the pdf.js
This commit is contained in:
Brendan Dahl 2012-05-04 12:13:24 -07:00
commit e9128e2e35
31 changed files with 941 additions and 78 deletions

View File

@ -1 +1,2 @@
content/
metadata.inc

View File

@ -58,6 +58,9 @@ ChromeActions.prototype = {
return '{}';
return application.prefs.getValue(EXT_PREFIX + '.database', '{}');
},
getLocale: function() {
return application.prefs.getValue('general.useragent.locale', 'en-US');
},
pdfBugEnabled: function() {
return application.prefs.getValue(EXT_PREFIX + '.pdfBugEnabled', false);
}

View File

@ -5,6 +5,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>uriloader@pdf.js</em:id>
<!-- PDFJS_LOCALIZED_METADATA -->
<em:name>PDF Viewer</em:name>
<em:version>PDFJSSCRIPT_VERSION</em:version>
<em:targetApplication>

View File

@ -7,6 +7,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>uriloader@pdf.js</em:id>
<!-- PDFJS_LOCALIZED_METADATA -->
<em:name>PDF Viewer</em:name>
<em:version>PDFJSSCRIPT_VERSION</em:version>
<em:targetApplication>

3
external/webL10n/README.md vendored Normal file
View File

@ -0,0 +1,3 @@
The source code for the library can be found at
https://github.com/fabi1cazenave/webL10n

322
external/webL10n/l10n.js vendored Normal file
View File

@ -0,0 +1,322 @@
/* 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.
*/
/*
Additional modifications for PDF.js project:
- Loading resources from <script type='application/l10n'>;
- Disabling language initialization on page loading;
- Add fallback argument to the translateString.
*/
'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 != '*') &&
(currentLang != lang.substring(0, 2));
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 <link type="application/l10n" href="..." /> nodes
// and load the resource files
var langLinks = document.querySelectorAll('link[type="application/l10n"]');
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;
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 < 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
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, fallback) {
var data = getL10nData(key);
if (!data && fallback)
data = {textContent: fallback};
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);

8
l10n/ar/metadata.inc Normal file
View File

@ -0,0 +1,8 @@
<em:localized>
<Description>
<em:locale>ar</em:locale>
<em:name>عارض PDF</em:name>
<em:description>يستخدم HTML5 لعرض ملفات PDF مباشره من خلال Firefox.</em:description>
</Description>
</em:localized>

31
l10n/ar/viewer.properties Normal file
View File

@ -0,0 +1,31 @@
bookmark.title=النافذه الحالية (نسخ أو فتح نافذة جديدة)
previous.title=السابق
next.title=التالي
print.title=طباعة
download.title=تحميل
zoom_out.title=التصغير
zoom_in.title=تكبير
error_more_info=مزيد من المعلومات
error_less_info=معلومات أقل
error_close=أغلق
error_build=PDF.JS بناء: {{build}}
error_message=رسالة: {{message}}
error_stack=المكدس: {{stack}}
error_file=ملف: {{file}}
error_line=سطر: {{line}}
page_scale_width=عرض الصفحه
page_scale_fit=تحجيم الصفحه
page_scale_auto=تكبير تلقائي
page_scale_actual=الحجم الفعلي
toggle_slider.title=تبديل المتزلج
thumbs.title=اظهار الصور المصغرة
outline.title=عرض مخطط الوثيقه
loading=تحميل ... {{percent}}٪
loading_error_indicator=خطأ
loading_error=حدث خطأ أثناء تحميل وثيقه بي دي اف
rendering_error=حدث خطأ اثناء رسم الصفحه
page_label=الصفحة:
page_of=من {{pageCount}}
no_outline=لايوجد مخطط
open_file.title=فتح ملف
text_annotation_type=[{{type}} ملاحظة]

8
l10n/da-DK/metadata.inc Normal file
View File

@ -0,0 +1,8 @@
<em:localized>
<Description>
<em:locale>da-DK</em:locale>
<em:name>PDF Viewer</em:name>
<em:description>Benytter HTML5 til at vise PDF-filer direkte i Firefox.</em:description>
</Description>
</em:localized>

View File

@ -0,0 +1,31 @@
bookmark.title=Aktuel visning (kopier eller åbn i et nyt vindue)
previous.title=Forrige
next.title=Næste
print.title=Udskriv
download.title=Hent
zoom_out.title=Zoom ud
zoom_in.title=Zoom ind
error_more_info=Mere information
error_less_info=Mindre information
error_close=Luk
error_build=PDF.JS Build: {{build}}
error_message=Besked: {{message}}
error_stack=Stak: {{stack}}
error_file=Fil: {{file}}
error_line=Linje: {{line}}
page_scale_width=Sidebredde
page_scale_fit=Helside
page_scale_auto=Automatisk zoom
page_scale_actual=Faktisk størrelse
toggle_slider.title=Skift Slider
thumbs.title=Vis thumbnails
outline.title=Vis dokumentoversigt
loading=Indlæser... {{percent}}%
loading_error_indicator=Fejl
loading_error=Der skete en fejl under indlæsningen af PDF-filen
rendering_error=Der skete en fejl under gengivelsen af PDF-filen
page_label=Side:
page_of=af {{pageCount}}
no_outline=Ingen dokumentoversigt tilgængelig
open_file.title=Åbn fil
text_annotation_type=[{{type}} Kommentar]

8
l10n/de-DE/metadata.inc Normal file
View File

@ -0,0 +1,8 @@
<em:localized>
<Description>
<em:locale>de-DE</em:locale>
<em:name>PDF Viewer</em:name>
<em:description>Nutzt HTML5 um PDFs direkt in Firefox anzuzeigen.</em:description>
</Description>
</em:localized>

View File

@ -0,0 +1,31 @@
bookmark.title=Aktuelle Ansicht (Kopieren oder in einem neuen Fenster öffnen)
previous.title=Zurück
next.title=Vor
print.title=Drucken
download.title=Runterladen
zoom_out.title=Verkleinern
zoom_in.title=Vergrößern
error_more_info=Mehr Info
error_less_info=Weniger Info
error_close=Schließen
error_build=PDF.JS Build: {{build}}
error_message=Nachricht: {{message}}
error_stack=Stack: {{stack}}
error_file=Datei: {{file}}
error_line=Zeile: {{line}}
page_scale_width=Seitenbreite
page_scale_fit=Ganze Seite
page_scale_auto=Automatisch
page_scale_actual=Originalgröße
toggle_slider.title=Thumbnails ein-/ausblenden
thumbs.title=Zeige Thumbnails
outline.title=Zeige Inhaltsverzeichnis
loading=Lade... {{percent}}%
loading_error_indicator=Fehler
loading_error=Das PDF konnte nicht geladen werden.
rendering_error=Das PDF konnte nicht angezeigt werden.
page_label=Seite:
page_of=von {{pageCount}}
no_outline=Kein Inhaltsverzeichnis verfügbar
open_file.title=Öffne Datei
text_annotation_type=[{{type}} Annotation]

8
l10n/en-US/metadata.inc Normal file
View File

@ -0,0 +1,8 @@
<em:localized>
<Description>
<em:locale>en-US</em:locale>
<em:name>PDF Viewer</em:name>
<em:description>Uses HTML5 to display PDF files directly in Firefox.</em:description>
</Description>
</em:localized>

View File

@ -0,0 +1,42 @@
bookmark.title=Current view (copy or open in new window)
previous.title=Previous Page
next.title=Next Page
print.title=Print
download.title=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=Automatic Zoom
page_scale_actual=Actual Size
toggle_slider.title=Toggle Slider
thumbs.title=Show Thumbnails
outline.title=Show 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.
page_label=Page:
page_of=of {{pageCount}}
no_outline=No Outline Available
open_file.title=Open File
text_annotation_type=[{{type}} Annotation]
toggle_slider_label=Toggle Slider
thumbs_label=Thumbnails
outline_label=Document Outline
bookmark_label=Current View
previous_label=Previous
next_label=Next
print_label=Print
download_label=Download
zoom_out_label=Zoom Out
zoom_in_label=Zoom In
zoom.title=Zoom

8
l10n/it/metadata.inc Normal file
View File

@ -0,0 +1,8 @@
<em:localized>
<Description>
<em:locale>it</em:locale>
<em:name>PDF Viewer</em:name>
<em:description>Usa HTML5 per visualizzare i file PDF direttamente in Firefox.</em:description>
</Description>
</em:localized>

31
l10n/it/viewer.properties Normal file
View File

@ -0,0 +1,31 @@
bookmark.title=Visualizzazione corrente (copia o apri in una nuova finestra)
previous.title=Precedente
next.title=Successiva
print.title=Stampa
download.title=Download
zoom_out.title=Riduci Zoom
zoom_in.title=Aumenta Zoom
error_more_info=Più Informazioni
error_less_info=Meno Informazioni
error_close=Chiudi
error_build=PDF.JS Build: {{build}}
error_message=Messaggio: {{message}}
error_stack=Stack: {{stack}}
error_file=File: {{file}}
error_line=Linea: {{line}}
page_scale_width=Adatta alla Larghezza
page_scale_fit=Adatta alla Pagina
page_scale_auto=Zoom Automatico
page_scale_actual=Dimensione Attuale
toggle_slider.title=Visualizza Riquadro Laterale
thumbs.title=Mostra Miniature
outline.title=Mostra Indice Documento
loading=Caricamento... {{percent}}%
loading_error_indicator=Errore
loading_error=È accaduto un errore durante il caricamento del PDF.
rendering_error=È accaduto un errore durante il rendering della pagina.
page_label=Pagina:
page_of=di {{pageCount}}
no_outline=Nessun Indice Disponibile
open_file.title=Apri File
text_annotation_type=[{{type}} Annotazione]

8
l10n/pt-BR/metadata.inc Normal file
View File

@ -0,0 +1,8 @@
<em:localized>
<Description>
<em:locale>pt-BR</em:locale>
<em:name>PDF Viewer</em:name>
<em:description>Aprensenta PDFs no browser usando a tecnologia HTML5.</em:description>
</Description>
</em:localized>

View File

@ -0,0 +1,31 @@
bookmark.title=Marcar posição atual (bookmark)
previous.title=Página anterior
next.title=Próxima página
print.title=Imprimir
download.title=Baixar arquivo
zoom_out.title=Diminuir Zoom
zoom_in.title=Aumentar Zoom
error_more_info=Mais informações
error_less_info=Menos informações
error_close=Fechar
error_build=PDF.JS Versão: {{build}}
error_message=Mensagem: {{message}}
error_stack=Pilha: {{stack}}
error_file=Arquivo: {{file}}
error_line=Linha: {{line}}
page_scale_width=Largura da página
page_scale_fit=Página inteira
page_scale_auto=Zoom automático
page_scale_actual=Tamanho original
toggle_slider.title=Abrir/fechar aba lateral
thumbs.title=Mostrar miniaturas
outline.title=Mostrar índice
loading=Carregando... {{percent}}%
loading_error_indicator=Erro
loading_error=Um erro ocorreu ao carregar o arquivo.
rendering_error=Um erro ocorreu ao apresentar a página.
page_label=Página:
page_of=de {{pageCount}}
no_outline=Índice não disponível
open_file.title=Abrir arquivo
text_annotation_type=[{{type}} Anotações]

8
l10n/ru/metadata.inc Normal file
View File

@ -0,0 +1,8 @@
<em:localized>
<Description>
<em:locale>ru</em:locale>
<em:name>PDF Viewer</em:name>
<em:description>Показывает файлы PDF непосредственно в Firefox используя HTML5.</em:description>
</Description>
</em:localized>

42
l10n/ru/viewer.properties Normal file
View File

@ -0,0 +1,42 @@
bookmark.title=Ссылка на текущий вид (скопировать или открыть в новом окне)
previous.title=Предыдущая страница
next.title=Следующая страница
print.title=Печать
download.title=Загрузить
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=Авто
page_scale_actual=Настоящий размер
toggle_slider.title=Открыть/закрыть вспомогательную панель
thumbs.title=Показать уменьшенные изображения
outline.title=Показать содержание документа
loading=Загрузка... {{percent}}%
loading_error_indicator=Ошибка
loading_error=Произошла ошибка во время загрузки PDF.
rendering_error=Произошла ошибка во время создания страницы.
page_label=Страница:
page_of=из {{pageCount}}
no_outline=Содержание не доступно
open_file.title=Открыть файл
text_annotation_type=[Аннотация {{type}}]
toggle_slider_label=Вспомогательная панель
thumbs_label=Уменьшенные изображения
outline_label=Содержание документа
bookmark_label=Текущий вид
previous_label=Предыдущая
next_label=Следующая
print_label=Печать
download_label=Загрузить
zoom_out_label=Уменьшить
zoom_in_label=Увеличить
zoom.title=Масштаб

42
l10n/xx/viewer.properties Normal file
View File

@ -0,0 +1,42 @@
bookmark.title=<<<_¢ȗггεпţ ṿiεẂ (¢OÞӳ Oг OÞεп iп пεẂ ẂiпÐOẂ)_>>>
previous.title=<<<_ÞгεṿiOȗ§ Þãģε_>>>
next.title=<<<_пεӾţ Þãģε_>>>
print.title=<<<_Þгiпţ_>>>
download.title=<<<_Ð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ḻÐ: {{build}}_>>>
error_message=<<<_м姧ãģε: {{message}}_>>>
error_stack=<<<_§ţã¢қ: {{stack}}_>>>
error_file=<<<_£iḻε: {{file}}_>>>
error_line=<<<_ḻiпε: {{line}}_>>>
page_scale_width=<<<_Þãģε ẂiÐţН_>>>
page_scale_fit=<<<_Þãģε £iţ_>>>
page_scale_auto=<<<_ãȗţOмãţi¢ ƩOOм_>>>
page_scale_actual=<<<_ã¢ţȗãḻ §iƩε_>>>
toggle_slider.title=<<<_ţOģģḻε §ḻiÐεг_>>>
thumbs.title=<<<_§НOẂ ţНȗмьпãiḻ§_>>>
outline.title=<<<_§НOẂ ÐO¢ȗмεпţ Oȗţḻiпε_>>>
loading=<<<_ḻOãÐiпģ... {{percent}}%_>>>
loading_error_indicator=<<<_εггOг_>>>
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ḻãьḻε_>>>
open_file.title=<<<_OÞεп £iḻε_>>>
text_annotation_type=<<<_[{{type}} ãппOţãţiOп]_>>>
toggle_slider_label=<<<_ţOģģḻε §ḻiÐεг_>>>
thumbs_label=<<<_ţНȗмьпãiḻ§_>>>
outline_label=<<<_ÐO¢ȗмεпţ Oȗţḻiпε_>>>
bookmark_label=<<<_¢ȗггεпţ ṿiεẂ_>>>
previous_label=<<<_ÞгεṿiOȗ§_>>>
next_label=<<<_пεӾţ_>>>
print_label=<<<_Þгiпţ_>>>
download_label=<<<_ÐOẂпḻOãÐ_>>>
zoom_out_label=<<<_ƩOOм Oȗţ_>>>
zoom_in_label=<<<_ƩOOм iп_>>>
zoom.title=<<<_ƩOOм_>>>

66
make.js
View File

@ -33,6 +33,7 @@ target.all = function() {
//
target.web = function() {
target.production();
target.locale();
target.extension();
target.pagesrepo();
@ -40,8 +41,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');
@ -56,6 +62,52 @@ target.web = function() {
" and issue 'git commit' to push changes.");
};
//
// make locale
// Creates localized resources for the viewer and extension.
//
target.locale = function() {
var L10N_PATH = 'l10n';
var METADATA_OUTPUT = 'extensions/firefox/metadata.inc';
var VIEWER_OUTPUT = 'web/locale.properties';
var DEFAULT_LOCALE = 'en-US';
cd(ROOT_DIR);
echo();
echo('### Building localization files');
var subfolders = ls(L10N_PATH);
subfolders.sort();
var metadataContent = '';
var viewerOutput = '';
for (var i = 0; i < subfolders.length; i++) {
var locale = subfolders[i];
var path = L10N_PATH + '/' + locale;
if (!test('-d', path))
continue;
if (!/^[a-z][a-z](-[A-Z][A-Z])?$/.test(locale)) {
echo('Skipping invalid locale: ' + locale);
continue;
}
if (test('-f', path + '/viewer.properties')) {
var properties = cat(path + '/viewer.properties');
if (locale == DEFAULT_LOCALE)
viewerOutput = '[*]\n' + properties + '\n' + viewerOutput;
else
viewerOutput = viewerOutput + '[' + locale + ']\n' + properties + '\n';
}
if (test('-f', path + '/metadata.inc')) {
var metadata = cat(path + '/metadata.inc');
metadataContent += metadata;
}
}
viewerOutput.to(VIEWER_OUTPUT);
metadataContent.to(METADATA_OUTPUT);
};
//
// make production
// Creates production output (pdf.js, and corresponding changes to web/ files)
@ -175,6 +227,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.',
@ -245,6 +299,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);
@ -271,6 +327,7 @@ 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_LOCALE_DATA.*\n/, 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');
@ -278,6 +335,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(/^\./))
@ -290,6 +349,11 @@ target.firefox = function() {
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/install.rdf.in');
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/README.mozilla');
// Update localized metadata
var localizedMetadata = cat(EXTENSION_SRC_DIR + '/firefox/metadata.inc');
sed('-i', /.*PDFJS_LOCALIZED_METADATA.*\n/, localizedMetadata, FIREFOX_BUILD_DIR + '/install.rdf');
sed('-i', /.*PDFJS_LOCALIZED_METADATA.*\n/, localizedMetadata, FIREFOX_BUILD_DIR + '/install.rdf.in');
// Create the xpi
cd(FIREFOX_BUILD_DIR);
exec('zip -r ' + FIREFOX_EXTENSION_NAME + ' ' + FIREFOX_EXTENSION_FILES.join(' '));

View File

@ -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:

1
web/.gitignore vendored
View File

@ -1 +1,2 @@
viewer-production.html
locale.properties

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

View File

@ -1,5 +1,9 @@
<!-- This snippet is used in firefox extension, see Makefile -->
<base href="resource://pdf.js/web/" />
<script type="application/l10n">
<!-- PDFJSSCRIPT_LOCALE_DATA -->
</script>
<script type="text/javascript" src="l10n.js"></script>
<script type="text/javascript" id="PDFJS_SCRIPT_TAG">
<!--
// pdf.js is inlined here because resource:// urls won't work

View File

@ -1,4 +1,6 @@
<!-- This snippet is used in production, see Makefile -->
<link rel="resource" type="application/l10n" href="locale.properties"/>
<script type="text/javascript" src="l10n.js"></script>
<script type="text/javascript" src="../build/pdf.js"></script>
<script type="text/javascript">
// This specifies the location of the pdf.js file.

View File

@ -22,16 +22,26 @@ body {
}
/* outer/inner center provides horizontal center */
.outerCenter {
html[dir='ltr'] .outerCenter {
float: right;
position: relative;
right: 50%;
}
.innerCenter {
html[dir='rtl'] .outerCenter {
float: left;
position: relative;
left: 50%;
}
html[dir='ltr'] .innerCenter {
float: right;
position: relative;
right: -50%;
}
html[dir='rtl'] .innerCenter {
float: left;
position: relative;
left: -50%;
}
#outerContainer {
width: 100%;
@ -42,23 +52,34 @@ body {
position: absolute;
top: 0;
bottom: 0;
left: -200px;
width: 200px;
visibility: hidden;
-moz-transition-property: left;
-moz-transition-duration: 200ms;
-moz-transition-timing-function: ease;
-webkit-transition-property: left;
-webkit-transition-duration: 200ms;
-webkit-transition-timing-function: ease;
}
#outerContainer.sidebarMoving > #sidebarContainer {
visibility: visible;
html[dir='ltr'] #sidebarContainer {
-moz-transition-property: left;
-webkit-transition-property: left;
left: -200px;
}
html[dir='rtl'] #sidebarContainer {
-moz-transition-property: right;
-webkit-transition-property: right;
right: -200px;
}
#outerContainer.sidebarMoving > #sidebarContainer,
#outerContainer.sidebarOpen > #sidebarContainer {
visibility: visible;
}
html[dir='ltr'] #outerContainer.sidebarOpen > #sidebarContainer {
left: 0px;
}
html[dir='rtl'] #outerContainer.sidebarOpen > #sidebarContainer {
right: 0px;
}
#mainContainer {
position: absolute;
@ -66,20 +87,24 @@ body {
right: 0;
bottom: 0;
left: 0;
-moz-transition-property: left;
-moz-transition-duration: 200ms;
-moz-transition-timing-function: ease;
-webkit-transition-property: left;
-webkit-transition-duration: 200ms;
-webkit-transition-timing-function: ease;
}
#outerContainer.sidebarOpen > #mainContainer {
html[dir='ltr'] #outerContainer.sidebarOpen > #mainContainer {
-moz-transition-property: left;
-webkit-transition-property: left;
left: 200px;
}
html[dir='rtl'] #outerContainer.sidebarOpen > #mainContainer {
-moz-transition-property: right;
-webkit-transition-property: right;
right: 200px;
}
#sidebarContent {
top: 32px;
left: 0;
bottom: 0;
overflow: auto;
position: absolute;
@ -88,6 +113,12 @@ body {
background-color: hsla(0,0%,0%,.1);
box-shadow: inset -1px 0 0 hsla(0,0%,0%,.25);
}
html[dir='ltr'] #sidebarContent {
left: 0;
}
html[dir='rtl'] #sidebarContent {
right: 0;
}
#viewerContainer {
overflow: auto;
@ -129,7 +160,6 @@ body {
#toolbarViewer {
position: relative;
margin-left: -1px;
height: 32px;
background-image: url(images/texture.png),
-moz-linear-gradient(hsla(0,0%,32%,.99), hsla(0,0%,27%,.95));
@ -142,31 +172,53 @@ body {
0 1px 0 hsla(0,0%,0%,.15),
0 1px 1px hsla(0,0%,0%,.1);
}
html[dir='ltr'] #toolbarViewerLeft {
margin-left: -1px;
}
html[dir='rtl'] #toolbarViewerRight {
margin-left: -1px;
}
#toolbarViewerLeft {
html[dir='ltr'] #toolbarViewerLeft,
html[dir='rtl'] #toolbarViewerRight {
position: absolute;
top: 0;
left: 0;
}
#toolbarViewerRight {
html[dir='ltr'] #toolbarViewerRight,
html[dir='rtl'] #toolbarViewerLeft {
position: absolute;
top: 0;
right: 0;
}
#toolbarViewerLeft > *,
#toolbarViewerMiddle > *,
#toolbarViewerRight > * {
html[dir='ltr'] #toolbarViewerLeft > *,
html[dir='ltr'] #toolbarViewerMiddle > *,
html[dir='ltr'] #toolbarViewerRight > * {
float: left;
}
html[dir='rtl'] #toolbarViewerLeft > *,
html[dir='rtl'] #toolbarViewerMiddle > *,
html[dir='rtl'] #toolbarViewerRight > * {
float: right;
}
.splitToolbarButton {
html[dir='ltr'] .splitToolbarButton {
margin: 3px 2px 4px 0;
display: inline-block;
}
.splitToolbarButton > .toolbarButton {
html[dir='rtl'] .splitToolbarButton {
margin: 3px 0 4px 2px;
display: inline-block;
}
html[dir='ltr'] .splitToolbarButton > .toolbarButton {
border-radius: 0;
float: left;
}
html[dir='rtl'] .splitToolbarButton > .toolbarButton {
border-radius: 0;
float: right;
}
.toolbarButton {
border: 0 none;
@ -214,7 +266,8 @@ body {
0 0 1px hsla(0,0%,0%,.05);
z-index: 199;
}
.splitToolbarButton > .toolbarButton:first-child {
html[dir='ltr'] .splitToolbarButton > .toolbarButton:first-child,
html[dir='rtl'] .splitToolbarButton > .toolbarButton:last-child {
position: relative;
margin: 0;
margin-right: -1px;
@ -222,7 +275,8 @@ body {
border-bottom-left-radius: 2px;
border-right-color: transparent;
}
.splitToolbarButton > .toolbarButton:last-child {
html[dir='ltr'] .splitToolbarButton > .toolbarButton:last-child,
html[dir='rtl'] .splitToolbarButton > .toolbarButton:first-child {
position: relative;
margin: 0;
margin-left: -1px;
@ -238,8 +292,13 @@ body {
box-shadow: 0 0 0 1px hsla(0,0%,100%,.08);
display: inline-block;
margin: 5px 0;
}
html[dir='ltr'] .splitToolbarButtonSeparator {
float:left;
}
html[dir='rtl'] .splitToolbarButtonSeparator {
float:right;
}
.splitToolbarButton:hover > .splitToolbarButtonSeparator,
.splitToolbarButton.toggled > .splitToolbarButtonSeparator {
padding: 12px 0;
@ -257,7 +316,6 @@ body {
.dropdownToolbarButton {
min-width: 16px;
padding: 2px 6px 0;
margin: 3px 2px 4px 0;
border: 1px solid transparent;
border-radius: 2px;
color: hsl(0,0%,95%);
@ -274,6 +332,15 @@ body {
-webkit-transition-timing-function: ease;
}
html[dir='ltr'] .toolbarButton,
html[dir='ltr'] .dropdownToolbarButton {
margin: 3px 2px 4px 0;
}
html[dir='rtl'] .toolbarButton,
html[dir='rtl'] .dropdownToolbarButton {
margin: 3px 0 4px 2px;
}
.toolbarButton:hover,
.toolbarButton:focus,
.dropdownToolbarButton {
@ -336,7 +403,13 @@ body {
max-width: 120px;
padding: 3px 2px 2px;
overflow: hidden;
background: url(images/toolbarButton-menuArrows.png) no-repeat 95%;
background: url(images/toolbarButton-menuArrows.png) no-repeat;
}
html[dir='ltr'] .dropdownToolbarButton {
background-position: 95%;
}
html[dir='rtl'] .dropdownToolbarButton {
background-position: 5%;
}
.dropdownToolbarButton > select {
@ -359,12 +432,16 @@ body {
border-bottom: 1px rgba(255, 255, 255, .5) solid;
}
.splitToolbarButton:first-child,
.toolbarButton:first-child {
html[dir='ltr'] .splitToolbarButton:first-child,
html[dir='ltr'] .toolbarButton:first-child,
html[dir='rtl'] .splitToolbarButton:last-child,
html[dir='rtl'] .toolbarButton:last-child {
margin-left: 4px;
}
.splitToolbarButton:last-child,
.toolbarButton:last-child {
html[dir='ltr'] .splitToolbarButton:last-child,
html[dir='ltr'] .toolbarButton:last-child,
html[dir='rtl'] .splitToolbarButton:first-child,
html[dir='rtl'] .toolbarButton:first-child {
margin-right: 4px;
}
@ -385,16 +462,26 @@ body {
content: url(images/toolbarButton-sidebarToggle.png);
}
.toolbarButton.pageUp::before {
html[dir='ltr'] .toolbarButton.pageUp::before {
display: inline-block;
content: url(images/toolbarButton-pageUp.png);
}
html[dir='rtl'] .toolbarButton.pageUp::before {
display: inline-block;
content: url(images/toolbarButton-pageUp-rtl.png);
}
.toolbarButton.pageDown::before {
html[dir='ltr'] .toolbarButton.pageDown::before {
display: inline-block;
content: url(images/toolbarButton-pageDown.png);
}
html[dir='rtl'] .toolbarButton.pageDown::before {
display: inline-block;
content: url(images/toolbarButton-pageDown-rtl.png);
}
.toolbarButton.zoomOut::before {
display: inline-block;
content: url(images/toolbarButton-zoomOut.png);
@ -625,6 +712,7 @@ canvas {
}
.page {
direction: ltr;
width: 816px;
height: 1056px;
margin: 10px auto;

View File

@ -1,12 +1,15 @@
<!DOCTYPE html>
<html>
<html dir="ltr">
<head>
<meta charset="utf-8">
<title>PDF.js viewer</title>
<!-- PDFJSSCRIPT_INCLUDE_FIREFOX_EXTENSION -->
<link rel="stylesheet" href="viewer.css"/>
<link rel="resource" type="application/l10n" href="locale.properties"/><!-- PDFJSSCRIPT_REMOVE_CORE -->
<script type="text/javascript" src="compatibility.js"></script> <!-- PDFJSSCRIPT_REMOVE_FIREFOX_EXTENSION -->
<script type="text/javascript" src="../external/webL10n/l10n.js"></script><!-- PDFJSSCRIPT_REMOVE_CORE -->
<!-- PDFJSSCRIPT_INCLUDE_BUILD -->
<script type="text/javascript" src="../src/core.js"></script> <!-- PDFJSSCRIPT_REMOVE_CORE -->
@ -43,11 +46,11 @@
<div id="sidebarContainer">
<div id="toolbarSidebar">
<div class="splitToolbarButton toggled">
<button id="viewThumbnail" class="toolbarButton toggled" title="Show Thumbnails" onclick="PDFView.switchSidebarView('thumbs')" tabindex="1">
<span>Thumbnails</span>
<button id="viewThumbnail" class="toolbarButton toggled" title="Show Thumbnails" onclick="PDFView.switchSidebarView('thumbs')" tabindex="1" data-l10n-id="thumbs">
<span data-l10n-id="thumbs_label">Thumbnails</span>
</button>
<button id="viewOutline" class="toolbarButton" title="Show Document Outline" onclick="PDFView.switchSidebarView('outline')" tabindex="2">
<span>Document Outline</span>
<button id="viewOutline" class="toolbarButton" title="Show Document Outline" onclick="PDFView.switchSidebarView('outline')" tabindex="2" data-l10n-id="outline">
<span data-l10n-id="outline_label">Document Outline</span>
</button>
</div>
</div>
@ -65,20 +68,20 @@
<div id="toolbarViewer">
<div id="toolbarViewerLeft">
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="3">
<span>Toggle Sidebar</span>
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="3" data-l10n-id="toggle_slider">
<span data-l10n-id="toggle_slider_label">Toggle Sidebar</span>
</button>
<div class="toolbarButtonSpacer"></div>
<div class="splitToolbarButton">
<button class="toolbarButton pageUp" title="Previous Page" onclick="PDFView.page--" id="previous" tabindex="4">
<span>Previous</span>
<button class="toolbarButton pageUp" title="Previous Page" onclick="PDFView.page--" id="previous" tabindex="4" data-l10n-id="previous">
<span data-l10n-id="previous_label">Previous</span>
</button>
<div class="splitToolbarButtonSeparator"></div>
<button class="toolbarButton pageDown" title="Next Page" onclick="PDFView.page++" id="next" tabindex="5">
<span>Next</span>
<button class="toolbarButton pageDown" title="Next Page" onclick="PDFView.page++" id="next" tabindex="5" data-l10n-id="next">
<span data-l10n-id="next_label">Next</span>
</button>
</div>
<label class="toolbarLabel" for="pageNumber">Page: </label>
<label class="toolbarLabel" for="pageNumber" data-l10n-id="page_label">Page: </label>
<input type="number" id="pageNumber" class="toolbarField pageNumber" onchange="PDFView.page = this.value;" value="1" size="4" min="1" tabindex="6">
</input>
<span id="numPages" class="toolbarLabel"></span>
@ -88,40 +91,40 @@
<!--
<input id="fileInput" class="fileInput" type="file" oncontextmenu="return false;" style="visibility: hidden; position: fixed; right: 0; top: 0" />
<button id="openFile" class="toolbarButton print" title="Open" tabindex="10" onclick="document.getElementById('fileInput').click()">
<span>Open</span>
<button id="openFile" class="toolbarButton print" title="Open File" tabindex="10" data-l10n-id="open_file" onclick="document.getElementById('fileInput').click()">
<span data-l10n-id="open_file_label">Open</span>
</button>
-->
<!--
<button id="print" class="toolbarButton print" title="Print" tabindex="11" onclick="window.print()">
<span>Print</span>
<button id="print" class="toolbarButton print" title="Print" tabindex="11" data-l10n-id="print" onclick="window.print()">
<span data-l10n-id="print_label">Print</span>
</button>
-->
<button id="download" class="toolbarButton download" title="Download" onclick="PDFView.download();" tabindex="12">
<span>Download</span>
<button id="download" class="toolbarButton download" title="Download" onclick="PDFView.download();" tabindex="12" data-l10n-id="download">
<span data-l10n-id="download_label">Download</span>
</button>
<!-- <div class="toolbarButtonSpacer"></div> -->
<a href="#" id="viewBookmark" class="toolbarButton bookmark" title="Bookmark (or copy) current location" tabindex="13"><span>Bookmark</span></a>
<a href="#" id="viewBookmark" class="toolbarButton bookmark" title="Current view (copy or open in new window)" tabindex="13" data-l10n-id="bookmark"><span data-l10n-id="bookmark_label">Current View</span></a>
</div>
<div class="outerCenter">
<div class="innerCenter" id="toolbarViewerMiddle">
<div class="splitToolbarButton">
<button class="toolbarButton zoomOut" title="Zoom Out" onclick="PDFView.zoomOut();" tabindex="7">
<span>Zoom Out</span>
<button class="toolbarButton zoomOut" title="Zoom Out" onclick="PDFView.zoomOut();" tabindex="7" data-l10n-id="zoom_out">
<span data-l10n-id="zoom_out_label">Zoom Out</span>
</button>
<div class="splitToolbarButtonSeparator"></div>
<button class="toolbarButton zoomIn" title="Zoom In" onclick="PDFView.zoomIn();" tabindex="8">
<span>Zoom In</span>
<button class="toolbarButton zoomIn" title="Zoom In" onclick="PDFView.zoomIn();" tabindex="8" data-l10n-id="zoom_in">
<span data-l10n-id="zoom_in_label">Zoom In</span>
</button>
</div>
<span class="dropdownToolbarButton">
<select id="scaleSelect" onchange="PDFView.parseScale(this.value);" title="Zoom" oncontextmenu="return false;" tabindex="9">
<option id="pageAutoOption" value="auto" selected="selected">Automatic Zoom</option>
<option value="page-actual">Actual Size</option>
<option id="pageFitOption" value="page-fit">Fit Page</option>
<option id="pageWidthOption" value="page-width">Full Width</option>
<select id="scaleSelect" onchange="PDFView.parseScale(this.value);" title="Zoom" oncontextmenu="return false;" tabindex="9" data-l10n-id="zoom">
<option id="pageAutoOption" value="auto" selected="selected" data-l10n-id="page_scale_auto">Automatic Zoom</option>
<option id="pageActualOption" value="page-actual" data-l10n-id="page_scale_actual">Actual Size</option>
<option id="pageFitOption" value="page-fit" data-l10n-id="page_scale_fit">Fit Page</option>
<option id="pageWidthOption" value="page-width" data-l10n-id="page_scale_width">Full Width</option>
<option id="customScaleOption" value="custom"></option>
<option value="0.5">50%</option>
<option value="0.75">75%</option>
@ -142,22 +145,22 @@
</div>
<div id="loadingBox">
<div id="loading">Loading... 0%</div>
<div id="loading" data-l10n-id="loading" data-l10n-args='{"percent": 0}'>Loading... 0%</div>
<div id="loadingBar"><div class="progress"></div></div>
</div>
<div id="errorWrapper" hidden='true'>
<div id="errorMessageLeft">
<span id="errorMessage"></span>
<button id="errorShowMore" onclick="" oncontextmenu="return false;">
<button id="errorShowMore" onclick="" oncontextmenu="return false;" data-l10n-id="error_more_info">
More Information
</button>
<button id="errorShowLess" onclick="" oncontextmenu="return false;" hidden='true'>
<button id="errorShowLess" onclick="" oncontextmenu="return false;" data-l10n-id="error_less_info" hidden='true'>
Less Information
</button>
</div>
<div id="errorMessageRight">
<button id="errorClose" oncontextmenu="return false;">
<button id="errorClose" oncontextmenu="return false;" data-l10n-id="error_close">
Close
</button>
</div>

View File

@ -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('?');
@ -347,11 +349,13 @@ var PDFView = {
},
function getDocumentError(message, exception) {
var loadingIndicator = document.getElementById('loading');
loadingIndicator.textContent = 'Error';
loadingIndicator.textContent = mozL10n.get('loading_error_indicator',
null, 'Error');
var moreInfo = {
message: message
};
self.error('An error occurred while loading the PDF.', moreInfo);
self.error(mozL10n.get('loading_error', null,
'An error occurred while loading the PDF.'), moreInfo);
self.loading = false;
},
function getDocumentProgress(progressData) {
@ -458,17 +462,29 @@ 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},
'PDF.JS Build: {{build}}') + '\n';
if (moreInfo) {
errorMoreInfo.value += 'Message: ' + moreInfo.message;
errorMoreInfo.value +=
mozL10n.get('error_message', {message: moreInfo.message},
'Message: {{message}}');
if (moreInfo.stack) {
errorMoreInfo.value += '\n' + 'Stack: ' + moreInfo.stack;
errorMoreInfo.value += '\n' +
mozL10n.get('error_stack', {stack: moreInfo.stack},
'Stack: {{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},
'File: {{file}}');
}
if (moreInfo.lineNumber) {
errorMoreInfo.value += '\n' +
mozL10n.get('error_line', {line: moreInfo.lineNumber},
'Line: {{line}}');
}
}
}
errorMoreInfo.rows = errorMoreInfo.value.split('\n').length - 1;
@ -477,7 +493,8 @@ 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},
'Loading... {{percent}}%');
PDFView.loadingBar.percent = percent;
},
@ -513,7 +530,8 @@ var PDFView = {
var pagesCount = pdfDocument.numPages;
var id = pdfDocument.fingerprint;
var storedHash = null;
document.getElementById('numPages').textContent = 'of ' + pagesCount;
document.getElementById('numPages').textContent =
mozL10n.get('page_of', {pageCount: pagesCount}, 'of {{pageCount}}');
document.getElementById('pageNumber').max = pagesCount;
PDFView.documentFingerprint = id;
var store = PDFView.store = new Settings(id);
@ -827,7 +845,8 @@ var PageView = function pageView(container, pdfPage, id, scale,
var rect = viewport.convertToViewportRectangle(item.rect);
rect = PDFJS.Util.normalizeRect(rect);
image.src = kImageDirectory + 'annotation-' + type.toLowerCase() + '.svg';
image.alt = '[' + type + ' Annotation]';
image.alt = mozL10n.get('text_annotation_type', {type: type},
'[{{type}} Annotation]');
var content = document.createElement('div');
content.setAttribute('hidden', true);
var title = document.createElement('h1');
@ -1008,8 +1027,10 @@ var PageView = function pageView(container, pdfPage, id, scale,
delete self.loadingIconDiv;
}
if (error)
PDFView.error('An error occurred while rendering the page.', error);
if (error) {
PDFView.error(mozL10n.get('rendering_error', null,
'An error occurred while rendering the page.'), error);
}
self.stats = pdfPage.stats;
self.updateStats();
@ -1153,7 +1174,8 @@ 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', null,
'No Outline Available');
outlineView.appendChild(noOutline);
return;
}
@ -1337,6 +1359,12 @@ window.addEventListener('load', function webViewerLoad(evt) {
if ('disableWorker' in hashParams)
PDFJS.disableWorker = (hashParams['disableWorker'] === 'true');
var locale = !PDFJS.isFirefoxExtension ? navigator.language :
FirefoxCom.request('getLocale', null);
if ('locale' in hashParams)
locale = hashParams['locale'];
mozL10n.language.code = locale;
if ('disableTextLayer' in hashParams)
PDFJS.disableTextLayer = (hashParams['disableTextLayer'] === 'true');
@ -1531,6 +1559,10 @@ function selectScaleOption(value) {
return predefinedValueFound;
}
window.addEventListener('localized', function localized(evt) {
document.getElementsByTagName('html')[0].dir = mozL10n.language.direction;
}, true);
window.addEventListener('scalechange', function scalechange(evt) {
var customScaleOption = document.getElementById('customScaleOption');
customScaleOption.selected = false;