Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add support for i18n
Roland Geider8f9feb843b5d
diff --git a/angular/README.md b/angular/README.mdindex c25a3d429..fbef3e9c5 100644--- a/angular/README.md+++ b/angular/README.md@@ -20,6 +20,13 @@ or in this folder:ng build --configuration production --output-path ../wger/core/static/angular --watch --output-hashing none```+## i18n++```bash+ng extract-i18n --output-path src/locale/+```++## Updating angularUpdate angular to a new version with@@ -27,3 +34,4 @@ Update angular to a new version with```bashng update @angular/core @angular/cli```+diff --git a/angular/angular.json b/angular/angular.jsonindex 37989173b..0d821c63c 100644--- a/angular/angular.json+++ b/angular/angular.json@@ -17,6 +17,12 @@"root": "","sourceRoot": "src","prefix": "app",+ "i18n": {+ "sourceLocale": "en-US",+ "locales": {+ "de": "src/locale/messages.de.xlf"+ }+ },"architect": {"build": {"builder": "@angular-devkit/build-angular:browser",@@ -40,7 +46,8 @@"buildOptimizer": false,"sourceMap": true,"optimization": false,- "namedChunks": true+ "namedChunks": true,+ "localize": ["de"]},"configurations": {"production": {diff --git a/angular/package-lock.json b/angular/package-lock.jsonindex 909a761fa..da5203342 100644--- a/angular/package-lock.json+++ b/angular/package-lock.json@@ -511,6 +511,141 @@"tslib": "^2.1.0"}},+ "@angular/localize": {+ "version": "12.0.2",+ "resolved": "https://registry.npmjs.org/@angular/localize/-/localize-12.0.2.tgz",+ "integrity": "sha512-1uWMDyD0kgDBc6LYTerZMp+16hOKQeDYxrRsCPAJ2EOBOZTEGbAEozge+CbBwUjCBu356L/6QQZeELS1XzCpbw==",+ "dev": true,+ "requires": {+ "@babel/core": "7.8.3",+ "glob": "7.1.7",+ "yargs": "^16.2.0"+ },+ "dependencies": {+ "@babel/core": {+ "version": "7.8.3",+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.8.3.tgz",+ "integrity": "sha512-4XFkf8AwyrEG7Ziu3L2L0Cv+WyY47Tcsp70JFmpftbAA1K7YL/sgE9jh9HyNj08Y/U50ItUchpN0w6HxAoX1rA==",+ "dev": true,+ "requires": {+ "@babel/code-frame": "^7.8.3",+ "@babel/generator": "^7.8.3",+ "@babel/helpers": "^7.8.3",+ "@babel/parser": "^7.8.3",+ "@babel/template": "^7.8.3",+ "@babel/traverse": "^7.8.3",+ "@babel/types": "^7.8.3",+ "convert-source-map": "^1.7.0",+ "debug": "^4.1.0",+ "gensync": "^1.0.0-beta.1",+ "json5": "^2.1.0",+ "lodash": "^4.17.13",+ "resolve": "^1.3.2",+ "semver": "^5.4.1",+ "source-map": "^0.5.0"+ }+ },+ "ansi-styles": {+ "version": "4.3.0",+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",+ "dev": true,+ "requires": {+ "color-convert": "^2.0.1"+ }+ },+ "cliui": {+ "version": "7.0.4",+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",+ "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",+ "dev": true,+ "requires": {+ "string-width": "^4.2.0",+ "strip-ansi": "^6.0.0",+ "wrap-ansi": "^7.0.0"+ }+ },+ "color-convert": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",+ "dev": true,+ "requires": {+ "color-name": "~1.1.4"+ }+ },+ "color-name": {+ "version": "1.1.4",+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",+ "dev": true+ },+ "glob": {+ "version": "7.1.7",+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",+ "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",+ "dev": true,+ "requires": {+ "fs.realpath": "^1.0.0",+ "inflight": "^1.0.4",+ "inherits": "2",+ "minimatch": "^3.0.4",+ "once": "^1.3.0",+ "path-is-absolute": "^1.0.0"+ }+ },+ "semver": {+ "version": "5.7.1",+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",+ "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",+ "dev": true+ },+ "source-map": {+ "version": "0.5.7",+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",+ "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",+ "dev": true+ },+ "wrap-ansi": {+ "version": "7.0.0",+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",+ "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",+ "dev": true,+ "requires": {+ "ansi-styles": "^4.0.0",+ "string-width": "^4.1.0",+ "strip-ansi": "^6.0.0"+ }+ },+ "y18n": {+ "version": "5.0.8",+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",+ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",+ "dev": true+ },+ "yargs": {+ "version": "16.2.0",+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",+ "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",+ "dev": true,+ "requires": {+ "cliui": "^7.0.2",+ "escalade": "^3.1.1",+ "get-caller-file": "^2.0.5",+ "require-directory": "^2.1.1",+ "string-width": "^4.2.0",+ "y18n": "^5.0.5",+ "yargs-parser": "^20.2.2"+ }+ },+ "yargs-parser": {+ "version": "20.2.9",+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",+ "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==",+ "dev": true+ }+ }+ },"@angular/platform-browser": {"version": "12.0.2","resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-12.0.2.tgz",diff --git a/angular/package.json b/angular/package.jsonindex 8f6bbcad5..8df990fe1 100644--- a/angular/package.json+++ b/angular/package.json@@ -34,6 +34,7 @@"@angular-eslint/template-parser": "12.1.0","@angular/cli": "~12.0.2","@angular/compiler-cli": "~12.0.2",+ "@angular/localize": "^12.0.2","@types/jasmine": "~3.6.0","@types/node": "^12.11.1","@typescript-eslint/eslint-plugin": "4.23.0",diff --git a/angular/src/app/weight/weight-chart/weight-chart.component.ts b/angular/src/app/weight/weight-chart/weight-chart.component.tsindex b97464dd6..1f6bdb6e8 100644--- a/angular/src/app/weight/weight-chart/weight-chart.component.ts+++ b/angular/src/app/weight/weight-chart/weight-chart.component.ts@@ -41,7 +41,6 @@ export class WeightChartComponent implements OnInit {const out: {name: Date, value: number}[] = this.service.entries.map(entry => {return {name: entry.date, value: entry.weight};});- console.log(out);this.data = [{name: 'Weight',series: outdiff --git a/angular/src/app/weight/weight-detail/weight-detail.component.html b/angular/src/app/weight/weight-detail/weight-detail.component.htmlindex f7a3403fa..b32c43d18 100644--- a/angular/src/app/weight/weight-detail/weight-detail.component.html+++ b/angular/src/app/weight/weight-detail/weight-detail.component.html@@ -1,8 +1,6 @@<li class="list-group-item">- <button class="btn btn-danger" (click)="deleteEntry()">- Delete- </button>- <button class="btn btn-primary" (click)="toggleForm()">Edit</button>+ <button class="btn btn-danger" (click)="deleteEntry()" i18n>Delete</button>+ <button class="btn btn-primary" (click)="toggleForm()" i18n>Edit</button><div *ngIf="!showForm">{{entry.date | date:'shortDate'}} - {{entry.weight}}diff --git a/angular/src/app/weight/weight-edit/weight-edit.component.html b/angular/src/app/weight/weight-edit/weight-edit.component.htmlindex 1f7519880..3339e5766 100644--- a/angular/src/app/weight/weight-edit/weight-edit.component.html+++ b/angular/src/app/weight/weight-edit/weight-edit.component.html@@ -2,7 +2,7 @@<div class="form-row"><div class="col">- <label for="date">Date</label>+ <label for="date" i18n>Date</label><inputtype="date"id="date"@@ -11,7 +11,7 @@</div><div class="col">- <label for="weight">Weight</label>+ <label for="weight" i18n>Weight</label><inputtype="text"id="weight"@@ -24,8 +24,7 @@<buttontype="submit"class="btn btn-success"- [disabled]="group.invalid">Save- </button>+ [disabled]="group.invalid" i18n>Save</button></div></div>diff --git a/angular/src/app/weight/weight-list/weight-list.component.html b/angular/src/app/weight/weight-list/weight-list.component.htmlindex daf8d9bd5..aa8bf0183 100644--- a/angular/src/app/weight/weight-list/weight-list.component.html+++ b/angular/src/app/weight/weight-list/weight-list.component.html@@ -8,12 +8,12 @@<div class="row"><div class="col-12">-<ul *ngFor="let entry of weightEntries"- class="list-group">- <app-weight-detail [entry]="entry"></app-weight-detail>-</ul>+ <ul *ngFor="let entry of weightEntries"+ class="list-group">+ <app-weight-detail [entry]="entry"></app-weight-detail>+ </ul></div></div>-<button class="btn btn-primary" (click)="toggleForm()">Add entry</button>+<button class="btn btn-primary" (click)="toggleForm()" i18n>Add entry</button><app-weight-edit *ngIf="showForm"></app-weight-edit>diff --git a/angular/src/locale/messages.de.xlf b/angular/src/locale/messages.de.xlfnew file mode 100644index 000000000..1ec25bfd1--- /dev/null+++ b/angular/src/locale/messages.de.xlf@@ -0,0 +1,55 @@+<?xml version="1.0" encoding="UTF-8" ?>+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">+ <file source-language="en-US" datatype="plaintext" original="ng2.template">+ <body>+ <trans-unit id="7022070615528435141" datatype="html">+ <source>Delete</source>+ <target>Löschen</target>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-detail/weight-detail.component.html</context>+ <context context-type="linenumber">2</context>+ </context-group>+ </trans-unit>+ <trans-unit id="7585826646011739428" datatype="html">+ <source>Edit</source>+ <target>Bearbeiten</target>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-detail/weight-detail.component.html</context>+ <context context-type="linenumber">3</context>+ </context-group>+ </trans-unit>+ <trans-unit id="3973931101896534797" datatype="html">+ <source>Date</source>+ <target>Datum</target>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-edit/weight-edit.component.html</context>+ <context context-type="linenumber">5</context>+ </context-group>+ </trans-unit>+ <trans-unit id="5848348023107769657" datatype="html">+ <source>Weight</source>+ <target>Gewicht</target>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-edit/weight-edit.component.html</context>+ <context context-type="linenumber">14</context>+ </context-group>+ </trans-unit>+ <trans-unit id="3768927257183755959" datatype="html">+ <source>Save</source>+ <target>Speichern</target>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-edit/weight-edit.component.html</context>+ <context context-type="linenumber">27</context>+ </context-group>+ </trans-unit>+ <trans-unit id="2540594807548326286" datatype="html">+ <source>Add entry</source>+ <target>Eintrag hinzufügen</target>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-list/weight-list.component.html</context>+ <context context-type="linenumber">18</context>+ </context-group>+ </trans-unit>+ </body>+ </file>+</xliff>diff --git a/angular/src/locale/messages.xlf b/angular/src/locale/messages.xlfnew file mode 100644index 000000000..af6332134--- /dev/null+++ b/angular/src/locale/messages.xlf@@ -0,0 +1,49 @@+<?xml version="1.0" encoding="UTF-8" ?>+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">+ <file source-language="en-US" datatype="plaintext" original="ng2.template">+ <body>+ <trans-unit id="7022070615528435141" datatype="html">+ <source>Delete</source>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-detail/weight-detail.component.html</context>+ <context context-type="linenumber">2</context>+ </context-group>+ </trans-unit>+ <trans-unit id="7585826646011739428" datatype="html">+ <source>Edit</source>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-detail/weight-detail.component.html</context>+ <context context-type="linenumber">3</context>+ </context-group>+ </trans-unit>+ <trans-unit id="3973931101896534797" datatype="html">+ <source>Date</source>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-edit/weight-edit.component.html</context>+ <context context-type="linenumber">5</context>+ </context-group>+ </trans-unit>+ <trans-unit id="5848348023107769657" datatype="html">+ <source>Weight</source>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-edit/weight-edit.component.html</context>+ <context context-type="linenumber">14</context>+ </context-group>+ </trans-unit>+ <trans-unit id="3768927257183755959" datatype="html">+ <source>Save</source>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-edit/weight-edit.component.html</context>+ <context context-type="linenumber">27</context>+ </context-group>+ </trans-unit>+ <trans-unit id="2540594807548326286" datatype="html">+ <source>Add entry</source>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/weight/weight-list/weight-list.component.html</context>+ <context context-type="linenumber">18</context>+ </context-group>+ </trans-unit>+ </body>+ </file>+</xliff>diff --git a/angular/src/polyfills.ts b/angular/src/polyfills.tsindex ae5b7a704..a230c5aed 100644--- a/angular/src/polyfills.ts+++ b/angular/src/polyfills.ts@@ -1,3 +1,7 @@+/***************************************************************************************************+ * Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.+ */+import '@angular/localize/init';/*** This file includes polyfills needed by Angular and is loaded before the app.* You can add your own extra polyfills to this file.