mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Add coffeescript back in
This commit is contained in:
27
common/script/content/faq.js
Normal file
27
common/script/content/faq.js
Normal 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;
|
||||
2347
common/script/content/index.coffee
Normal file
2347
common/script/content/index.coffee
Normal file
File diff suppressed because it is too large
Load Diff
21
common/script/content/translation.js
Normal file
21
common/script/content/translation.js
Normal 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;
|
||||
@@ -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
44
common/script/i18n.coffee
Normal 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.'
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user