Add Translations for the Language names and the Language Controller will retrieve it's files from a path instead of the classpath (ref #228)
This commit is contained in:
parent
63ac6df2ab
commit
d119a723f3
|
@ -8,6 +8,7 @@ import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
@ -27,11 +28,11 @@ public class LanguageController {
|
||||||
public ResponseEntity getLanguage(@PathVariable String lang) throws IOException {
|
public ResponseEntity getLanguage(@PathVariable String lang) throws IOException {
|
||||||
|
|
||||||
String fileName = this.environment.getProperty("language.path") + lang + ".json";
|
String fileName = this.environment.getProperty("language.path") + lang + ".json";
|
||||||
InputStream is = getClass().getClassLoader().getResource(fileName).openStream();
|
InputStream is = new FileInputStream(fileName);
|
||||||
|
|
||||||
HttpHeaders responseHeaders = new HttpHeaders();
|
HttpHeaders responseHeaders = new HttpHeaders();
|
||||||
responseHeaders.setContentLength(is.available());
|
responseHeaders.setContentLength(is.available());
|
||||||
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName);
|
responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName);
|
||||||
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
</button>
|
</button>
|
||||||
<mat-menu #languageMenu="matMenu">
|
<mat-menu #languageMenu="matMenu">
|
||||||
<button mat-menu-item *ngFor="let lang of languages" (click)="onLanguageSelected(lang)">
|
<button mat-menu-item *ngFor="let lang of languages" (click)="onLanguageSelected(lang)">
|
||||||
{{ lang.label }}
|
{{ lang.label | translate }}
|
||||||
</button>
|
</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
<mat-select placeholder="{{'USER-PROFILE.SETTINGS.LANGUAGE' | translate}}"
|
<mat-select placeholder="{{'USER-PROFILE.SETTINGS.LANGUAGE' | translate}}"
|
||||||
[formControl]="this.formGroup.get('language')" required>
|
[formControl]="this.formGroup.get('language')" required>
|
||||||
<mat-option *ngFor="let language of languages" [value]="language">
|
<mat-option *ngFor="let language of languages" [value]="language">
|
||||||
{{ language.label }}
|
{{ language.label | translate }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
|
@ -126,6 +126,11 @@
|
||||||
"XML": "XML",
|
"XML": "XML",
|
||||||
"JSON": "JSON",
|
"JSON": "JSON",
|
||||||
"DOC": "Document"
|
"DOC": "Document"
|
||||||
|
},
|
||||||
|
"LANGUAGES": {
|
||||||
|
"ENGLISH": "English",
|
||||||
|
"GREEK": "Greek",
|
||||||
|
"SPANISH": "Spanish"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"COOKIE": {
|
"COOKIE": {
|
||||||
|
|
|
@ -126,6 +126,11 @@
|
||||||
"XML": "XML",
|
"XML": "XML",
|
||||||
"JSON": "JSON",
|
"JSON": "JSON",
|
||||||
"DOC": "Document"
|
"DOC": "Document"
|
||||||
|
},
|
||||||
|
"LANGUAGES": {
|
||||||
|
"ENGLISH": "Inglés",
|
||||||
|
"GREEK": "Griego",
|
||||||
|
"SPANISH": "Espanol"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"COOKIE": {
|
"COOKIE": {
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
},
|
},
|
||||||
"ACTIONS": {
|
"ACTIONS": {
|
||||||
"LOG-IN": "Είσοδος"
|
"LOG-IN": "Είσοδος"
|
||||||
|
},
|
||||||
|
"LANGUAGES": {
|
||||||
|
"ENGLISH": "Αγγλικά",
|
||||||
|
"GREEK": "Ελληνικά",
|
||||||
|
"SPANISH": "Ισπανικά"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"label": "English",
|
"label": "GENERAL.LANGUAGES.ENGLISH",
|
||||||
"value": "en"
|
"value": "en"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Greek",
|
"label": "GENERAL.LANGUAGES.GREEK",
|
||||||
"value": "gr"
|
"value": "gr"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Spanish",
|
"label": "GENERAL.LANGUAGES.SPANISH",
|
||||||
"value": "es"
|
"value": "es"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue