Commit 35a6578a authored by Homada.Boumedane's avatar Homada.Boumedane Committed by Florent Poittevin
Browse files

refactor: language

remove iso3166-2-db b/c it has a large size and use another small dependency to get iso2/3 language.
parent 85f462bc
......@@ -2292,6 +2292,11 @@
}
}
},
"@cospired/i18n-iso-languages": {
"version": "3.1.1",
"resolved": "https://nexus.unige.ch/repository/npm-all/@cospired/i18n-iso-languages/-/i18n-iso-languages-3.1.1.tgz",
"integrity": "sha512-8X3tP5oWBJjRo5nuaeqA5tXIDUvfBTO81coPLVPlyXAn1oe9fjDsvlCenblbD2WKIfVlk+RmU5+6yl5oVB1TKQ=="
},
"@cspotcode/source-map-consumer": {
"version": "0.8.0",
"resolved": "https://nexus.unige.ch/repository/npm-all/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz",
......@@ -9884,11 +9889,6 @@
"resolved": "https://nexus.unige.ch/repository/npm-all/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
},
"iso3166-2-db": {
"version": "2.3.8",
"resolved": "https://nexus.unige.ch/repository/npm-all/iso3166-2-db/-/iso3166-2-db-2.3.8.tgz",
"integrity": "sha512-6YKT1I2dS5EFP2gEvR5Sp+YlbTHik2JuErwwWMJmXiq4ButUGSm+2AsIfoZbPuaFdg81d31B5AozHinau+D6kQ=="
},
"isobject": {
"version": "3.0.1",
"resolved": "https://nexus.unige.ch/repository/npm-all/isobject/-/isobject-3.0.1.tgz",
......
......@@ -41,7 +41,7 @@
"serve:prod": "cd dist/DLCM-Frontend && ws --spa index.html --rewrite \"/api/rss -> https://www.unige.ch/feed/rss\" -p 4200",
"simulate-prod-local": "rm -fr dist && cd ../Solidify-Frontend/ && npm run build && cp -fr dist/solidify-frontend ../AoU-Portal/node_modules && cd ../DLCM-Portal/ && npm run build:sourcemaps-prod-local && npm run serve:prod",
"refresh-ngsw-config": "ngsw-config dist/DLCM-Frontend ngsw-config.json",
"build-solidify": "rm -rf ./node_modules/Solidify-Frontend && cd ../Solidify-Frontend && npm run build && cp -fr dist/solidify-frontend ../DLCM-Portal/node_modules"
"build-solidify": "rm -rf ./node_modules/folidify-frontend && cd ../solidify-frontend && npm run build && cp -fr dist/solidify-frontend ../dlcm-portal/node_modules"
},
"dependencies": {
"@angular/animations": "12.2.7",
......@@ -56,6 +56,7 @@
"@angular/platform-browser-dynamic": "12.2.7",
"@angular/router": "12.2.7",
"@angular/service-worker": "12.2.7",
"@cospired/i18n-iso-languages": "^3.1.1",
"@fortawesome/angular-fontawesome": "0.9.0",
"@fortawesome/fontawesome-svg-core": "1.2.36",
"@fortawesome/free-solid-svg-icons": "5.15.4",
......@@ -73,7 +74,6 @@
"docx-preview": "0.1.7",
"file-saver": "2.0.5",
"http-status-codes": "2.1.4",
"iso3166-2-db": "2.3.8",
"jsme": "2017.2.26",
"jsmol": "1.1.0",
"moment": "2.29.1",
......
......@@ -10,10 +10,10 @@
[required]="formValidationHelper.hasRequiredField(fd)"
(blur)="checkAvailable(formDefinition.resId, fd)"
>
<mat-option *ngFor="let country of listCountry"
[value]="country.iso"
<mat-option *ngFor="let language of languagesList"
[value]="language.iso"
>
{{country.name}}
{{language.name}}
</mat-option>
</mat-select>
</mat-form-field>
......
......@@ -13,7 +13,6 @@ import {
import {Language} from "@models";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {BaseFormDefinition} from "@shared/models/base-form-definition.model";
import {Country} from "@shared/models/country.model";
import {RegionUtil} from "@shared/utils/region.util";
import {
distinctUntilChanged,
......@@ -24,6 +23,7 @@ import {
PropertyName,
SolidifyValidator,
} from "solidify-frontend";
import {AdminLanguage} from "@shared/models/admin-language.model";
@Component({
selector: "dlcm-admin-research-domain-form",
......@@ -37,7 +37,7 @@ export class AdminLanguageFormPresentational extends AbstractFormPresentational<
}
formDefinition: FormComponentFormDefinition = new FormComponentFormDefinition();
listCountry: Country[] = RegionUtil.getCountries();
languagesList: AdminLanguage[] = RegionUtil.getLanguagesWithIsoCode();
constructor(protected readonly _changeDetectorRef: ChangeDetectorRef,
protected readonly _elementRef: ElementRef,
......
export interface AdminLanguage {
iso: string;
name: string;
iso3?: string;
}
export interface Country {
iso: string;
iso3: string;
numeric: number;
fips: string;
reference: any;
regions: any[];
name: string;
}
import {Country} from "@shared/models/country.model";
import {
getDataSet,
reduce,
} from "iso3166-2-db";
import {AdminLanguage} from "@shared/models/admin-language.model";
import {getNames, LocalizedLanguageNames, registerLocale, toAlpha3T} from "@cospired/i18n-iso-languages";
declare const require: any;
export class RegionUtil {
static getCountries(): Country[] {
const countriesObject = reduce(getDataSet(), "en");
return Object.values(countriesObject);
static getLanguagesWithIsoCode(): AdminLanguage[] {
registerLocale(require("@cospired/i18n-iso-languages/langs/en.json"));
const languagesList : LocalizedLanguageNames = getNames("en");
return Object.entries(languagesList).map(([k, v]) => ({ iso: k.toUpperCase(), name: v, iso3: toAlpha3T(k).toUpperCase() }));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment