Initial localization

This commit is contained in:
Yury Delendik 2012-04-30 15:29:05 -05:00
parent ba9c828117
commit 9b8b3bd25f
7 changed files with 145 additions and 34 deletions

View File

@ -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.',

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:

89
web/locale.properties Normal file
View File

@ -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пģ ţНε Þãģε._>>>

View File

@ -1,5 +1,6 @@
<!-- This snippet is used in firefox extension, see Makefile -->
<base href="resource://pdf.js/web/" />
<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,5 @@
<!-- This snippet is used in production, see Makefile -->
<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

@ -5,6 +5,7 @@
<!-- PDFJSSCRIPT_INCLUDE_FIREFOX_EXTENSION -->
<link rel="stylesheet" href="viewer.css"/>
<link rel="resource" type="application/l10n" href="locale.properties"/>
<script type="text/javascript" src="compatibility.js"></script> <!-- PDFJSSCRIPT_REMOVE_FIREFOX_EXTENSION -->
@ -33,22 +34,21 @@
<script type="text/javascript" src="../src/jpx.js"></script> <!-- PDFJSSCRIPT_REMOVE_CORE -->
<script type="text/javascript" src="../src/bidi.js"></script> <!-- PDFJSSCRIPT_REMOVE_CORE -->
<script type="text/javascript">PDFJS.workerSrc = '../src/worker_loader.js';</script> <!-- PDFJSSCRIPT_REMOVE_CORE -->
<script type="text/javascript" src="../external/webL10n/l10n.js"></script><!-- PDFJSSCRIPT_REMOVE_CORE -->
<script type="text/javascript" src="debugger.js"></script>
<script type="text/javascript" src="viewer.js"></script>
</head>
<body>
<div id="controls">
<button id="previous" onclick="PDFView.page--;" oncontextmenu="return false;">
<img src="images/go-up.svg" align="top" height="16"/>
Previous
<span data-l10n-id="previous_label">Previous</span>
</button>
<button id="next" onclick="PDFView.page++;" oncontextmenu="return false;">
<img src="images/go-down.svg" align="top" height="16"/>
Next
<span data-l10n-id="next_label">Next</span>
</button>
<div class="separator"></div>
@ -60,10 +60,10 @@
<div class="separator"></div>
<button id="zoomOut" title="Zoom Out" onclick="PDFView.zoomOut();" oncontextmenu="return false;">
<button id="zoomOut" title="Zoom Out" onclick="PDFView.zoomOut();" oncontextmenu="return false;" data-l10n-id="zoom_out">
<img src="images/zoom-out.svg" align="top" height="16"/>
</button>
<button id="zoomIn" title="Zoom In" onclick="PDFView.zoomIn();" oncontextmenu="return false;">
<button id="zoomIn" title="Zoom In" onclick="PDFView.zoomIn();" oncontextmenu="return false;" data-l10n-id="zoom_in">
<img src="images/zoom-in.svg" align="top" height="16"/>
</button>
@ -77,21 +77,21 @@
<option value="1.25">125%</option>
<option value="1.5">150%</option>
<option value="2">200%</option>
<option id="pageWidthOption" value="page-width">Page Width</option>
<option id="pageFitOption" value="page-fit">Page Fit</option>
<option id="pageAutoOption" value="auto" selected="selected">Auto</option>
<option id="pageWidthOption" value="page-width" data-l10n-id="page_scale_width">Page Width</option>
<option id="pageFitOption" value="page-fit" data-l10n-id="page_scale_fit">Page Fit</option>
<option id="pageAutoOption" value="auto" data-l10n-id="page_scale_auto" selected="selected">Auto</option>
</select>
<div class="separator"></div>
<button id="print" onclick="window.print();" oncontextmenu="return false;">
<img src="images/document-print.svg" align="top" height="16"/>
Print
<span data-l10n-id="print_label">Print</span>
</button>
<button id="download" title="Download" onclick="PDFView.download();" oncontextmenu="return false;">
<img src="images/download.svg" align="top" height="16"/>
Download
<span data-l10n-id="download_label">Download</span>
</button>
<div class="separator"></div>
@ -100,23 +100,23 @@
<div id="fileInputSeperator" class="separator"></div>
<a href="#" id="viewBookmark" title="Bookmark (or copy) current location">
<img src="images/bookmark.svg" alt="Bookmark" align="top" height="16"/>
<a href="#" id="viewBookmark" data-l10n-id="bookmark" title="Bookmark (or copy) current location">
<img src="images/bookmark.svg" data-l10n-id="bookmark_icon" alt="Bookmark" align="top" height="16"/>
</a>
</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>
@ -134,18 +134,18 @@
<div id="outlineView"></div>
</div>
<div id="sidebarControls">
<button id="thumbsSwitch" title="Show Thumbnails" onclick="PDFView.switchSidebarView('thumbs')" data-selected>
<img src="images/nav-thumbs.svg" align="top" height="16" alt="Thumbs" />
<button id="thumbsSwitch" title="Show Thumbnails" onclick="PDFView.switchSidebarView('thumbs')" data-l10n-id="thumbs" data-selected>
<img src="images/nav-thumbs.svg" align="top" height="16" alt="Thumbs" data-l10n-id="thumbs_icon"/>
</button>
<button id="outlineSwitch" title="Show Document Outline" onclick="PDFView.switchSidebarView('outline')" disabled>
<img src="images/nav-outline.svg" align="top" height="16" alt="Document Outline" />
<button id="outlineSwitch" title="Show Document Outline" onclick="PDFView.switchSidebarView('outline')" data-l10n-id="outline" disabled>
<img src="images/nav-outline.svg" align="top" height="16" alt="Document Outline" data-l10n-id="outline_icon"/>
</button>
</div>
</div>
</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="viewer"></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('?');
@ -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');