mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-03 17:19:42 +00:00
fix(i18n): fix /content api call
This commit is contained in:
parent
eedb1d147c
commit
01c9307cd1
2 changed files with 13 additions and 1 deletions
|
|
@ -17,7 +17,16 @@ var api = module.exports;
|
|||
// api.purchase // Shared.ops
|
||||
|
||||
api.getContent = function(req, res, next) {
|
||||
res.json(shared.content);
|
||||
var language = req.query.language; //|| 'en' in i18n
|
||||
var content = _.cloneDeep(shared.content);
|
||||
var walk = function(obj){
|
||||
_.each(obj, function(item, key, source){
|
||||
if(_.isPlainObject(item) || _.isArray(item)) return walk(item);
|
||||
if(_.isFunction(item) && item.i18nLangFunc) source[key] = item(language);
|
||||
});
|
||||
}
|
||||
walk(content);
|
||||
res.json(content);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ module.exports = (swagger, v2) ->
|
|||
'/content':
|
||||
spec:
|
||||
description: "Get all available content objects. This is essential, since Habit often depends on item keys (eg, when purchasing a weapon)."
|
||||
parameters: [
|
||||
query("language","Optional language to use for content's strings. Default is english.","string")
|
||||
]
|
||||
action: user.getContent
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue