mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added initial i18n implementation for Signup-form (#16914)
closes https://github.com/TryGhost/Team/issues/3307 This commit includes several important updates to add internationalisation (i18n) support within the signup form package: - Modified the translate script in `package.json` to include translations for the signup form. - Added a new test for the signup form resources in `i18n.test.js`. - Updated `tsconfig.json` to allow synthetic default imports. - Made updates to `package.json`, including adding a prebuild command for `@tryghost/i18n` to ensure typescript declaration files get built. - added `vite-plugin-commonjs` so we can bundle commonjs packages to be useable by the browser. - In `App.tsx`, imported the `i18n` library and created an `i18n` instance for the `signup-form` namespace. This `i18n` instance's `t` function was added to the application context. - Updated the `AppContextType` in `AppContext.ts` to include the `t` function from i18n Co-authored-by: Daniel Lockyer <hi@daniellockyer.com>
This commit is contained in:
parent
a8848bc7c6
commit
4fcaabe563
48 changed files with 284 additions and 16 deletions
6
ghost/i18n/locales/af/signup-form.json
Normal file
6
ghost/i18n/locales/af/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "Nou kyk na u e-pos!",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/bg/signup-form.json
Normal file
6
ghost/i18n/locales/bg/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/ca/signup-form.json
Normal file
6
ghost/i18n/locales/ca/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
|
@ -90,6 +90,7 @@
|
|||
"Plan checkout was cancelled.": "Notification for when a plan checkout was cancelled",
|
||||
"Plan upgrade was cancelled.": "Notification for when a plan upgrade was cancelled",
|
||||
"Please confirm your email address with this link:": "Descriptive text in signup emails, right before the button members click to confirm their address",
|
||||
"Please enter a valid email address": "",
|
||||
"Please fill in required fields": "Error message when a required field is missing",
|
||||
"Price": "A label to indicate price of a tier",
|
||||
"Re-enable emails": "A button for members to turn-back-on emails, if they have been previously disabled as a result of delivery failures",
|
||||
|
@ -108,6 +109,7 @@
|
|||
"Sign out": "A button to sign out",
|
||||
"Sign up": "A button to sign up",
|
||||
"Signup error: Invalid link": "Notification text when an invalid / expired signup link is used",
|
||||
"Something went wrong, please try again.": "",
|
||||
"Sorry, that didn’t work.": "Title of a page when an error occured while submitting feedback",
|
||||
"Spam complaints": "A title in the email suppression FAQ",
|
||||
"Start {{amount}}-day free trial": "A button for starting a free trial",
|
||||
|
@ -132,6 +134,7 @@
|
|||
"There was a problem submitting your feedback. Please try again a little later.": "An error message for when submitting feedback has failed",
|
||||
"This email address will not be used.": "This is in the footer of signup verification emails, and comes right after 'If you did not make this request, you can simply delete this message.'",
|
||||
"This site is invite-only, contact the owner for access.": "A message on the member login screen indicating that a site is not-open to public signups",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": "A confirmation message displayed during the signup process, indicating that the person signing up needs to go and check their email - and reminding them to check their spam folder, too",
|
||||
"Try free for {{amount}} days, then {{originalPrice}}.": "A label for an offer with a free trial",
|
||||
"Unlock access to all newsletters by becoming a paid subscriber.": "A message to encourage members to upgrade to a paid subscription",
|
||||
|
@ -176,4 +179,4 @@
|
|||
"{{memberEmail}} will no longer receive this newsletter.": "A message shown when a user unsubscribes from a newsletter",
|
||||
"{{memberEmail}} will no longer receive {{newsletterName}} newsletter.": "A message shown when a user unsubscribes from a newsletter",
|
||||
"{{trialDays}} days free": "A label for free trial days"
|
||||
}
|
||||
}
|
6
ghost/i18n/locales/cs/signup-form.json
Normal file
6
ghost/i18n/locales/cs/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/da/signup-form.json
Normal file
6
ghost/i18n/locales/da/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/de/signup-form.json
Normal file
6
ghost/i18n/locales/de/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/en/signup-form.json
Normal file
6
ghost/i18n/locales/en/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/eo/signup-form.json
Normal file
6
ghost/i18n/locales/eo/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/es/signup-form.json
Normal file
6
ghost/i18n/locales/es/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/fi/signup-form.json
Normal file
6
ghost/i18n/locales/fi/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
|
@ -39,11 +39,11 @@
|
|||
"Continue": "Continuer",
|
||||
"Continue subscription": "Continuer l'abonnement",
|
||||
"Could not sign in. Login link expired.": "Impossible de se connecter. Le lien de connexion a expiré.",
|
||||
"Could not update email! Invalid link.": "Impossible de mettre à jour l'e-mail ! Lien invalide.",
|
||||
"Could not update email! Invalid link.": "Impossible de mettre à jour l'e-mail\u00a0! Lien invalide.",
|
||||
"Create a new contact": "Créer un nouveau contact",
|
||||
"Current plan": "Plan actuel",
|
||||
"Delete account": "Fermer le compte",
|
||||
"Didn't mean to do this? Manage your preferences <button>here</button>.": "Vous ne vouliez pas faire ça ? Gérez vos préférences <button>ici</button>.",
|
||||
"Didn't mean to do this? Manage your preferences <button>here</button>.": "Vous ne vouliez pas faire ça\u00a0? Gérez vos préférences <button>ici</button>.",
|
||||
"Don't have an account?": "Vous n’avez pas encore de compte ?",
|
||||
"Edit": "Modifier",
|
||||
"Email": "E-mail",
|
||||
|
@ -99,7 +99,7 @@
|
|||
"Sign in": "Se connecter",
|
||||
"Sign out": "Se déconnecter",
|
||||
"Sign up": "S’enregistrer",
|
||||
"Signup error: Invalid link": "Erreur d'inscription : lien invalide",
|
||||
"Signup error: Invalid link": "Erreur d'inscription\u00a0: lien invalide",
|
||||
"Sorry, that didn’t work.": "Désolé, ça n'a pas fonctionné.",
|
||||
"Spam complaints": "Plaintes pour spam",
|
||||
"Start {{amount}}-day free trial": "Commencer l’essai gratuit de {{amount}} jours",
|
||||
|
|
6
ghost/i18n/locales/fr/signup-form.json
Normal file
6
ghost/i18n/locales/fr/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/hu/signup-form.json
Normal file
6
ghost/i18n/locales/hu/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/id/signup-form.json
Normal file
6
ghost/i18n/locales/id/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/it/signup-form.json
Normal file
6
ghost/i18n/locales/it/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/ko/signup-form.json
Normal file
6
ghost/i18n/locales/ko/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/mn/signup-form.json
Normal file
6
ghost/i18n/locales/mn/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/nl/signup-form.json
Normal file
6
ghost/i18n/locales/nl/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/no/signup-form.json
Normal file
6
ghost/i18n/locales/no/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/pl/signup-form.json
Normal file
6
ghost/i18n/locales/pl/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/pt-BR/signup-form.json
Normal file
6
ghost/i18n/locales/pt-BR/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/pt/signup-form.json
Normal file
6
ghost/i18n/locales/pt/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/ro/signup-form.json
Normal file
6
ghost/i18n/locales/ro/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/ru/signup-form.json
Normal file
6
ghost/i18n/locales/ru/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/si/signup-form.json
Normal file
6
ghost/i18n/locales/si/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/sl/signup-form.json
Normal file
6
ghost/i18n/locales/sl/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/sq/signup-form.json
Normal file
6
ghost/i18n/locales/sq/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/sr/signup-form.json
Normal file
6
ghost/i18n/locales/sr/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/sv/signup-form.json
Normal file
6
ghost/i18n/locales/sv/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/tr/signup-form.json
Normal file
6
ghost/i18n/locales/tr/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/uk/signup-form.json
Normal file
6
ghost/i18n/locales/uk/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/uz/signup-form.json
Normal file
6
ghost/i18n/locales/uz/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/vi/signup-form.json
Normal file
6
ghost/i18n/locales/vi/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/zh-Hant/signup-form.json
Normal file
6
ghost/i18n/locales/zh-Hant/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
6
ghost/i18n/locales/zh/signup-form.json
Normal file
6
ghost/i18n/locales/zh/signup-form.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Now check your email!": "",
|
||||
"Please enter a valid email address": "",
|
||||
"Something went wrong, please try again.": "",
|
||||
"To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!": ""
|
||||
}
|
|
@ -15,9 +15,10 @@
|
|||
"lint:code": "eslint *.js lib/ --ext .js --cache",
|
||||
"lint": "yarn lint:code && yarn lint:test",
|
||||
"lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache",
|
||||
"translate": "yarn translate:ghost && yarn translate:portal && node generate-context.js",
|
||||
"translate": "yarn translate:ghost && yarn translate:portal && yarn translate:signup-form && node generate-context.js",
|
||||
"translate:ghost": "NAMESPACE=ghost i18next '../core/core/{frontend,server,shared}/**/*.{js,jsx}'",
|
||||
"translate:portal": "NAMESPACE=portal i18next '../portal/src/**/*.{js,jsx}'"
|
||||
"translate:portal": "NAMESPACE=portal i18next '../portal/src/**/*.{js,jsx}'",
|
||||
"translate:signup-form": "NAMESPACE=signup-form i18next '../signup-form/src/**/*.{ts,tsx}'"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
|
|
|
@ -16,4 +16,18 @@ describe('i18n', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Can use Signup-form resources', function () {
|
||||
describe('Afrikaans', function () {
|
||||
let t;
|
||||
|
||||
before(function () {
|
||||
t = i18n('af', 'signup-form').t;
|
||||
});
|
||||
|
||||
it('can translate `Now check your email!`', function () {
|
||||
assert.equal(t('Now check your email!'), 'Nou kyk na u e-pos!');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
"emitDeclarationOnly": true,
|
||||
"outDir": "./build",
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
},
|
||||
"include": ["lib/**/*.js"],
|
||||
"exclude": ["node_modules", "test"]
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
"preview": "concurrently \"vite preview -l silent\" \"vite build --watch\"",
|
||||
"dev:test": "vite build && vite preview --port 6175",
|
||||
"build": "tsc && vite build",
|
||||
"prebuild": "yarn workspace @tryghost/i18n build",
|
||||
"lint": "yarn run lint:js",
|
||||
"lint:js": "eslint --ext .js,.ts,.cjs,.tsx --cache src test",
|
||||
"test:unit": "yarn build",
|
||||
|
@ -72,6 +73,7 @@
|
|||
"tailwindcss": "3.3.2",
|
||||
"typescript": "5.1.3",
|
||||
"vite": "4.3.9",
|
||||
"vite-plugin-commonjs": "0.7.1",
|
||||
"vite-plugin-svgr": "3.2.0",
|
||||
"vitest": "0.31.4"
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import * as i18nLib from '@tryghost/i18n';
|
||||
import React, {ComponentProps} from 'react';
|
||||
import pages, {Page, PageName} from './pages';
|
||||
import {AppContextProvider, AppContextType} from './AppContext';
|
||||
|
@ -29,17 +30,18 @@ const App: React.FC<AppProps> = ({scriptTag}) => {
|
|||
} as Page);
|
||||
};
|
||||
|
||||
const i18n = i18nLib.default('en', 'signup-form');
|
||||
const context: AppContextType = {
|
||||
page,
|
||||
api,
|
||||
options,
|
||||
setPage: _setPage,
|
||||
t: i18n.t,
|
||||
scriptTag
|
||||
};
|
||||
|
||||
const PageComponent = pages[page.name];
|
||||
const data = page.data as any; // issue with TypeScript understanding the type here when passing it to the component
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppContextProvider value={context}>
|
||||
|
|
|
@ -20,6 +20,7 @@ export type AppContextType = {
|
|||
setPage: <T extends PageName>(name: T, data: ComponentProps<typeof pages[T]>) => void,
|
||||
options: SignupFormOptions,
|
||||
api: GhostApi,
|
||||
t: any,
|
||||
scriptTag: HTMLElement
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import * as i18nLib from '@tryghost/i18n';
|
||||
import React, {ComponentProps, useState} from 'react';
|
||||
import pages, {Page, PageName} from './pages';
|
||||
import {AppContextProvider, SignupFormOptions} from './AppContext';
|
||||
|
@ -26,6 +27,8 @@ const Preview: React.FC<SignupFormOptions & {
|
|||
const PageComponent = pages[page.name];
|
||||
const data = page.data as any;
|
||||
|
||||
const i18n = i18nLib.default('en', 'signup-form');
|
||||
|
||||
return <AppContextProvider value={{
|
||||
page,
|
||||
setPage: _setPage,
|
||||
|
@ -39,6 +42,7 @@ const Preview: React.FC<SignupFormOptions & {
|
|||
return simulateApiError ? false : true;
|
||||
}
|
||||
},
|
||||
t: i18n.t,
|
||||
options,
|
||||
scriptTag: document.createElement('div')
|
||||
}}>
|
||||
|
|
|
@ -7,11 +7,11 @@ import {useAppContext} from '../../AppContext';
|
|||
export const FormPage: React.FC = () => {
|
||||
const [error, setError] = React.useState('');
|
||||
const [loading, setLoading] = React.useState(false);
|
||||
const {api, setPage, options} = useAppContext();
|
||||
const {api, setPage, options, t} = useAppContext();
|
||||
|
||||
const submit = async ({email}: { email: string }) => {
|
||||
if (!isValidEmail(email)) {
|
||||
setError('Please enter a valid email address');
|
||||
setError(t(`Please enter a valid email address`));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ export const FormPage: React.FC = () => {
|
|||
});
|
||||
} catch (_) {
|
||||
setLoading(false);
|
||||
setError('Something went wrong, please try again.');
|
||||
setError(t(`Something went wrong, please try again.`));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import React from 'react';
|
||||
import {useAppContext} from '../../AppContext';
|
||||
|
||||
export const SuccessView: React.FC<{
|
||||
email: string;
|
||||
|
@ -8,10 +9,11 @@ export const SuccessView: React.FC<{
|
|||
backgroundColor?: string;
|
||||
textColor?: string;
|
||||
}> = ({isMinimal, title, logo, backgroundColor, textColor}) => {
|
||||
const {t} = useAppContext();
|
||||
if (isMinimal) {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-xl font-bold">Now check your email!</h1>
|
||||
<h1 className="text-xl font-bold">{t(`Now check your email!`)}</h1>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -22,8 +24,8 @@ export const SuccessView: React.FC<{
|
|||
style={{backgroundColor, color: textColor}}
|
||||
>
|
||||
{logo && <img alt={title} className='mb-2 h-[64px] w-auto' src={logo}/>}
|
||||
<h1 className='text-center text-lg font-bold sm:text-xl md:text-2xl lg:text-3xl'>Now check your email!</h1>
|
||||
<p className='mb-4 text-center sm:mb-[4.1rem]'>To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!</p>
|
||||
<h1 className='text-center text-lg font-bold sm:text-xl md:text-2xl lg:text-3xl'>{t(`Now check your email!`)}</h1>
|
||||
<p className='mb-4 text-center sm:mb-[4.1rem]'>{t(`To complete signup, click the confirmation link in your inbox. If it doesn't arrive within 3 minutes, check your spam folder!`)}</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import commonjs from 'vite-plugin-commonjs';
|
||||
import pkg from './package.json';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import svgr from 'vite-plugin-svgr';
|
||||
import {SUPPORTED_LOCALES} from '@tryghost/i18n';
|
||||
import {defineConfig} from 'vitest/config';
|
||||
import {resolve} from 'path';
|
||||
|
||||
|
@ -11,7 +13,12 @@ export default (function viteConfig() {
|
|||
return defineConfig({
|
||||
plugins: [
|
||||
svgr(),
|
||||
react()
|
||||
react(),
|
||||
commonjs({
|
||||
dynamic: {
|
||||
loose: true
|
||||
}
|
||||
})
|
||||
],
|
||||
define: {
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||
|
@ -42,7 +49,9 @@ export default (function viteConfig() {
|
|||
output: {}
|
||||
},
|
||||
commonjsOptions: {
|
||||
include: [/packages/, /node_modules/]
|
||||
include: [/ghost/, /node_modules/],
|
||||
dynamicRequireRoot: '../',
|
||||
dynamicRequireTargets: SUPPORTED_LOCALES.map(locale => `../i18n/locales/${locale}/signup-form.json`)
|
||||
}
|
||||
},
|
||||
test: {
|
||||
|
|
23
yarn.lock
23
yarn.lock
|
@ -16090,6 +16090,11 @@ es-module-lexer@^0.9.0, es-module-lexer@^0.9.3:
|
|||
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19"
|
||||
integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==
|
||||
|
||||
es-module-lexer@^1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.2.1.tgz#ba303831f63e6a394983fde2f97ad77b22324527"
|
||||
integrity sha512-9978wrXM50Y4rTMmW5kXIC09ZdXQZqkE4mxhwkd8VbzsGkXGPgV4zWuqQJgCEzYngdo2dYDa0l8xhX4fkSwJSg==
|
||||
|
||||
es-set-tostringtag@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz#338d502f6f674301d710b80c8592de8a15f09cd8"
|
||||
|
@ -32680,11 +32685,29 @@ vite-node@0.31.4:
|
|||
picocolors "^1.0.0"
|
||||
vite "^3.0.0 || ^4.0.0"
|
||||
|
||||
vite-plugin-commonjs@0.7.1:
|
||||
version "0.7.1"
|
||||
resolved "https://registry.yarnpkg.com/vite-plugin-commonjs/-/vite-plugin-commonjs-0.7.1.tgz#7e0d20264d355b733e46ed4ed0e7931a113b47e9"
|
||||
integrity sha512-pRkI+pKW3NygFGTiLRejEntiJL0N+yC1wpnzne2bQ/bAqYwZWAzFU7XgU6EC8GE898ZAKfAZ6bhDP+uL+pM61Q==
|
||||
dependencies:
|
||||
acorn "^8.8.2"
|
||||
fast-glob "^3.2.12"
|
||||
vite-plugin-dynamic-import "^1.4.0"
|
||||
|
||||
vite-plugin-css-injected-by-js@3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/vite-plugin-css-injected-by-js/-/vite-plugin-css-injected-by-js-3.1.1.tgz#8324412636cf6fdada1a86f595aa2e78458e5ddb"
|
||||
integrity sha512-mwrFvEEy0TuH8Ul0cb2HgjmNboQ/JnEFy+kHCWqAJph3ikMOiIuyYVdx0JO4nEIWJyzSnc4TTdmoTulsikvJEg==
|
||||
|
||||
vite-plugin-dynamic-import@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/vite-plugin-dynamic-import/-/vite-plugin-dynamic-import-1.4.0.tgz#681fd38e40b36a4d312092b16a2cd96d735ed9d1"
|
||||
integrity sha512-OBWeCGyWE4iIwCUfx3RK8XwT1BjPAJNeMQmdO5md5Gq8PD8gLMCfUnuEiX9dIQDL9Gdvao1GNRqZwfcpwWDTNw==
|
||||
dependencies:
|
||||
acorn "^8.8.2"
|
||||
es-module-lexer "^1.2.1"
|
||||
fast-glob "^3.2.12"
|
||||
|
||||
vite-plugin-svgr@3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/vite-plugin-svgr/-/vite-plugin-svgr-3.2.0.tgz#920375aaf6635091c9ac8e467825f92d32544476"
|
||||
|
|
Loading…
Reference in a new issue