Skip to content

Commit add0329

Browse files
authored
Combine strings.ts and swg-strings.ts (#3857)
1 parent eff6eb3 commit add0329

15 files changed

+777
-656
lines changed

build_binaries.sh

100644100755
File mode changed.

src/components/dialog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {CloseWindowRequest} from '../proto/api_messages';
1919
import {Doc, resolveDoc} from '../model/doc';
2020
import {FriendlyIframe} from './friendly-iframe';
2121
import {Graypane} from './graypane';
22+
import {I18N_STRINGS} from '../i18n/strings';
2223
import {LoadingView} from '../ui/loading-view';
23-
import {SWG_I18N_STRINGS} from '../i18n/swg-strings';
2424
import {UI_CSS} from '../ui/ui-css';
2525
import {View} from './view';
2626
import {
@@ -151,7 +151,7 @@ export class Dialog {
151151
const iframeCssClass =
152152
dialogConfig.iframeCssClassOverride || defaultIframeCssClass;
153153

154-
const title = msg(SWG_I18N_STRINGS.SWG_CTA, titleLang);
154+
const title = msg(I18N_STRINGS.SWG_CTA, titleLang);
155155

156156
this.iframe_ = new FriendlyIframe(doc.getWin().document, {
157157
'class': iframeCssClass,

src/i18n/strings.ts

Lines changed: 746 additions & 11 deletions
Large diffs are not rendered by default.

src/i18n/swg-strings.ts

Lines changed: 0 additions & 600 deletions
This file was deleted.

src/i18n/translation.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
*/
1616

1717
import {I18N_STRINGS} from './strings';
18-
import {SWG_I18N_STRINGS} from './swg-strings';
1918

2019
/* Language code to string mapping. English is always provided. */
2120
export type Translation = {
2221
en: string;
2322
} & Record<string, string>;
2423

2524
I18N_STRINGS satisfies Record<string, Translation>;
26-
SWG_I18N_STRINGS satisfies Record<string, Translation>;

src/runtime/analytics-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import {ClientEvent} from '../api/client-event-manager-api';
2929
import {ClientEventManager} from './client-event-manager';
3030
import {Deps} from './deps';
3131
import {Doc} from '../model/doc';
32+
import {I18N_STRINGS} from '../i18n/strings';
3233
import {INTERNAL_RUNTIME_VERSION} from '../constants';
33-
import {SWG_I18N_STRINGS} from '../i18n/swg-strings';
3434
import {createElement} from '../utils/dom';
3535
import {feUrl} from './services';
3636
import {getCanonicalTag, getCanonicalUrl} from '../utils/url';
@@ -110,7 +110,7 @@ export class AnalyticsService {
110110
this.activityPorts_ = deps_.activities();
111111

112112
this.iframe_ = createElement(this.doc_.getWin().document, 'iframe', {
113-
'title': SWG_I18N_STRINGS.SWG_SERVICE.en,
113+
'title': I18N_STRINGS.SWG_SERVICE.en,
114114
});
115115
setImportantStyles(this.iframe_, iframeStyles);
116116
this.doc_.getBody()?.appendChild(this.getElement());

src/runtime/audience-action-flow-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => {
546546
expect(toast).not.to.be.null;
547547
expect(toast.src_).to.contain('flavor=custom');
548548
expect(decodeURI(toast.src_)).to.contain(
549-
'Signup failed. Try signing up again.'
549+
'Sign-up failed. Try signing up again.'
550550
);
551551
});
552552

src/runtime/audience-action-flow.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ import {ClientConfigManager} from './client-config-manager';
4343
import {Deps} from './deps';
4444
import {DialogManager} from '../components/dialog-manager';
4545
import {EntitlementsManager} from './entitlements-manager';
46+
import {I18N_STRINGS} from '../i18n/strings';
4647
import {InterventionResult} from '../api/available-intervention';
4748
import {InterventionType} from '../api/intervention-type';
4849
import {Message} from '../proto/api_messages';
4950
import {ProductType} from '../api/subscriptions';
5051
import {PromptPreference} from './intervention';
51-
import {SWG_I18N_STRINGS} from '../i18n/swg-strings';
5252
import {StorageKeys} from '../utils/constants';
5353
import {Toast} from '../ui/toast';
5454
import {XhrFetcher} from './fetcher';
@@ -112,7 +112,7 @@ const autopromptTypeToProductTypeMapping: {
112112

113113
const DEFAULT_PRODUCT_TYPE = ProductType.SUBSCRIPTION;
114114

115-
const placeholderPatternForEmail = /<ph name="EMAIL".+?\/ph>/g;
115+
const placeholderPatternForEmail = /{EMAIL}/g;
116116

117117
interface DirectCompleteAudienceActionResponse {
118118
updated?: boolean;
@@ -301,13 +301,13 @@ export class AudienceActionIframeFlow implements AudienceActionFlow {
301301
let customText = '';
302302
switch (this.params_.action) {
303303
case InterventionType.TYPE_REGISTRATION_WALL:
304-
customText = msg(
305-
SWG_I18N_STRINGS.REGWALL_ACCOUNT_CREATED,
306-
lang
307-
).replace(placeholderPatternForEmail, userEmail);
304+
customText = msg(I18N_STRINGS.REGWALL_ACCOUNT_CREATED, lang).replace(
305+
placeholderPatternForEmail,
306+
userEmail
307+
);
308308
break;
309309
case InterventionType.TYPE_NEWSLETTER_SIGNUP:
310-
customText = msg(SWG_I18N_STRINGS.NEWSLETTER_SIGNED_UP, lang).replace(
310+
customText = msg(I18N_STRINGS.NEWSLETTER_SIGNED_UP, lang).replace(
311311
placeholderPatternForEmail,
312312
userEmail
313313
);
@@ -337,10 +337,10 @@ export class AudienceActionIframeFlow implements AudienceActionFlow {
337337
let customText = '';
338338
switch (this.params_.action) {
339339
case InterventionType.TYPE_REGISTRATION_WALL:
340-
customText = msg(SWG_I18N_STRINGS.REGWALL_REGISTER_FAILED, lang);
340+
customText = msg(I18N_STRINGS.REGWALL_REGISTER_FAILED, lang);
341341
break;
342342
case InterventionType.TYPE_NEWSLETTER_SIGNUP:
343-
customText = msg(SWG_I18N_STRINGS.NEWSLETTER_SIGN_UP_FAILED, lang);
343+
customText = msg(I18N_STRINGS.NEWSLETTER_SIGN_UP_FAILED, lang);
344344
break;
345345
default:
346346
// Do not show toast for other types.

src/runtime/basic-runtime.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ import {Doc, resolveDoc} from '../model/doc';
3737
import {Entitlements} from '../api/entitlements';
3838
import {EntitlementsManager} from './entitlements-manager';
3939
import {Fetcher, XhrFetcher} from './fetcher';
40+
import {I18N_STRINGS} from '../i18n/strings';
4041
import {InlineCtaApi} from './inline-cta-api';
4142
import {JsError} from './jserror';
4243
import {PageConfig} from '../model/page-config';
4344
import {PageConfigResolver} from '../model/page-config-resolver';
4445
import {PageConfigWriter} from '../model/page-config-writer';
4546
import {PayClient} from './pay-client';
46-
import {SWG_I18N_STRINGS} from '../i18n/swg-strings';
4747
import {Storage} from './storage';
4848
import {StorageKeys} from '../utils/constants';
4949
import {SubscribeResponse} from '../api/subscribe-response';
@@ -586,7 +586,7 @@ export class ConfiguredBasicRuntime implements Deps, BasicSubscriptions {
586586
// Fallback in case there is no active flow. This occurs when the entitlment check
587587
// runs as a redirect.
588588
const language = this.clientConfigManager().getLanguage();
589-
const customText = msg(SWG_I18N_STRINGS.NO_MEMBERSHIP_FOUND, language);
589+
const customText = msg(I18N_STRINGS.NO_MEMBERSHIP_FOUND, language);
590590
new Toast(
591591
this,
592592
feUrl('/toastiframe', {

src/runtime/button-api.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {ButtonOptions, SmartButtonOptions} from '../api/subscriptions';
2020
import {ConfiguredRuntime} from './runtime';
2121
import {Deps} from './deps';
2222
import {Doc} from '../model/doc';
23-
import {SWG_I18N_STRINGS} from '../i18n/swg-strings';
23+
import {I18N_STRINGS} from '../i18n/strings';
2424
import {SmartSubscriptionButtonApi, Theme} from './smart-button-api';
2525
import {createElement} from '../utils/dom';
2626
import {msg} from '../utils/i18n';
@@ -106,10 +106,7 @@ export class ButtonApi {
106106
if (options['lang']) {
107107
button.setAttribute('lang', options['lang']);
108108
}
109-
button.setAttribute(
110-
'title',
111-
msg(SWG_I18N_STRINGS.SUBSCRIPTION_TITLE, button)
112-
);
109+
button.setAttribute('title', msg(I18N_STRINGS.SUBSCRIPTION_BUTTON, button));
113110
this.logSwgEvent_(AnalyticsEvent.IMPRESSION_SWG_BUTTON);
114111

115112
return button;
@@ -142,10 +139,7 @@ export class ButtonApi {
142139
button./*OK*/ innerHTML = BUTTON_INNER_HTML.replace(
143140
'$theme$',
144141
theme!
145-
).replace(
146-
'$textContent$',
147-
msg(SWG_I18N_STRINGS.SUBSCRIPTION_TITLE, button)
148-
);
142+
).replace('$textContent$', msg(I18N_STRINGS.SUBSCRIPTION_BUTTON, button));
149143
this.logSwgEvent_(AnalyticsEvent.IMPRESSION_SHOW_OFFERS_SWG_BUTTON);
150144

151145
return button;
@@ -178,10 +172,7 @@ export class ButtonApi {
178172
button./*OK*/ innerHTML = BUTTON_INNER_HTML.replace(
179173
'$theme$',
180174
theme!
181-
).replace(
182-
'$textContent$',
183-
msg(SWG_I18N_STRINGS.CONTRIBUTION_TITLE, button)
184-
);
175+
).replace('$textContent$', msg(I18N_STRINGS.CONTRIBUTION_BUTTON, button));
185176
this.logSwgEvent_(AnalyticsEvent.IMPRESSION_SHOW_CONTRIBUTIONS_SWG_BUTTON);
186177

187178
return button;

0 commit comments

Comments
 (0)