2 /*jshint node:true, indent:2, curly:false, eqeqeq:true, immed:true,
3 latedef:true, newcap:true, noarg:true,
4 regexp:true, undef:true, strict:true, trailing:true, white:true */
7 // This file really just parses the arguments, and sends the real work
8 // off to scripts/lib/build_dictionary.js.
13 var _ = require("underscore"),
14 async = require("async"),
16 path = require('path'),
17 program = require('commander'),
18 dictionaryToolkit = require("./lib/build_dictionary");
21 .option('-a, --apikey [api key]', 'Google Translate API key.')
22 .option('-d, --database [database name]', 'Database name to export from.')
23 .option('-l, --language [language]', 'Language name in form es_MX.')
24 .option('-t, --total', 'Export the totality of the language files en batch.')
29 dictionaryToolkit.exportEnglish(
31 database: program.database,
32 apiKey: program.apikey,
33 language: program.language
37 console.log("Export failed", err);
40 console.log("Success!");
47 // Do a total batch export
49 if (program.database || program.language) {
50 console.log("Don't enter a database name or a language. I'll take care of that.");
53 var buildAll = require('./lib/build_all');
54 program.database = "linguist";
57 // Step 1: Create a database with the appropriate extensions
59 var buildPostbooks = function (done) {
61 database: program.database,
63 source: path.join(__dirname, "../foundation-database/postbooks_demo_data.sql")
66 var buildExtensions = function (done) {
67 var extensions = ["inventory", "manufacturing", "distribution"/*, "bi"*/];
68 async.mapSeries(extensions, function (extension, next) {
70 database: program.database,
71 frozen: (extension !== "bi"),
72 extension: path.join(__dirname, "../../private-extensions/source", extension)
77 // Step 2: Load all the language files that we have
79 var importExistingDictionaries = function (done) {
80 fs.readdir(path.join(__dirname, "../../xtuple-linguist/translations"), function (err, files) {
81 async.mapSeries(files, function (file, next) {
82 var fullFilename = path.join(__dirname, "../../xtuple-linguist/translations", file);
83 dictionaryToolkit.importDictionary(program.database, fullFilename, next);
89 // Step 3: Export in every language
91 var supportedLanguages = [
92 {locale: "de_DE", label: "Deutch", english: "German"},
93 {locale: "es_MX", label: "Español", english: "Spanish"},
94 {locale: "fr_FR", label: "Français", english: "French"},
95 {locale: "te_IN", label: "తెలుగు", english: "Telugu"},
96 {locale: "zh_CN", label: "中国的", english: "Simplified Chinese"}
98 var exportAllDictionaries = function (done) {
99 async.mapSeries(supportedLanguages, function (language, next) {
100 dictionaryToolkit.exportEnglish(
102 database: program.database,
103 apiKey: program.apikey,
104 language: language.locale,
105 directory: path.join(__dirname, "../../xtuple-linguist/translations")
113 importExistingDictionaries,
114 exportAllDictionaries
115 ], function (err, results) {
117 console.log("Export failed: ", err);
120 console.log("Success! Don't forget to commit and push xtuple-linguist!");