diff --git a/scripts/normalize-xlf.prebuild.ts b/scripts/normalize-xlf.prebuild.ts index f6d83dc68..470c03c7d 100644 --- a/scripts/normalize-xlf.prebuild.ts +++ b/scripts/normalize-xlf.prebuild.ts @@ -7,6 +7,43 @@ const TEST_LANGUAGES = [ { code: 'rl', target: 'RL' }, ] +// Path to the standalone print-view script. Its $localize strings are NOT +// picked up by `ng extract-i18n` (the file is a plain asset, not part of the +// Angular compilation), so we parse them out here and inject them into the +// XLF. Parsing the file directly keeps fetch-orcid.js as the single source of +// truth: strings added/removed there propagate automatically, with no +// hardcoded list to drift out of sync. +const PRINT_VIEW_SOURCE_FILE = './src/assets/print-view/fetch-orcid.js' + +interface PrintViewUnit { + id: string + source: string +} + +function parsePrintViewUnits(path: string): PrintViewUnit[] { + const js = fs.readFileSync(path, 'utf8') + // Matches $localize tagged templates of the form `:@@printView.someId:Source text` + const re = /:@@(printView\.[A-Za-z0-9_]+):([^`]*)`/g + const units: PrintViewUnit[] = [] + const seen = new Set() + let match: RegExpExecArray | null + while ((match = re.exec(js)) !== null) { + const [, id, rawSource] = match + if (seen.has(id)) { + continue + } + seen.add(id) + // Convert $localize template placeholders `${expression}:NAME:` into the + // canonical $localize message form `{$NAME}` so the XLF source matches the + // runtime message and stays stable regardless of the JS expression. + const source = normalizeText( + rawSource.replace(/\$\{[^}]*\}:([A-Z0-9_]+):/g, '{$$$1}') + ) + units.push({ id, source }) + } + return units +} + function normalizeText(input: string): string { return input .replace(/\r/g, '') @@ -85,115 +122,19 @@ function normalizeXlf12Sources(path: string) { } }) - // Inject @@printView.* source-only trans-units so the test-language - // generator (generateTestingLanguages) will also stamp X / LR / RL for - // these strings, and so Transifex can discover them for real locales. - // We use a stable @@-prefixed id so $localize can match by explicit id. - const PRINT_VIEW_UNITS = [ - 'printView.unnamedProfile', - 'printView.orcidIdAlt', - 'printView.biography', - 'printView.personalInformation', - 'printView.emails', - 'printView.websitesSocialLinks', - 'printView.otherIds', - 'printView.keywords', - 'printView.countries', - 'printView.activities', - 'printView.employments', - 'printView.educationAndQualifications', - 'printView.professionalActivities', - 'printView.fundings', - 'printView.researchResources', - 'printView.works', - 'printView.organization', - 'printView.organizationAddress', - 'printView.startDate', - 'printView.endDate', - 'printView.publicationDate', - 'printView.journal', - 'printView.roleTitle', - 'printView.department', - 'printView.type', - 'printView.url', - 'printView.untitled', - 'printView.identifier', - 'printView.enterOrcidId', - 'printView.orcidIdHelp', - 'printView.loadProfile', - 'printView.invalidOrcidId', - 'printView.loadingRecord', - 'printView.recordNotFound', - 'printView.redirectingToPrimary', - 'printView.fetchFailed', - 'printView.couldNotLoad', - 'printView.activityGroupHeading', - 'printView.peerReviewHeading', - 'printView.printSaveAsPdf', - 'printView.printThisOrcidProfile', - 'printView.relSelf', - 'printView.relPartOf', - 'printView.relVersionOf', - 'printView.relFundedBy', - ] - const PRINT_VIEW_SOURCES: Record = { - 'printView.unnamedProfile': 'Unnamed ORCID profile', - 'printView.orcidIdAlt': 'ORCID iD', - 'printView.biography': 'Biography', - 'printView.personalInformation': 'Personal information', - 'printView.emails': 'Emails', - 'printView.websitesSocialLinks': 'Websites & social links', - 'printView.otherIds': 'Other IDs', - 'printView.keywords': 'Keywords', - 'printView.countries': 'Countries', - 'printView.activities': 'Activities', - 'printView.employments': 'Employments', - 'printView.educationAndQualifications': 'Education and qualifications', - 'printView.professionalActivities': 'Professional activities', - 'printView.fundings': 'Fundings', - 'printView.researchResources': 'Research Resources', - 'printView.works': 'Works', - 'printView.organization': 'Organization', - 'printView.organizationAddress': 'Organization address', - 'printView.startDate': 'Start date', - 'printView.endDate': 'End date', - 'printView.publicationDate': 'Publication date', - 'printView.journal': 'Journal', - 'printView.roleTitle': 'Role title', - 'printView.department': 'Department', - 'printView.type': 'Type', - 'printView.url': 'URL', - 'printView.untitled': 'Untitled', - 'printView.identifier': 'Identifier', - 'printView.enterOrcidId': 'Enter an ORCID iD', - 'printView.orcidIdHelp': - 'Add an ORCID iD to the URL or use the form below.', - 'printView.loadProfile': 'Load profile', - 'printView.invalidOrcidId': - 'Enter a valid ORCID iD (format: 0000-0000-0000-0000).', - 'printView.loadingRecord': 'Loading ORCID record...', - 'printView.recordNotFound': - 'Record data was not found in ORCID response.', - 'printView.redirectingToPrimary': - 'Redirecting to primary ORCID record\u2026', - 'printView.fetchFailed': 'Failed to fetch ORCID record', - 'printView.couldNotLoad': 'Could not load', - 'printView.activityGroupHeading': 'Activity group heading', - 'printView.peerReviewHeading': 'Peer review heading', - 'printView.printSaveAsPdf': 'Print / Save as PDF', - 'printView.printThisOrcidProfile': 'Print this ORCID profile', - 'printView.relSelf': 'Self', - 'printView.relPartOf': 'Part of', - 'printView.relVersionOf': 'Version of', - 'printView.relFundedBy': 'Funded by', - } + // Inject @@printView.* source-only trans-units parsed from the standalone + // print-view script so the test-language generator (generateTestingLanguages) + // will also stamp X / LR / RL for these strings, and so Transifex can + // discover them for real locales. We use a stable @@-prefixed id so + // $localize can match by explicit id. + const printViewUnits = parsePrintViewUnits(PRINT_VIEW_SOURCE_FILE) const existingIds = new Set(transUnits.map((tu: any) => tu?.$?.id)) const printViewBody = fileNode?.body?.[0] - PRINT_VIEW_UNITS.forEach((id) => { + printViewUnits.forEach(({ id, source }) => { if (!existingIds.has(id)) { printViewBody['trans-unit'].push({ $: { id, datatype: 'html', resname: id }, - source: [PRINT_VIEW_SOURCES[id] ?? id], + source: [source], }) } }) diff --git a/src/app/constants.ts b/src/app/constants.ts index f13a7e84e..3a3439a36 100644 --- a/src/app/constants.ts +++ b/src/app/constants.ts @@ -137,7 +137,7 @@ export const ApplicationRoutesLabels = { [ApplicationRoutes.resetPasswordEmail]: $localize`:@@share.resetPasswordEmail:Reset password - ORCID`, [ApplicationRoutes.selfService]: $localize`:@@share.selfService:Self Service - ORCID`, [ApplicationRoutes.developerTools]: $localize`:@@share.developerTools:Developer tools - ORCID`, - [ApplicationRoutes.smsPoc]: $localize`:@@share.smsPoc:SMS POC - ORCID`, + [ApplicationRoutes.smsPoc]: 'SMS POC - ORCID', } export const ApplicationDynamicRoutesLabels = { diff --git a/src/app/sms-poc/pages/sms-poc/sms-poc.component.html b/src/app/sms-poc/pages/sms-poc/sms-poc.component.html index 3ed245a39..fb71a3091 100644 --- a/src/app/sms-poc/pages/sms-poc/sms-poc.component.html +++ b/src/app/sms-poc/pages/sms-poc/sms-poc.component.html @@ -1,17 +1,14 @@ -

+

SMS POC

-

+

Send a test SMS. Choose AWS or Twilio for each send.

- + This POC currently runs in SANDBOX mode. If you want to test actual SMS delivery to your phone, please reach out to Leo on Slack to add your phone number to our AWS SNS ORCID Friend Sandbox and the Twilio @@ -22,10 +19,7 @@

- + Provider color="primary" class="provider-group flex gap-4" > - + AWS SNS - + Twilio @@ -46,7 +40,6 @@

@@ -66,7 +59,7 @@

- Message + Message {{ message?.value?.length || 0 }}/1600 @if (message?.hasError('required') && message?.touched) { - Message is required + Message is required } @if (message?.hasError('maxlength') && message?.touched) { - + Message must be 1600 characters or fewer } @@ -90,7 +83,7 @@

} @if (response?.success) {
- SMS sent. + SMS sent. {{ response.provider }}: {{ response.providerMessageId || response.status }} @@ -107,7 +100,6 @@

type="submit" [disabled]="loading" [ngClass]="{ 'button-loading': loading }" - i18n="@@smsPoc.send" > Send SMS diff --git a/src/app/sms-poc/pages/sms-poc/sms-poc.component.ts b/src/app/sms-poc/pages/sms-poc/sms-poc.component.ts index a4a3e1912..4018b7c7c 100644 --- a/src/app/sms-poc/pages/sms-poc/sms-poc.component.ts +++ b/src/app/sms-poc/pages/sms-poc/sms-poc.component.ts @@ -43,10 +43,10 @@ export class SmsPocComponent implements OnInit { return null } if (this.phoneNumber.hasError('required')) { - return $localize`:@@smsPoc.phoneRequired:Phone number is required` + return 'Phone number is required' } if (this.phoneNumber.hasError('invalidPhone')) { - return $localize`:@@smsPoc.phoneInvalid:Enter a valid phone number` + return 'Enter a valid phone number' } return null } @@ -73,7 +73,7 @@ export class SmsPocComponent implements OnInit { }, error: () => { this.loading = false - this.backendError = $localize`:@@smsPoc.sendFailed:SMS send failed` + this.backendError = 'SMS send failed' }, }) } diff --git a/src/locale/messages.lr.xlf b/src/locale/messages.lr.xlf index 557f9966a..4ac20a5ab 100644 --- a/src/locale/messages.lr.xlf +++ b/src/locale/messages.lr.xlf @@ -6371,14 +6371,6 @@ LR - - SMS POC - ORCID - - src/app/constants.ts - 140 - - LR - - ORCID @@ -18967,126 +18959,6 @@ LR - - SMS POC - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 2,4 - - LR - - - Send a test SMS. Choose AWS or Twilio for each send. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 8,10 - - LR - - - This POC currently runs in SANDBOX mode. If you want to test actual SMS delivery to your phone, please reach out to Leo on Slack to add your phone number to our AWS SNS ORCID Friend Sandbox and the Twilio accounts. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 14,19 - - LR - - - Provider - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 28,30 - - LR - - - AWS SNS - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 36,38 - - LR - - - Twilio - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 39,41 - - LR - - - Phone number - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 50,52 - - LR - - - Message - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 69 - - LR - - - Message is required - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 78 - - LR - - - Message must be 1600 characters or fewer - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 80,82 - - LR - - - SMS sent. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 93 - - LR - - - Send SMS - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 111,113 - - LR - - - Phone number is required - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 46 - - LR - - - Enter a valid phone number - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 49 - - LR - - - SMS send failed - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 76 - - LR - Step 1 of 2 - Authentication app @@ -21153,7 +21025,7 @@ LR - Unnamed ORCID profile + Name is private LR @@ -21264,22 +21136,6 @@ Identifier LR - - Enter an ORCID iD - LR - - - Add an ORCID iD to the URL or use the form below. - LR - - - Load profile - LR - - - Enter a valid ORCID iD (format: 0000-0000-0000-0000). - LR - Loading ORCID record... LR @@ -21292,20 +21148,8 @@ Redirecting to primary ORCID record… LR - - Failed to fetch ORCID record - LR - - - Could not load - LR - - - Activity group heading - LR - - - Peer review heading + + ORCID Print view LR @@ -21332,6 +21176,22 @@ Funded by LR + + {$TITLE} ({$COUNT}) + LR + + + Peer review ({$REVIEW_COUNT} reviews for {$PUBLICATION_COUNT} publications/grants) + LR + + + Failed to fetch ORCID record ({$STATUS}). + LR + + + Could not load {$ORCID_ID}. + LR + \ No newline at end of file diff --git a/src/locale/messages.rl.xlf b/src/locale/messages.rl.xlf index f1d3828cd..951453fe6 100644 --- a/src/locale/messages.rl.xlf +++ b/src/locale/messages.rl.xlf @@ -6371,14 +6371,6 @@ RL - - SMS POC - ORCID - - src/app/constants.ts - 140 - - RL - - ORCID @@ -18967,126 +18959,6 @@ RL - - SMS POC - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 2,4 - - RL - - - Send a test SMS. Choose AWS or Twilio for each send. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 8,10 - - RL - - - This POC currently runs in SANDBOX mode. If you want to test actual SMS delivery to your phone, please reach out to Leo on Slack to add your phone number to our AWS SNS ORCID Friend Sandbox and the Twilio accounts. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 14,19 - - RL - - - Provider - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 28,30 - - RL - - - AWS SNS - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 36,38 - - RL - - - Twilio - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 39,41 - - RL - - - Phone number - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 50,52 - - RL - - - Message - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 69 - - RL - - - Message is required - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 78 - - RL - - - Message must be 1600 characters or fewer - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 80,82 - - RL - - - SMS sent. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 93 - - RL - - - Send SMS - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 111,113 - - RL - - - Phone number is required - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 46 - - RL - - - Enter a valid phone number - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 49 - - RL - - - SMS send failed - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 76 - - RL - Step 1 of 2 - Authentication app @@ -21153,7 +21025,7 @@ RL - Unnamed ORCID profile + Name is private RL @@ -21264,22 +21136,6 @@ Identifier RL - - Enter an ORCID iD - RL - - - Add an ORCID iD to the URL or use the form below. - RL - - - Load profile - RL - - - Enter a valid ORCID iD (format: 0000-0000-0000-0000). - RL - Loading ORCID record... RL @@ -21292,20 +21148,8 @@ Redirecting to primary ORCID record… RL - - Failed to fetch ORCID record - RL - - - Could not load - RL - - - Activity group heading - RL - - - Peer review heading + + ORCID Print view RL @@ -21332,6 +21176,22 @@ Funded by RL + + {$TITLE} ({$COUNT}) + RL + + + Peer review ({$REVIEW_COUNT} reviews for {$PUBLICATION_COUNT} publications/grants) + RL + + + Failed to fetch ORCID record ({$STATUS}). + RL + + + Could not load {$ORCID_ID}. + RL + \ No newline at end of file diff --git a/src/locale/messages.xlf b/src/locale/messages.xlf index 3bb140584..9e2050200 100644 --- a/src/locale/messages.xlf +++ b/src/locale/messages.xlf @@ -5771,13 +5771,6 @@ 139 - - SMS POC - ORCID - - src/app/constants.ts - 140 - - - ORCID @@ -16993,111 +16986,6 @@ 54 - - SMS POC - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 2,4 - - - - Send a test SMS. Choose AWS or Twilio for each send. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 8,10 - - - - This POC currently runs in SANDBOX mode. If you want to test actual SMS delivery to your phone, please reach out to Leo on Slack to add your phone number to our AWS SNS ORCID Friend Sandbox and the Twilio accounts. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 14,19 - - - - Provider - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 28,30 - - - - AWS SNS - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 36,38 - - - - Twilio - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 39,41 - - - - Phone number - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 50,52 - - - - Message - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 69 - - - - Message is required - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 78 - - - - Message must be 1600 characters or fewer - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 80,82 - - - - SMS sent. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 93 - - - - Send SMS - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 111,113 - - - - Phone number is required - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 46 - - - - Enter a valid phone number - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 49 - - - - SMS send failed - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 76 - - Step 1 of 2 - Authentication app @@ -18909,7 +18797,7 @@ - Unnamed ORCID profile + Name is private ORCID iD @@ -18992,18 +18880,6 @@ Identifier - - Enter an ORCID iD - - - Add an ORCID iD to the URL or use the form below. - - - Load profile - - - Enter a valid ORCID iD (format: 0000-0000-0000-0000). - Loading ORCID record... @@ -19013,17 +18889,8 @@ Redirecting to primary ORCID record… - - Failed to fetch ORCID record - - - Could not load - - - Activity group heading - - - Peer review heading + + ORCID Print view Print / Save as PDF @@ -19043,6 +18910,18 @@ Funded by + + {$TITLE} ({$COUNT}) + + + Peer review ({$REVIEW_COUNT} reviews for {$PUBLICATION_COUNT} publications/grants) + + + Failed to fetch ORCID record ({$STATUS}). + + + Could not load {$ORCID_ID}. + \ No newline at end of file diff --git a/src/locale/messages.xx.xlf b/src/locale/messages.xx.xlf index adef31a40..9a1ce7710 100644 --- a/src/locale/messages.xx.xlf +++ b/src/locale/messages.xx.xlf @@ -6371,14 +6371,6 @@ X - - SMS POC - ORCID - - src/app/constants.ts - 140 - - X - - ORCID @@ -18967,126 +18959,6 @@ X - - SMS POC - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 2,4 - - X - - - Send a test SMS. Choose AWS or Twilio for each send. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 8,10 - - X - - - This POC currently runs in SANDBOX mode. If you want to test actual SMS delivery to your phone, please reach out to Leo on Slack to add your phone number to our AWS SNS ORCID Friend Sandbox and the Twilio accounts. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 14,19 - - X - - - Provider - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 28,30 - - X - - - AWS SNS - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 36,38 - - X - - - Twilio - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 39,41 - - X - - - Phone number - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 50,52 - - X - - - Message - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 69 - - X - - - Message is required - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 78 - - X - - - Message must be 1600 characters or fewer - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 80,82 - - X - - - SMS sent. - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 93 - - X - - - Send SMS - - src/app/sms-poc/pages/sms-poc/sms-poc.component.html - 111,113 - - X - - - Phone number is required - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 46 - - X - - - Enter a valid phone number - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 49 - - X - - - SMS send failed - - src/app/sms-poc/pages/sms-poc/sms-poc.component.ts - 76 - - X - Step 1 of 2 - Authentication app @@ -21153,7 +21025,7 @@ X - Unnamed ORCID profile + Name is private X @@ -21264,22 +21136,6 @@ Identifier X - - Enter an ORCID iD - X - - - Add an ORCID iD to the URL or use the form below. - X - - - Load profile - X - - - Enter a valid ORCID iD (format: 0000-0000-0000-0000). - X - Loading ORCID record... X @@ -21292,20 +21148,8 @@ Redirecting to primary ORCID record… X - - Failed to fetch ORCID record - X - - - Could not load - X - - - Activity group heading - X - - - Peer review heading + + ORCID Print view X @@ -21332,6 +21176,22 @@ Funded by X + + {$TITLE} ({$COUNT}) + X + + + Peer review ({$REVIEW_COUNT} reviews for {$PUBLICATION_COUNT} publications/grants) + X + + + Failed to fetch ORCID record ({$STATUS}). + X + + + Could not load {$ORCID_ID}. + X + \ No newline at end of file