[Pkg-javascript-commits] [pdf.js] 134/161: Implements importl10n command

David Prévot taffit at moszumanska.debian.org
Sat Apr 19 14:16:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit c6f009403d44fdc122e5d5d54101c8c572e975eb
Author: Tim van der Meij <timvandermeij at gmail.com>
Date:   Sat Mar 22 16:40:59 2014 +0100

    Implements importl10n command
---
 CONTRIBUTING.md                |  6 ++-
 external/importL10n/locales.js | 88 ++++++++++++++++++++++++++++++++++++++++++
 l10n/README.md                 |  5 +++
 make.js                        | 21 +++++++++-
 4 files changed, 117 insertions(+), 3 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d65112d..353caca 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,10 +1,12 @@
 # PDF.js issue reporting
 
-The issues are used to track both bugs filed by users and specific work items for developers. Try to file one issue per problem observed. Please specify valid title (e.g. "Glyph spacing is incorrect" instead of "PDF.js does not work") and provide more details about the issue: link to the PDF, location in the PDF, screenshot, browser version, operating system, PDF.js version and JavaScript console warning/error messages. The issues that do not have enough details provided will be closed a [...]
+The issues are used to track both bugs filed by users and specific work items for developers. Try to file one issue per problem observed. Please specify a valid title (e.g. "Glyph spacing is incorrect" instead of "PDF.js does not work") and provide more details about the issue: link to the PDF, location in the PDF, screenshot, browser version, operating system, PDF.js version and JavaScript console warning/error messages. Issues that do not have enough details provided will be closed as  [...]
 
 The issue tracking system is designed to record a single technical problem. A bug report is something where a developer/contributor can work on. The GitHub issue tracker is not a good place for general, not well thought out or unworkable ideas. Most likely a discussion-type issue will not be addressed for a long time or closed as invalid. The best place is our dev-pdf-js at lists.mozilla.org mailing list. You can subscribe to it using http://lists.mozilla.org or Google Groups. This way you  [...]
 
-If you are developing a custom solution, first check examples at https://github.com/mozilla/pdf.js#learning and search existing issues. If this does not help, please prepare short well-documented example that demonstrate the problem and make it accessible online on your website, jsbin, github, etc. before opening a new issue or contacting us on the IRC channel -- keep in mind that just code snippets won't help us troubleshoot the problem. The issues that do not provide enough details wil [...]
+If you are developing a custom solution, first check the examples at https://github.com/mozilla/pdf.js#learning and search existing issues. If this does not help, please prepare a short well-documented example that demonstrates the problem and make it accessible online on your website, JS Bin, GitHub, etc. before opening a new issue or contacting us on the IRC channel -- keep in mind that just code snippets won't help us troubleshoot the problem.
+
+Note that the translations for PDF.js in the `l10n` folder are synchronized with the Aurora branch of Mozilla Firefox. This means that we will only accept pull requests that add strings currently missing in the Aurora branch (because it will take at least six weeks before the most recent translations are in the Aurora branch), but keep in mind that the changes will be overwritten when we synchronize again.
 
 See also:
 - https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions
diff --git a/external/importL10n/locales.js b/external/importL10n/locales.js
new file mode 100644
index 0000000..aba35ea
--- /dev/null
+++ b/external/importL10n/locales.js
@@ -0,0 +1,88 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
+/* Copyright 2012 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.
+ */
+/* jshint node:true */
+
+'use strict';
+
+var fs = require('fs');
+var http = require('http');
+var path = require('path');
+
+// Defines all languages that have a translation at mozilla-aurora.
+// This is used in make.js for the importl10n command.
+var langCodes = [
+  'ach', 'af', 'ak', 'an', 'ar', 'as', 'ast', 'az', 'be', 'bg',
+  'bn-BD', 'bn-IN', 'br', 'bs', 'ca', 'cs', 'csb', 'cy', 'da',
+  'de', 'el', 'en-GB', 'en-ZA', 'eo', 'es-AR', 'es-CL', 'es-ES',
+  'es-MX', 'et', 'eu', 'fa', 'ff', 'fi', 'fr', 'fy-NL', 'ga-IE',
+  'gd', 'gl', 'gu-IN', 'he', 'hi-IN', 'hr', 'hu', 'hy-AM', 'id',
+  'is', 'it', 'ja', 'ka', 'kk', 'km', 'kn', 'ko', 'ku', 'lg',
+  'lij', 'lt', 'lv', 'mai', 'mk', 'ml', 'mn', 'mr', 'ms', 'my',
+  'nb-NO', 'nl', 'nn-NO', 'nso', 'oc', 'or', 'pa-IN', 'pl',
+  'pt-BR', 'pt-PT', 'rm', 'ro', 'ru', 'rw', 'sah', 'si', 'sk',
+  'sl', 'son', 'sq', 'sr', 'sv-SE', 'sw', 'ta', 'ta-LK', 'te',
+  'th', 'tl', 'tn', 'tr', 'uk', 'ur', 'vi', 'wo', 'xh', 'zh-CN',
+  'zh-TW', 'zu'
+];
+
+function downloadLanguageFiles(langCode, callback) {
+  console.log('Downloading ' + langCode + '...');
+
+  // Constants for constructing the URLs. Translations are taken from the
+  // Aurora channel as those are the most recent ones. The Nightly channel
+  // does not provide all translations.
+  var MOZCENTRAL_ROOT = 'http://mxr.mozilla.org/l10n-mozilla-aurora/source/';
+  var MOZCENTRAL_PDFJS_DIR = '/browser/pdfviewer/';
+  var MOZCENTRAL_RAW_FLAG = '?raw=1';
+
+  // Defines which files to download for each language.
+  var files = ['chrome.properties', 'viewer.properties'];
+  var downloadsLeft = files.length;
+
+  if (!fs.existsSync(langCode)) {
+    fs.mkdirSync(langCode);
+  }
+
+  // Download the necessary files for this language.
+  files.forEach(function(fileName) {
+    var outputPath = path.join(langCode, fileName);
+    var file = fs.createWriteStream(outputPath);
+    var url = MOZCENTRAL_ROOT + langCode + MOZCENTRAL_PDFJS_DIR +
+              fileName + MOZCENTRAL_RAW_FLAG;
+    var request = http.get(url, function(response) {
+      response.pipe(file);
+      response.on('end', function() {
+        downloadsLeft--;
+        if (downloadsLeft === 0) {
+          callback();
+        }
+      })
+    });
+  });
+}
+
+function downloadL10n() {
+  var i = 0;
+  (function next() {
+    if (i >= langCodes.length) {
+      return;
+    }
+    downloadLanguageFiles(langCodes[i++], next);
+  })();
+}
+
+exports.downloadL10n = downloadL10n;
diff --git a/l10n/README.md b/l10n/README.md
new file mode 100644
index 0000000..a2fea69
--- /dev/null
+++ b/l10n/README.md
@@ -0,0 +1,5 @@
+Most of the files in this folder (except for the `en-US` folder and the
+`metadata.inc` files) have been imported from the Firefox Aurora branch,
+which is located at https://mxr.mozilla.org/l10n-mozilla-aurora/source.
+Some of the files are licensed under the MPL license. You can obtain a 
+copy of the license at http://mozilla.org/MPL/2.0.
diff --git a/make.js b/make.js
index 418947e..c54d75d 100644
--- a/make.js
+++ b/make.js
@@ -202,7 +202,7 @@ target.locale = function() {
     if (!test('-d', path)) {
       continue;
     }
-    if (!/^[a-z][a-z](-[A-Z][A-Z])?$/.test(locale)) {
+    if (!/^[a-z][a-z]([a-z])?(-[A-Z][A-Z])?$/.test(locale)) {
       echo('Skipping invalid locale: ' + locale);
       continue;
     }
@@ -1308,3 +1308,22 @@ target.makefile = function() {
   makefileContent += '.PHONY: ' + targetsNames.join(' ') + '\n';
   makefileContent.to('Makefile');
 };
+
+//
+//make importl10n
+//
+target.importl10n = function() {
+  var locales = require('./external/importL10n/locales.js');
+  var LOCAL_L10N_DIR = 'l10n';
+
+  cd(ROOT_DIR);
+  echo();
+  echo('### Importing translations from mozilla-aurora');
+
+  if (!test('-d', LOCAL_L10N_DIR)) {
+    mkdir(LOCAL_L10N_DIR);
+  }
+  cd(LOCAL_L10N_DIR);
+
+  locales.downloadL10n();
+};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list