Skip to content

Commit 666b6c9

Browse files
committed
feat(preprint-document-type): Introduced helper function that calculates document type
1 parent a4b1b9e commit 666b6c9

5 files changed

Lines changed: 56 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './preprint-document-type';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { TranslateService } from '@ngx-translate/core';
2+
3+
import { PreprintProviderDetails, PreprintWordGrammar } from '../models';
4+
5+
export function getPreprintDocumentType(
6+
provider: PreprintProviderDetails,
7+
translateService: TranslateService
8+
): Record<PreprintWordGrammar, string> {
9+
const key = `preprints.documentType.${provider.preprintWord}`;
10+
11+
return {
12+
plural: translateService.instant(`${key}.plural`),
13+
pluralCapitalized: translateService.instant(`${key}.pluralCapitalized`),
14+
singular: translateService.instant(`${key}.singular`),
15+
singularCapitalized: translateService.instant(`${key}.singularCapitalized`),
16+
};
17+
}

src/app/features/preprints/models/preprint-provider-json-api.models.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { StringOrNull } from '@core/helpers';
22
import { ProviderReviewsWorkflow } from '@osf/features/preprints/enums';
3+
import { PreprintWord } from '@osf/features/preprints/models/preprint-provider.models';
34
import { BrandDataJsonApi } from '@shared/models';
45

56
export interface PreprintProviderDetailsJsonApi {
@@ -12,7 +13,7 @@ export interface PreprintProviderDetailsJsonApi {
1213
example: string;
1314
domain: string;
1415
footer_links: string;
15-
preprint_word: string;
16+
preprint_word: PreprintWord;
1617
assets: {
1718
wide_white: string;
1819
square_color_no_transparent: string;

src/app/features/preprints/models/preprint-provider.models.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { StringOrNull } from '@core/helpers';
22
import { ProviderReviewsWorkflow } from '@osf/features/preprints/enums/provider-reviews-workflow.enum';
33
import { Brand } from '@shared/models';
44

5+
export type PreprintWord = 'default' | 'work' | 'paper' | 'preprint' | 'thesis';
6+
export type PreprintWordGrammar = 'plural' | 'pluralCapitalized' | 'singular' | 'singularCapitalized';
7+
58
export interface PreprintProviderDetails {
69
id: string;
710
name: string;
@@ -10,7 +13,7 @@ export interface PreprintProviderDetails {
1013
examplePreprintId: string;
1114
domain: string;
1215
footerLinksHtml: string;
13-
preprintWord: string;
16+
preprintWord: PreprintWord;
1417
allowSubmissions: boolean;
1518
assertionsEnabled: boolean;
1619
reviewsWorkflow: ProviderReviewsWorkflow | null;

src/assets/i18n/en.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,38 @@
19901990
"contributorsLabel": "Contributors",
19911991
"modifiedLabel": "Modified"
19921992
}
1993+
},
1994+
"documentType": {
1995+
"default": {
1996+
"plural": "documents",
1997+
"pluralCapitalized": "Documents",
1998+
"singular": "document",
1999+
"singularCapitalized": "Document"
2000+
},
2001+
"work": {
2002+
"plural": "works",
2003+
"pluralCapitalized": "Works",
2004+
"singular": "work",
2005+
"singularCapitalized": "Work"
2006+
},
2007+
"paper": {
2008+
"plural": "papers",
2009+
"pluralCapitalized": "Papers",
2010+
"singular": "paper",
2011+
"singularCapitalized": "Paper"
2012+
},
2013+
"preprint": {
2014+
"plural": "preprints",
2015+
"pluralCapitalized": "Preprints",
2016+
"singular": "preprint",
2017+
"singularCapitalized": "Preprint"
2018+
},
2019+
"thesis": {
2020+
"plural": "theses",
2021+
"pluralCapitalized": "Theses",
2022+
"singular": "thesis",
2023+
"singularCapitalized": "Thesis"
2024+
}
19932025
}
19942026
},
19952027
"registries": {

0 commit comments

Comments
 (0)