Files
habitica/website/server/libs/apiMessages.js
Garrett Scott d95836b881 Translator minor changes fixes #8917 (#9297)
* Updated userItemsNotEnough string

* Added a variable to be passed to the deleteSocialAccountText string. This variable name is `magic_word` and is set as DELETE where used

* modified incorrectDeletePhrase to use a variable rather than translatable string for the word DELETE. Updated the DELETE-user test and the user api

* Changed noSudoAccess from translatable string to static

* Changed enterprisePlansEmailSubject from a translatable string to a static string within groupPlans.vue

* Fixed test problems with translation fixes

* Added no sudo access string to api messages

* changed plain string to apiMessage for no sudo access messages
2017-11-27 20:08:39 -06:00

25 lines
964 B
JavaScript

// A map of messages used by the API that don't need to be translated and
// so are not placed into /common/locales
import _ from 'lodash';
// When this file grows, it can be split into multiple ones.
const messages = {
guildsOnlyPaginate: 'Only public guilds support pagination.',
guildsPaginateBooleanString: 'req.query.paginate must be a boolean string.',
guildsPageInteger: 'req.query.page must be an integer greater than or equal to 0.',
groupIdRequired: 'req.params.groupId must contain a groupId.',
managerIdRequired: 'req.body.managerId must contain a user ID.',
noSudoAccess: 'You don\'t have sudo access',
};
export default function (msgKey, vars = {}) {
let message = messages[msgKey];
if (!message) throw new Error(`Error processing the API message "${msgKey}".`);
let clonedVars = vars ? _.clone(vars) : {};
// TODO cache the result of template() ? More memory usage, faster output
return _.template(message)(clonedVars);
}