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
This commit is contained in:
Garrett Scott
2017-11-27 19:08:39 -07:00
committed by Sabe Jones
parent fac81bb9ee
commit d95836b881
14 changed files with 23 additions and 16 deletions

View File

@@ -1,8 +1,8 @@
import {
generateUser,
translate as t,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
import apiMessages from '../../../../../website/server/libs/apiMessages';
describe('GET /coupons/', () => {
let user;
@@ -19,7 +19,7 @@ describe('GET /coupons/', () => {
await expect(user.get('/coupons')).to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
message: t('noSudoAccess'),
message: apiMessages('noSudoAccess'),
});
});

View File

@@ -4,6 +4,7 @@ import {
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
import couponCode from 'coupon-code';
import apiMessages from '../../../../../website/server/libs/apiMessages';
describe('POST /coupons/generate/:event', () => {
let user;
@@ -25,7 +26,7 @@ describe('POST /coupons/generate/:event', () => {
await expect(user.post('/coupons/generate/aaa')).to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
message: t('noSudoAccess'),
message: apiMessages('noSudoAccess'),
});
});

View File

@@ -308,7 +308,7 @@ describe('DELETE /user', () => {
})).to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
message: t('incorrectDeletePhrase'),
message: t('incorrectDeletePhrase', {magicWord: 'DELETE'}),
});
});

View File

