Skip to content

Commit

Permalink
initial commit iwth date error
Browse files Browse the repository at this point in the history
  • Loading branch information
cathysarisky committed Oct 27, 2024
1 parent 76d4ef2 commit 4d60bcb
Show file tree
Hide file tree
Showing 65 changed files with 1,437 additions and 18 deletions.
15 changes: 15 additions & 0 deletions ghost/email-service/i18n-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const i18nLib = require('../i18n');
const {settingsCache} = require('../core/core/frontend/services/proxy');

let locale = settingsCache.get('locale') || 'en';

const i18nLanguage = locale;
const i18n = i18nLib(i18nLanguage, 'newsletter');

function t(key, options) {
console.log('key is', key, "hash is", options?.hash );
let hash = options?.hash;
return i18n.t(key, hash);
}

module.exports = { t }
10 changes: 6 additions & 4 deletions ghost/email-service/lib/EmailRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const tpl = require('@tryghost/tpl');
const {EmailAddressParser} = require('@tryghost/email-addresses');
const {registerHelpers} = require('./helpers/register-helpers');
const crypto = require('crypto');
const {t} = require('../i18n-setup');

const messages = {
subscriptionStatus: {
Expand Down Expand Up @@ -671,15 +672,17 @@ class EmailRenderer {
id: 'status',
getValue: (member) => {
if (member.status === 'comped') {
return 'complimentary';
return t('complimentary');
}
if (this.isMemberTrialing(member)) {
return 'trialing';
return t('trialing');
}
return member.status;
// other possible statuses: t('free'), t('paid') //
return t(member.status);
}
},
{
//TODO i18n
id: 'status_text',
getValue: (member) => {
return this.getMemberStatusText(member);
Expand Down Expand Up @@ -748,7 +751,6 @@ class EmailRenderer {
}
delete replacement.originalId;
}

return replacements;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<td dir="ltr" valign="top" align="center" style="vertical-align: top; font-family: inherit; font-size: 14px; text-align: center; padding: 0 4px 4px; cursor: pointer; width: 33%;" nowrap>
<a href="{{href}}" target="_blank">
<img src={{iconUrl}} border="0" width={{width}} height={{height}} alt="{{buttonText}}">
<p class="feedback-button-mobile-text">{{buttonText}}</p>
<p class="feedback-button-mobile-text">{{t buttonText}}</p>
{{!-- Button text possible values: {{t 'More like this'}} {{t 'Less like this'}} {{t 'Comment'}} --}}
</a>
</td>
22 changes: 11 additions & 11 deletions ghost/email-service/lib/email-templates/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@
<table class="post-meta-wrapper" role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%" style="padding-bottom: 32px;">
<tr>
<td height="20" class="{{classes.meta}}" style="padding: 0;">
By {{post.authors}} • <span class="post-meta-date">{{post.publishedAt}} </span>
{{t 'By {authors}' authors=post.authors }} • <span class="post-meta-date">{{post.publishedAt}} </span>
</td>
<td class="{{classes.meta}} view-online desktop">
<a href="{{post.url}}" class="view-online-link">View in browser</a>
<a href="{{post.url}}" class="view-online-link">{{t 'View in browser'}}</a>
</td>
</tr>
<tr class="{{classes.meta}} view-online-mobile">
<td height="20" class="view-online">
<a href="{{post.url}}" class="view-online-link">View in browser</a>
<a href="{{post.url}}" class="view-online-link">{{t 'View in browser'}}</a>
</td>
</tr>
</table>
Expand Down Expand Up @@ -183,7 +183,7 @@
{{#if latestPosts.length}}
<tr>
<td style="padding: 24px 0; border-bottom: 1px solid #e5eff5;">
<h3 class="latest-posts-header">Keep reading</h3>
<h3 class="latest-posts-header">{{t 'Keep reading'}}</h3>
{{> latestPosts}}
</td>
</tr>
Expand All @@ -192,19 +192,19 @@
{{#if newsletter.showSubscriptionDetails}}
<tr>
<td class="subscription-box">
<h3>Subscription details</h3>
<h3>{{t 'Subscription details'}}</h3>
<p style="margin-bottom: 16px;">
<span>You are receiving this because you are a <strong>%%{status}%% subscriber</strong> to {{site.title}}.</span> %%{status_text}%%
<span>{{{t "You are receiving this because you are a <strong>%%{status}%% subscriber</strong> to {site}." site=site.title }}}</span> %%{status_text}%%
</p>
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="subscription-details">
<p class="%%{name_class}%%">Name: %%{name, "not provided"}%%</p>
<p>Email: <a href="#">%%{email}%%</a></p>
<p>Member since: %%{created_at}%%</p>
<p class="%%{name_class}%%">{{t 'Name'}}: %%{name, "not provided"}%%</p>
<p>{{t 'Email'}}: <a href="#">%%{email}%%</a></p>
<p>{{t 'Member since'}}: %%{created_at}%%</p>
</td>
<td align="right" valign="bottom" class="manage-subscription">
<a href="%%{manage_account_url}%%"> Manage subscription &rarr;</a>
<a href="%%{manage_account_url}%%">{{t 'Manage subscription'}} &rarr;</a>
</td>
</tr>
</table>
Expand All @@ -219,7 +219,7 @@
<tr><td class="footer">{{{footerContent}}}</td></tr>
{{/if}}
<tr>
<td class="footer">{{site.title}} &copy; {{year}} – <a href="%%{unsubscribe_url}%%">Unsubscribe</a></td>
<td class="footer">{{site.title}} &copy; {{year}} – <a href="%%{unsubscribe_url}%%">{{t 'Unsubscribe'}}</a></td>
</tr>

{{#if showBadge }}
Expand Down
5 changes: 5 additions & 0 deletions ghost/email-service/lib/helpers/register-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@ module.exports = {
return options.inverse(this);
}
});

handlebars.registerHelper('t', function (key, options) {
let i18n = require('../../i18n-setup');
return i18n.t(key, options);
});
}
};
12 changes: 11 additions & 1 deletion ghost/i18n/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,17 @@ const SUPPORTED_LOCALES = [

/**
* @param {string} [lng]
* @param {'ghost'|'portal'|'test'|'signup-form'|'comments'|'search'} ns
* @param {'ghost'|'portal'|'test'|'signup-form'|'comments'|'search'|'newsletter'} ns
*/
module.exports = (lng = 'en', ns = 'portal') => {
const i18nextInstance = i18next.createInstance();
let interpolation = {};
if (ns === 'newsletter') {
interpolation = {
prefix: "{",
suffix: "}",
}
}
i18nextInstance.init({
lng,

Expand All @@ -82,6 +89,9 @@ module.exports = (lng = 'en', ns = 'portal') => {
ns: ns,
defaultNS: ns,

// separators
interpolation,

resources: SUPPORTED_LOCALES.reduce((acc, locale) => {
const res = require(`../locales/${locale}/${ns}.json`);

Expand Down
24 changes: 24 additions & 0 deletions ghost/i18n/locales/af/newsletter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"By {authors}": "",
"Comment": "",
"complimentary": "",
"Email": "",
"free": "",
"Keep reading": "",
"Less like this": "",
"Manage subscription": "",
"Member since": "",
"More like this": "",
"Name": "",
"paid": "",
"Subscription details": "",
"trialing": "",
"Unsubscribe": "",
"View in browser": "",
"You are receiving this because you are a <strong>%%{status}%% subscriber</strong> to {site}.": "",
"Your free trial ends on {date}, at which time you will be charged the regular price. You can always cancel before then.": "",
"Your subscription has been canceled and will expire on {date}. You can resume your subscription via your account settings.": "",
"Your subscription has expired.": "",
"Your subscription will expire on {date}.": "",
"Your subscription will renew on {date}.": ""
}
24 changes: 24 additions & 0 deletions ghost/i18n/locales/ar/newsletter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"By {authors}": "",
"Comment": "",
"complimentary": "",
"Email": "",
"free": "",
"Keep reading": "",
"Less like this": "",
"Manage subscription": "",
"Member since": "",
"More like this": "",
"Name": "",
"paid": "",
"Subscription details": "",
"trialing": "",
"Unsubscribe": "",
"View in browser": "",
"You are receiving this because you are a <strong>%%{status}%% subscriber</strong> to {site}.": "",
"Your free trial ends on {date}, at which time you will be charged the regular price. You can always cancel before then.": "",
"Your subscription has been canceled and will expire on {date}. You can resume your subscription via your account settings.": "",
"Your subscription has expired.": "",
"Your subscription will expire on {date}.": "",
"Your subscription will renew on {date}.": ""
}
24 changes: 24 additions & 0 deletions ghost/i18n/locales/bg/newsletter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"By {authors}": "",
"Comment": "",
"complimentary": "",
"Email": "",
"free": "",
"Keep reading": "",
"Less like this": "",
"Manage subscription": "",
"Member since": "",
"More like this": "",
"Name": "",
"paid": "",
"Subscription details": "",
"trialing": "",
"Unsubscribe": "",
"View in browser": "",
"You are receiving this because you are a <strong>%%{status}%% subscriber</strong> to {site}.": "",
"Your free trial ends on {date}, at which time you will be charged the regular price. You can always cancel before then.": "",
"Your subscription has been canceled and will expire on {date}. You can resume your subscription via your account settings.": "",
"Your subscription has expired.": "",
"Your subscription will expire on {date}.": "",
"Your subscription will renew on {date}.": ""
}
24 changes: 24 additions & 0 deletions ghost/i18n/locales/bn/newsletter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"By {authors}": "",
"Comment": "",
"complimentary": "",
"Email": "",
"free": "",
"Keep reading": "",
"Less like this": "",
"Manage subscription": "",
"Member since": "",
"More like this": "",
"Name": "",
"paid": "",
"Subscription details": "",
"trialing": "",
"Unsubscribe": "",
"View in browser": "",
"You are receiving this because you are a <strong>%%{status}%% subscriber</strong> to {site}.": "",
"Your free trial ends on {date}, at which time you will be charged the regular price. You can always cancel before then.": "",
"Your subscription has been canceled and will expire on {date}. You can resume your subscription via your account settings.": "",
"Your subscription has expired.": "",
"Your subscription will expire on {date}.": "",
"Your subscription will renew on {date}.": ""
}
24 changes: 24 additions & 0 deletions ghost/i18n/locales/bs/newsletter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"By {authors}": "",
"Comment": "",
"complimentary": "",
"Email": "",
"free": "",
"Keep reading": "",
"Less like this": "",
"Manage subscription": "",
"Member since": "",
"More like this": "",
"Name": "",
"paid": "",
"Subscription details": "",
"trialing": "",
"Unsubscribe": "",
"View in browser": "",
"You are receiving this because you are a <strong>%%{status}%% subscriber</strong> to {site}.": "",
"Your free trial ends on {date}, at which time you will be charged the regular price. You can always cancel before then.": "",
"Your subscription has been canceled and will expire on {date}. You can resume your subscription via your account settings.": "",
"Your subscription has expired.": "",
"Your subscription will expire on {date}.": "",
"Your subscription will renew on {date}.": ""
}
24 changes: 24 additions & 0 deletions ghost/i18n/locales/ca/newsletter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"By {authors}": "",
"Comment": "",
"complimentary": "",
"Email": "",
"free": "",
"Keep reading": "",
"Less like this": "",
"Manage subscription": "",
"Member since": "",
"More like this": "",
"Name": "",
"paid": "",
"Subscription details": "",
"trialing": "",
"Unsubscribe": "",
"View in browser": "",
"You are receiving this because you are a <strong>%%{status}%% subscriber</strong> to {site}.": "",
"Your free trial ends on {date}, at which time you will be charged the regular price. You can always cancel before then.": "",
"Your subscription has been canceled and will expire on {date}. You can resume your subscription via your account settings.": "",
"Your subscription has expired.": "",
"Your subscription will expire on {date}.": "",
"Your subscription will renew on {date}.": ""
}
Loading

0 comments on commit 4d60bcb

Please sign in to comment.