From 9b8b3bd25f91152c7fb471cbf5b78e0f39df43cb Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 30 Apr 2012 15:29:05 -0500 Subject: [PATCH] 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');