@@ -7,6 +7,7 @@ import {
import i18n from '../../../../../website/common/script/i18n';
import { ensureAdmin, ensureSudo } from '../../../../../website/server/middlewares/ensureAccessRight';
import { NotAuthorized } from '../../../../../website/server/libs/errors';
import apiMessages from '../../../../../website/server/libs/apiMessages';
describe('ensure access middlewares', () => {
let res, req, next;
@@ -42,7 +43,7 @@ describe('ensure access middlewares', () => {
ensureSudo(req, res, next);
expect(next).to.be.calledWith(new NotAuthorized(i18n.t('noSudoAccess')));
expect(next).to.be.calledWith(new NotAuthorized(apiMessages('noSudoAccess')));
});
it('passes when user is a sudo user', () => {

View File

@@ -18,7 +18,7 @@
.social-delete(v-if='!user.auth.local.email')
h4 {{ $t('deleteAccount') }}
.modal-body
p {{ $t('deleteSocialAccountText') }}
p {{ $t('deleteSocialAccountText', {magicWord: 'DELETE'}) }}
br
.row
.col-md-6

View File

@@ -17,7 +17,7 @@
span {{ $t('enterprisePlansDescription') }}
.row.row-margin
// TODO
a.btn.btn-primary.btn-lg.btn-block(:href="'mailto:vicky@habitica.com?subject=' + $t('enterprisePlansEmailSubject')") {{ $t('enterprisePlansButton') }}
a.btn.btn-primary.btn-lg.btn-block(:href="'mailto:vicky@habitica.com?subject=' + enterprisePlansEmailSubject") {{ $t('enterprisePlansButton') }}
br
@@ -36,11 +36,16 @@
<script>
import StaticHeader from './header.vue';
import * as Analytics from 'client/libs/analytics';
export default {
components: {
StaticHeader,
},
data () {
return {
enterprisePlansEmailSubject: 'Question regarding Enterprise Plans',
};
},
methods: {
goToNewGroupPage () {
if (!this.$store.state.isUserLoggedIn) {
@@ -63,7 +68,7 @@
eventLabel: 'Contact Us (Plans)',
});
window.location.href = `mailto:vicky@habitica.com?subject=${this.$t('enterprisePlansEmailSubject')}`;
window.location.href = `mailto:vicky@habitica.com?subject=${ this.enterprisePlansEmailSubject }`;
},
},
};

View File

@@ -253,7 +253,7 @@
"missingNewPassword": "Missing new password.",
"invalidEmailDomain": "You cannot register with emails with the following domains: <%= domains %>",
"wrongPassword": "Wrong password.",
"incorrectDeletePhrase": "Please type DELETE in all caps to delete your account.",
"incorrectDeletePhrase": "Please type <%= magicWord %> in all caps to delete your account.",
"notAnEmail": "Invalid email address.",
"emailTaken": "Email address is already used in an account.",
"newEmailRequired": "Missing new email address.",

View File

@@ -296,7 +296,6 @@
"funExtras": "Fun Extras",
"enterprisePlansButton": "Ask about Enterprise Plans",
"enterprisePlansDescription": "Looking for a larger install with custom needs? See if our enterprise plans are right for you.",
"enterprisePlansEmailSubject": "Question regarding Enterprise Plans",
"familyPlansButton": "Sign Up for Family Plan Mailing List",
"familyPlansDescription": "Want a cozier solution to manage your household? Family Plans are coming soon!",
"createAGroup": "Create a Group",

View File

@@ -95,7 +95,7 @@
"plusOneGem": "+1 Gem",
"typeNotSellable": "Type is not sellable. Must be one of the following <%= acceptedTypes %>",
"userItemsKeyNotFound": "Key not found for user.items <%= type %>",
"userItemsNotEnough": "Not enough items found for user.items <%= type %>",
"userItemsNotEnough": "You do not have enough <%= type %>",
"pathRequired": "Path string is required",
"unlocked": "Items have been unlocked",
"alreadyUnlocked": "Full set already unlocked.",

View File

@@ -65,7 +65,7 @@
"resetText1": "WARNING! This resets many parts of your account. This is highly discouraged, but some people find it useful in the beginning after playing with the site for a short time.",
"resetText2": "You will lose all your levels, gold, and experience points. All your tasks (except those from challenges) will be deleted permanently and you will lose all of their historical data. You will lose all your equipment but you will be able to buy it all back, including all limited edition equipment or subscriber Mystery items that you already own (you will need to be in the correct class to re-buy class-specific gear). You will keep your current class and your pets and mounts. You might prefer to use an Orb of Rebirth instead, which is a much safer option and which will preserve your tasks and equipment.",
"deleteLocalAccountText": "Are you sure? This will delete your account forever, and it can never be restored! You will need to register a new account to use Habitica again. Banked or spent Gems will not be refunded. If you're absolutely certain, type your password into the text box below.",
"deleteSocialAccountText": "Are you sure? This will delete your account forever, and it can never be restored! You will need to register a new account to use Habitica again. Banked or spent Gems will not be refunded. If you're absolutely certain, type \"DELETE\" into the text box below.",
"deleteSocialAccountText": "Are you sure? This will delete your account forever, and it can never be restored! You will need to register a new account to use Habitica again. Banked or spent Gems will not be refunded. If you're absolutely certain, type \"<%= magicWord %>\" into the text box below.",
"API": "API",
"APIv3": "API v3",
"APIText": "Copy these for use in third party applications. However, think of your API Token like a password, and do not share it publicly. You may occasionally be asked for your User ID, but never post your API Token where others can see it, including on Github.",

View File

@@ -170,7 +170,6 @@
"cardTypeNotAllowed": "Unknown card type.",
"invalidCoupon": "Invalid coupon code.",
"couponUsed": "Coupon code already used.",
"noSudoAccess": "You don't have sudo access.",
"couponCodeRequired": "The coupon code is required.",
"eventRequired": "\"req.params.event\" is required.",
"countRequired": "\"req.query.count\" is required.",

View File

@@ -395,7 +395,7 @@ api.deleteUser = {
let isValidPassword = await passwordUtils.compare(user, password);
if (!isValidPassword) throw new NotAuthorized(res.t('wrongPassword'));
} else if ((user.auth.facebook.id || user.auth.google.id) && password !== DELETE_CONFIRMATION) {
throw new NotAuthorized(res.t('incorrectDeletePhrase'));
throw new NotAuthorized(res.t('incorrectDeletePhrase', {magicWord: 'DELETE'}));
}
let feedback = req.body.feedback;

View File

@@ -10,6 +10,7 @@ const messages = {
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 = {}) {

View File

@@ -1,6 +1,7 @@
import {
NotAuthorized,
} from '../libs/errors';
import apiMessages from '../libs/apiMessages';
export function ensureAdmin (req, res, next) {
let user = res.locals.user;
@@ -16,7 +17,7 @@ export function ensureSudo (req, res, next) {
let user = res.locals.user;
if (!user.contributor.sudo) {
return next(new NotAuthorized(res.t('noSudoAccess')));
return next(new NotAuthorized(apiMessages('noSudoAccess')));
}
next();