Skip to content

Commit

Permalink
shared: enable translations
Browse files Browse the repository at this point in the history
- Adds cli commands to extract and update translations.
- Copies shared assets to the app projects.
- Fixes assets pathes with the node dev server.

Co-Authored-by: Johnny Mariéthoz <[email protected]>
Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
jma and Garfield-fr committed Oct 9, 2023
1 parent 515f307 commit cc85e87
Show file tree
Hide file tree
Showing 24 changed files with 322 additions and 103 deletions.
105 changes: 78 additions & 27 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
"main": "projects/admin/src/main.ts",
"polyfills": "projects/admin/src/polyfills.ts",
"tsConfig": "projects/admin/tsconfig.app.json",
"assets": ["projects/admin/src/assets"],
"assets": [
"projects/admin/src/assets",
{
"glob": "**/*.json",
"input": "projects/shared/src/assets",
"output": "/assets/"
}
],
"styles": [
"node_modules/primeng/resources/themes/lara-light-blue/theme.css",
"node_modules/primeng/resources/primeng.min.css",
Expand Down Expand Up @@ -137,18 +144,25 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"allowedCommonJsDependencies": [
"crypto-js",
"easymde",
"moment"
],
"allowedCommonJsDependencies": ["crypto-js", "easymde", "moment"],
"outputPath": "build/dist/public-holdings-items",
"index": "projects/public-holdings-items/src/index.html",
"main": "projects/public-holdings-items/src/main.ts",
"polyfills": "projects/public-holdings-items/src/polyfills.ts",
"tsConfig": "projects/public-holdings-items/tsconfig.app.json",
"aot": true,
"assets": [],
"assets": [
{
"glob": "**/*.json",
"input": "projects/public-search/src/assets",
"output": "/assets/"
},
{
"glob": "**/*.json",
"input": "projects/shared/src/assets",
"output": "/assets/"
}
],
"styles": ["projects/public-search/src/app/scss/styles.scss"],
"scripts": []
},
Expand Down Expand Up @@ -243,7 +257,12 @@
"tsConfig": "projects/public-search/tsconfig.app.json",
"assets": [
"projects/public-search/src/favicon.ico",
"projects/public-search/src/assets"
"projects/public-search/src/assets",
{
"glob": "**/*.json",
"input": "projects/shared/src/assets",
"output": "/assets/"
}
],
"styles": [],
"scripts": [],
Expand Down Expand Up @@ -349,18 +368,25 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"allowedCommonJsDependencies": [
"crypto-js",
"easymde",
"moment"
],
"allowedCommonJsDependencies": ["crypto-js", "easymde", "moment"],
"outputPath": "build/dist/search-bar",
"index": "projects/search-bar/src/index.html",
"main": "projects/search-bar/src/main.ts",
"polyfills": "projects/search-bar/src/polyfills.ts",
"tsConfig": "projects/search-bar/tsconfig.app.json",
"aot": true,
"assets": [],
"assets": [
{
"glob": "**/*.json",
"input": "projects/public-search/src/assets",
"output": "/assets/"
},
{
"glob": "**/*.json",
"input": "projects/shared/src/assets",
"output": "/assets/"
}
],
"styles": [],
"scripts": []
},
Expand Down Expand Up @@ -490,7 +516,18 @@
"main": "projects/public-patron-profile/src/main.ts",
"polyfills": "projects/public-patron-profile/src/polyfills.ts",
"tsConfig": "projects/public-patron-profile/tsconfig.app.json",
"assets": [],
"assets": [
{
"glob": "**/*.json",
"input": "projects/public-search/src/assets",
"output": "/assets/"
},
{
"glob": "**/*.json",
"input": "projects/shared/src/assets",
"output": "/assets/"
}
],
"styles": ["projects/public-search/src/app/scss/styles.scss"],
"scripts": [],
"vendorChunk": true,
Expand Down Expand Up @@ -583,18 +620,25 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"allowedCommonJsDependencies": [
"crypto-js",
"easymde",
"moment"
],
"allowedCommonJsDependencies": ["crypto-js", "easymde", "moment"],
"outputPath": "build/dist/public-user-profile-edit",
"index": "projects/public-user-profile-edit/src/index.html",
"main": "projects/public-user-profile-edit/src/main.ts",
"polyfills": "projects/public-user-profile-edit/src/polyfills.ts",
"tsConfig": "projects/public-user-profile-edit/tsconfig.app.json",
"aot": true,
"assets": [],
"assets": [
{
"glob": "**/*.json",
"input": "projects/public-search/src/assets",
"output": "/assets/"
},
{
"glob": "**/*.json",
"input": "projects/shared/src/assets",
"output": "/assets/"
}
],
"styles": [],
"scripts": []
},
Expand Down Expand Up @@ -679,18 +723,25 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"allowedCommonJsDependencies": [
"crypto-js",
"easymde",
"moment"
],
"allowedCommonJsDependencies": ["crypto-js", "easymde", "moment"],
"outputPath": "build/dist/public-user-password-change",
"index": "projects/public-user-password-change/src/index.html",
"main": "projects/public-user-password-change/src/main.ts",
"polyfills": "projects/public-user-password-change/src/polyfills.ts",
"tsConfig": "projects/public-user-password-change/tsconfig.app.json",
"aot": true,
"assets": [],
"assets": [
{
"glob": "**/*.json",
"input": "projects/public-search/src/assets",
"output": "/assets/"
},
{
"glob": "**/*.json",
"input": "projects/shared/src/assets",
"output": "/assets/"
}
],
"styles": [],
"scripts": []
},
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@
"test": "ng test",
"lint": "ng lint --cache",
"e2e": "ng e2e",
"shared_extract_messages": "ngx-translate-extract -k -c -s -i ./projects/shared/src -o ./projects/shared/src/assets/rero-ils-ui/shared/i18n/en_US.json --fi ' '",
"shared_update_catalog": "ngx-translate-extract -k -c -s -i ./projects/shared/src -o ./projects/shared/src/assets/rero-ils-ui/shared/i18n/{de,en,es,fr,it,nl,ar}.json --fi ' '",
"admin_extract_messages": "ngx-translate-extract -k -c -s -i ./projects/admin/src -o ./projects/admin/src/assets/rero-ils-ui/admin/i18n/en_US.json --fi ' '",
"admin_update_catalog": "ngx-translate-extract -k -c -s -i ./projects/admin/src -o ./projects/admin/src/assets/rero-ils-ui/admin/i18n/{de,en,es,fr,it,nl,ar}.json --fi ' '",
"public-search_extract_messages": "ngx-translate-extract -k -c -s -i ./projects/public-search/src -o ./projects/public-search/src/assets/rero-ils-ui/public-search/i18n/en_US.json --fi ' '",
"public-search_update_catalog": "ngx-translate-extract -k -c -s -i ./projects/public-search/src -o ./projects/public-search/src/assets/rero-ils-ui/public-search/i18n/{de,en,es,fr,it,nl,ar}.json --fi ' '",
"extract_messages": "npm run public-search_extract_messages && npm run admin_extract_messages",
"update_catalog": "npm run public-search_update_catalog && npm run admin_update_catalog",
"extract_messages": "npm run shared_extract_messages && npm run public-search_extract_messages && npm run admin_extract_messages",
"update_catalog": "npm run shared_update_catalog && npm run public-search_update_catalog && npm run admin_update_catalog",
"postinstall": "ngcc"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion projects/admin/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const environment = {
defaultLanguage: 'en',
adminRoles: ['system_librarian', 'librarian'],
translationsURLs: [
'static/node_modules/@rero/rero-ils-ui/dist/admin/assets/rero-ils-ui/admin/i18n/${lang}.json',
'/static/node_modules/@rero/rero-ils-ui/dist/admin/assets/rero-ils-ui/shared/i18n/${lang}.json',
'/static/node_modules/@rero/rero-ils-ui/dist/admin/assets/rero-ils-ui/admin/i18n/${lang}.json',
'/api/translations/${lang}.json'
],
librarySwitchCheckParamsUrl: ['new', 'edit']
Expand Down
1 change: 1 addition & 0 deletions projects/admin/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const environment = {
defaultLanguage: 'en',
adminRoles: ['system_librarian', 'librarian'],
translationsURLs: [
'/assets/rero-ils-ui/shared/i18n/${lang}.json',
'/assets/rero-ils-ui/admin/i18n/${lang}.json',
'/api/translations/${lang}.json'
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
export const environment = {
production: true,
apiBaseUrl: '',
$refPrefix: 'https://bib.rero.ch',
languages: ['fr', 'de', 'it', 'en'],
globalViewName: 'global',
apiBaseUrl: "",
$refPrefix: "https://bib.rero.ch",
languages: ["fr", "de", "it", "en"],
globalViewName: "global",
translationsURLs: [
'/static/node_modules/@rero/rero-ils-ui/dist/public-search/assets/rero-ils-ui/public-search/i18n/${lang}.json',
'/api/translations/${lang}.json'
]
"/static/node_modules/@rero/rero-ils-ui/dist/public-holdings-items/assets/rero-ils-ui/shared/i18n/${lang}.json",
"/static/node_modules/@rero/rero-ils-ui/dist/public-holdings-items/assets/rero-ils-ui/public-search/i18n/${lang}.json",
"/api/translations/${lang}.json",
],
};
15 changes: 8 additions & 7 deletions projects/public-holdings-items/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

export const environment = {
production: false,
apiBaseUrl: '',
$refPrefix: 'https://bib.rero.ch',
languages: ['fr', 'de', 'it', 'en'],
globalViewName: 'global',
apiBaseUrl: "",
$refPrefix: "https://bib.rero.ch",
languages: ["fr", "de", "it", "en"],
globalViewName: "global",
translationsURLs: [
'/static/node_modules/@rero/rero-ils-ui/dist/public-search/assets/rero-ils-ui/public-search/i18n/${lang}.json',
'/api/translations/${lang}.json'
]
"/assets/rero-ils-ui/shared/i18n/${lang}.json",
"/assets/rero-ils-ui/public-search/i18n/${lang}.json",
"/api/translations/${lang}.json",
],
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*/
export const environment = {
production: true,
apiBaseUrl: '',
$refPrefix: 'https://bib.rero.ch',
languages: ['fr', 'de', 'it', 'en'],
globalViewName: 'global',
apiBaseUrl: "",
$refPrefix: "https://bib.rero.ch",
languages: ["fr", "de", "it", "en"],
globalViewName: "global",
translationsURLs: [
'/static/node_modules/@rero/rero-ils-ui/dist/public-search/assets/rero-ils-ui/public-search/i18n/${lang}.json',
'/api/translations/${lang}.json'
]
"/static/node_modules/@rero/rero-ils-ui/dist/public-patron-profile/assets/rero-ils-ui/shared/i18n/${lang}.json",
"/static/node_modules/@rero/rero-ils-ui/dist/public-patron-profile/assets/rero-ils-ui/public-search/i18n/${lang}.json",
"/api/translations/${lang}.json",
],
};
15 changes: 8 additions & 7 deletions projects/public-patron-profile/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@

export const environment = {
production: false,
apiBaseUrl: '',
$refPrefix: 'https://bib.rero.ch',
languages: ['fr', 'de', 'it', 'en'],
globalViewName: 'global',
apiBaseUrl: "",
$refPrefix: "https://bib.rero.ch",
languages: ["fr", "de", "it", "en"],
globalViewName: "global",
translationsURLs: [
'/static/node_modules/@rero/rero-ils-ui/dist/public-search/assets/rero-ils-ui/public-search/i18n/${lang}.json',
'/api/translations/${lang}.json'
]
"/assets/rero-ils-ui/shared/i18n/${lang}.json",
"/assets/rero-ils-ui/public-search/i18n/${lang}.json",
"/api/translations/${lang}.json",
],
};

/*
Expand Down
15 changes: 8 additions & 7 deletions projects/public-search/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*/
export const environment = {
production: true,
apiBaseUrl: '',
$refPrefix: 'https://bib.rero.ch',
languages: ['fr', 'de', 'it', 'en'],
globalViewName: 'global',
apiBaseUrl: "",
$refPrefix: "https://bib.rero.ch",
languages: ["fr", "de", "it", "en"],
globalViewName: "global",
translationsURLs: [
'/static/node_modules/@rero/rero-ils-ui/dist/public-search/assets/rero-ils-ui/public-search/i18n/${lang}.json',
'/api/translations/${lang}.json'
]
"/static/node_modules/@rero/rero-ils-ui/dist/public-search/assets/rero-ils-ui/shared/i18n/${lang}.json",
"/static/node_modules/@rero/rero-ils-ui/dist/public-search/assets/rero-ils-ui/public-search/i18n/${lang}.json",
"/api/translations/${lang}.json",
],
};
15 changes: 8 additions & 7 deletions projects/public-search/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@

export const environment = {
production: false,
apiBaseUrl: '',
$refPrefix: 'https://bib.rero.ch',
languages: ['fr', 'de', 'it', 'en'],
globalViewName: 'global',
apiBaseUrl: "",
$refPrefix: "https://bib.rero.ch",
languages: ["fr", "de", "it", "en"],
globalViewName: "global",
translationsURLs: [
'/assets/rero-ils-ui/public-search/i18n/${lang}.json',
'/api/translations/${lang}.json'
]
"/assets/rero-ils-ui/shared/i18n/${lang}.json",
"/assets/rero-ils-ui/public-search/i18n/${lang}.json",
"/api/translations/${lang}.json",
],
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*/
export const environment = {
production: true,
apiBaseUrl: '',
$refPrefix: 'https://bib.rero.ch',
languages: ['fr', 'de', 'it', 'en'],
globalViewName: 'global',
apiBaseUrl: "",
$refPrefix: "https://bib.rero.ch",
languages: ["fr", "de", "it", "en"],
globalViewName: "global",
translationsURLs: [
'/static/node_modules/@rero/rero-ils-ui/dist/public-search/assets/rero-ils-ui/public-search/i18n/${lang}.json',
'/api/translations/${lang}.json'
]
"/static/node_modules/@rero/rero-ils-ui/dist/public-user-password-change/assets/rero-ils-ui/shared/i18n/${lang}.json",
"/static/node_modules/@rero/rero-ils-ui/dist/public-user-password-change/assets/rero-ils-ui/public-search/i18n/${lang}.json",
"/api/translations/${lang}.json",
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@

export const environment = {
production: false,
apiBaseUrl: '',
$refPrefix: 'https://bib.rero.ch',
languages: ['fr', 'de', 'it', 'en'],
globalViewName: 'global',
apiBaseUrl: "",
$refPrefix: "https://bib.rero.ch",
languages: ["fr", "de", "it", "en"],
globalViewName: "global",
translationsURLs: [
'/static/node_modules/@rero/rero-ils-ui/dist/public-search/assets/rero-ils-ui/public-search/i18n/${lang}.json',
'/api/translations/${lang}.json'
"/assets/rero-ils-ui/shared/i18n/${lang}.json",
"/assets/rero-ils-ui/public-search/i18n/${lang}.json",
"/api/translations/${lang}.json",
]
};

Expand Down
Loading

0 comments on commit cc85e87

Please sign in to comment.