Skip to content

Commit

Permalink
Add locale module for non-Angular code. Fix placeholders into i18n st…
Browse files Browse the repository at this point in the history
…rings
  • Loading branch information
ommann committed Jan 10, 2024
1 parent 06564b7 commit e56211a
Show file tree
Hide file tree
Showing 12 changed files with 252 additions and 99 deletions.
18 changes: 18 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,34 @@
"fi": {
"localize": [
"fi"
],
"fileReplacements": [
{
"replace": "src/environments/locale.ts",
"with": "src/environments/locale.fi.ts"
}
]
},
"en": {
"localize": [
"en"
],
"fileReplacements": [
{
"replace": "src/environments/locale.ts",
"with": "src/environments/locale.en.ts"
}
]
},
"sv": {
"localize": [
"sv"
],
"fileReplacements": [
{
"replace": "src/environments/locale.ts",
"with": "src/environments/locale.sv.ts"
}
]
},
"es5": {
Expand Down
18 changes: 10 additions & 8 deletions src/app/portal/components/collapsible/collapsible.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="collapsible-container">
<div class='collapsible-label' (click)="toggle()">
<div style='display:flex'>
<div style='display: flex; flex-wrap: wrap'>
<ng-container *ngIf='decoration === "plus" && isOpen'>
<div style='margin-right: 10px'>-</div>
</ng-container>
Expand All @@ -15,17 +15,19 @@
<div style='margin-right: 10px'>+</div>
</ng-container>

<div>{{label}}</div>
<div>
{{label}}

<ng-container *ngIf='hasTooltip'>
<div style='margin-left: 10px; color: rgb(69, 70, 185)'>
<i class="fa fa-info-circle" [tooltip]='tooltipElement'></i>
</div>
</ng-container>
<ng-container *ngIf='hasTooltip'>
<div style='display: inline-block; margin-left: 10px; color: rgb(69, 70, 185)'>
<i class="fa fa-info-circle" [tooltip]='tooltipElement'></i>
</div>
</ng-container>
</div>
</div>

<span>
<i class="fa fa-chevron-down" [ngClass]='{"icon-collapsed": !isOpen, "icon-expanded": isOpen}'></i>
<i style='margin: 0 4px' class="fa fa-chevron-down" [ngClass]='{"icon-collapsed": !isOpen, "icon-expanded": isOpen}'></i>
</span>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ export class OrganizationFilterComponent {
6: 10,
};

/* TODO localization solution */ // TODO ?
public sectorNames = {
1: "Yliopisto",
2: "Ammattikorkeakoulu",
3: "Tutkimuslaitos",
4: "Yliopistollisen sairaalan erityisvastuualue",
6: "Muu"
1: $localize`:@@organizationSector1:Yliopisto`,
2: $localize`:@@organizationSector2:Ammattikorkeakoulu`,
3: $localize`:@@organizationSector3:Tutkimuslaitos`,
4: $localize`:@@organizationSector4:Yliopistollisen sairaalan erityisvastuualue`,
6: $localize`:@@organizationSector5:Muu`
}

toggleExpanded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ <h3 style='font-size: 1.4rem; margin: 0'>Rajaa hakua</h3>
OKM:n julkaisutiedonkeruun mukainen julkaisutyyppi A–G.
</ng-container>

<ng-container *ngFor='let label of ["A", "B", "C", "D", "E", "F", "G", "I"]'>
<ng-container *ngFor='let label of publicationTypeLabels'>

<app-collapsible [label]='label'>
<app-collapsible [label]='label.text'>
<ng-container *ngFor='let publicationTypeCodeFilter of publicationTypeCodeFilters$ | async'>

<ng-container *ngIf='(publicationTypeCodeFilter.id | firstLetter) === label'>
<ng-container *ngIf='(publicationTypeCodeFilter.id | firstLetter) === label.id'>
<app-filter-option [label]='publicationTypeCodeFilter.name'
[count]='publicationTypeCodeFilter.count'
[value]='publicationTypeCodeFilter.enabled'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ export class Publications2Component implements OnDestroy {
jufoLevel: $localize`:@@jufoLevel:Julkaisufoorumitaso`,
}

publicationTypeLabels = [
{id: "A", text: $localize`:@@publicationClassA:Vertaisarvioidut tieteelliset artikkelit`},
{id: "B", text: $localize`:@@publicationClassB:Vertaisarvioimattomat tieteelliset kirjoitukset`},
{id: "C", text: $localize`:@@publicationClassC:Tieteelliset kirjat`},
{id: "D", text: $localize`:@@publicationClassD:Ammattiyhteisölle suunnatut julkaisut`},
{id: "E", text: $localize`:@@publicationClassE:Suurelle yleisölle suunnatut julkaisut`},
{id: "F", text: $localize`:@@publicationClassF:Julkinen taiteellinen ja taideteollinen toiminta`},
{id: "G", text: $localize`:@@publicationClassG:Opinnäytteet`},
{id: "I", text: $localize`:@@publicationClassI:Audiovisuaaliset julkaisut ja tieto- ja viestintätekniset sovellukset`},
];


filterCount$ = new BehaviorSubject(0);
filterCountLookup: Record<string, number> = {};

Expand Down Expand Up @@ -300,27 +312,15 @@ export class Publications2Component implements OnDestroy {
tap(filters => this.updateFilterCount("parentPublicationType", filters.filter(filter => filter.enabled).length))
);



/* TODO localization solution */
public sectorName = {
1: "Yliopisto",
2: "Ammattikorkeakoulu",
3: "Tutkimuslaitos",
4: "Yliopistollisen sairaalan erityisvastuualue",
6: "Muu"
};

/* TODO localization solution */
public mainFieldOfScienceName = {
"1": "Luonnontieteet",
"2": "Tekniikka",
"3": "Lääke- ja terveystieteet",
"4": "Maatalous- ja metsätieteet",
"5": "Yhteiskuntatieteet",
"6": "Humanistiset tieteet",
"1": $localize`:@@naturalSciences:Luonnontieteet`,
"2": $localize`:@@engineeringTecnology:Tekniikka`,
"3": $localize`:@@medicalHealthSciences:Lääke- ja terveystieteet`,
"4": $localize`:@@agriculturalSciences:Maatalous- ja metsätieteet`,
"5": $localize`:@@socialSciences:Yhteiskuntatieteet`,
"6": $localize`:@@humanities:Humanistiset tieteet`,
// 7 not used
"8": "Taiteenala",
"8": $localize`:@@fieldsOfArt:Taiteenala`,
}

/*public collapseStates = {
Expand Down
Loading

0 comments on commit e56211a

Please sign in to comment.