Add coffeescript back in

This commit is contained in:
Blade Barringer
2015-10-03 06:39:10 -05:00
parent 655d8de7c8
commit 928e8478f7
6 changed files with 2443 additions and 4 deletions

View File

@@ -0,0 +1,27 @@
'use strict';
require('coffee-script');
var t = require('./translation.js');
var NUMBER_OF_QUESTIONS = 12;
var faq = {};
faq.questions = [];
for (var i = 0; i < NUMBER_OF_QUESTIONS; i++) {
var question = {
question: t('faqQuestion' + i),
ios: t('iosFaqAnswer' + i),
web: t('webFaqAnswer' + i)
};
faq.questions.push(question);
}
faq.stillNeedHelp = {
ios: t('iosFaqStillNeedHelp'),
web: t('webFaqStillNeedHelp')
};
module.exports = faq;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
'use strict';
require('coffee-script');
var i18n = require('../i18n.coffee');
var t = function(string, vars) {
var func = function(lang) {
if (vars == null) {
vars = {
a: 'a'
};
}
return i18n.t(string, vars, lang);
};
func.i18nLangFunc = true; // Trick to recognize this type of function
return func;
};
module.exports = t;

View File

@@ -1,7 +1,8 @@
'use strict';
require('coffee-script');
var _ = require('lodash');
var content = require('../dist/scripts/content/index');
var content = require('./content/index.coffee');
var DROP_ANIMALS = _.keys(content.pets);

44
common/script/i18n.coffee Normal file
View File

@@ -0,0 +1,44 @@
_ = require 'lodash'
module.exports =
strings: null, # Strings for one single language
translations: {} # Strings for multiple languages {en: strings, de: strings, ...}
t: (stringName) -> # Other parameters allowed are vars (Object) and locale (String)
vars = arguments[1]
if _.isString(arguments[1])
vars = null
locale = arguments[1]
else if arguments[2]?
vars = arguments[1]
locale = arguments[2]
locale = 'en' if (!locale? or (!module.exports.strings and !module.exports.translations[locale]))
if module.exports.strings
string = module.exports.strings[stringName]
else
string =
module.exports.translations[locale] and
module.exports.translations[locale][stringName]
clonedVars = _.clone(vars) or {}
clonedVars.locale = locale
if string
try
_.template(string, (clonedVars))
catch e
'Error processing the string. Please see Help > Report a Bug.'
else
if module.exports.strings
stringNotFound = module.exports.strings.stringNotFound
else if module.exports.translations[locale]
stringNotFound =
module.exports.translations[locale] and
module.exports.translations[locale].stringNotFound
try
_.template(stringNotFound, {string: stringName})
catch e
'Error processing the string. Please see Help > Report a Bug.'

View File

@@ -1,8 +1,7 @@
moment = require('moment')
_ = require('lodash')
content = require('../dist/scripts/content/index')
i18n = require('../dist/scripts/i18n')
content = require('./content/index.coffee')
i18n = require('./i18n.coffee')
api = module.exports = {}
api.i18n = i18n