Browse Source

feat: i18n stuff

master
Konstantinos Kamaropoulos 5 years ago
parent
commit
89fcfb9892
  1. 1
      src/app/chart/chart.component.html
  2. 6
      src/app/chart/chart.component.scss
  3. 3
      src/app/chart/chart.component.ts
  4. 6
      src/app/core/i18n.service.spec.ts
  5. 4
      src/app/core/i18n.service.ts
  6. 10
      src/app/shell/header/header.component.html
  7. 2
      src/environments/environment.prod.ts
  8. 2
      src/environments/environment.ts
  9. 10
      src/translations/el-GR.json
  10. 9
      src/translations/en-US.json
  11. 7
      src/translations/fr-FR.json

1
src/app/chart/chart.component.html

@ -1 +1,2 @@
<h1 class="chartTitle">{{ 'ChartTitle' | translate }}</h1>
<div id="chartContainer" style="height: 85vh; width: 100%; margin-left:auto;margin-right:auto;"></div>

6
src/app/chart/chart.component.scss

@ -0,0 +1,6 @@
.chartTitle {
font-size: 28px;
text-align: center;
font-weight: 600;
padding-bottom: 10px;
}

3
src/app/chart/chart.component.ts

@ -52,9 +52,6 @@ export class ChartComponent implements OnInit {
zoomEnabled: true,
animationEnabled: true,
exportEnabled: true,
title: {
text: 'Sensor Readings'
},
axisX: {
scaleBreaks: {
autoCalculate: true

6
src/app/core/i18n.service.spec.ts

@ -5,7 +5,7 @@ import { Subject } from 'rxjs';
import { extract, I18nService } from './i18n.service';
const defaultLanguage = 'en-US';
const supportedLanguages = ['eo', 'en-US', 'fr-FR'];
const supportedLanguages = ['eo', 'en-US', 'el-GR'];
class MockTranslateService {
currentLang = '';
@ -105,8 +105,8 @@ describe('I18nService', () => {
i18nService.language = newLanguage;
// Assert
expect(translateService.use).toHaveBeenCalledWith('fr-FR');
expect(onLangChangeSpy).toHaveBeenCalledWith('fr-FR');
expect(translateService.use).toHaveBeenCalledWith('el-GR');
expect(onLangChangeSpy).toHaveBeenCalledWith('el-GR');
});
it('should change current language to default if unsupported', () => {

4
src/app/core/i18n.service.ts

@ -4,7 +4,7 @@ import { Subscription } from 'rxjs';
import { Logger } from './logger.service';
import enUS from '../../translations/en-US.json';
import frFR from '../../translations/fr-FR.json';
import elGR from '../../translations/el-GR.json';
const log = new Logger('I18nService');
const languageKey = 'language';
@ -31,7 +31,7 @@ export class I18nService {
constructor(private translateService: TranslateService) {
// Embed languages to avoid extra HTTP requests
translateService.setTranslation('en-US', enUS);
translateService.setTranslation('fr-FR', frFR);
translateService.setTranslation('el-GR', elGR);
}
/**

10
src/app/shell/header/header.component.html

@ -15,18 +15,18 @@
<div class="navbar-nav">
<a class="nav-item nav-link text-uppercase" routerLink="/home" routerLinkActive="active">
<i class="fas fa-home"></i>
<span translate> Home</span>
&nbsp;<span translate>Home</span>
</a>
<a class="nav-item nav-link text-uppercase" routerLink="/map" routerLinkActive="active">
<i class="fas fa-map"></i>
<span translate> Map</span>
&nbsp;<span translate>Map</span>
</a>
<a class="nav-item nav-link text-uppercase" routerLink="/chart" routerLinkActive="active">
<i class="fas fa-chart-area"></i>
<span translate> Chart</span>
&nbsp;<span translate>Chart</span>
</a>
</div>
<!-- <div class="navbar-nav ml-auto">
<div class="navbar-nav ml-auto">
<div class="nav-item" ngbDropdown display="dynamic" placement="bottom-right">
<a id="language-dropdown" class="nav-link" ngbDropdownToggle>{{ currentLanguage }}</a>
<div ngbDropdownMenu aria-labelledby="language-dropdown">
@ -35,7 +35,7 @@
</button>
</div>
</div>
</div> -->
</div>
</div>
</nav>
</header>

2
src/environments/environment.prod.ts

@ -12,5 +12,5 @@ export const environment = {
version: env.npm_package_version,
serverUrl: 'https://api.chucknorris.io',
defaultLanguage: 'en-US',
supportedLanguages: ['en-US', 'fr-FR']
supportedLanguages: ['en-US', 'el-GR']
};

2
src/environments/environment.ts

@ -16,7 +16,7 @@ export const environment = {
version: env.npm_package_version + '-dev',
serverUrl: '/api',
defaultLanguage: 'en-US',
supportedLanguages: ['en-US', 'fr-FR'],
supportedLanguages: ['en-US', 'el-GR'],
mapbox: {
accessToken: 'pk.eyJ1Ijoia2FtYXJvcG91bG9zIiwiYSI6ImNrNzN0dzBxcjAxbzUza3Bhb2Jnd2c2cWIifQ.7CvFsos8lOlKopFajrf2FA'
}

10
src/translations/el-GR.json

@ -0,0 +1,10 @@
{
"APP_NAME": "Αίολος",
"Home": "Αρχικη",
"Map": "Χαρτης",
"Chart": "Γραφημα",
"Home | Aiolos": "Αρχική | Αίολος",
"Map | Aiolos": "Χάρτης | Αίολος",
"Chart | Aiolos": "Γράφημα | Αίολος",
"ChartTitle": "Μετρήσεις Αισθητήρων"
}

9
src/translations/en-US.json

@ -1,7 +1,10 @@
{
"APP_NAME": "Aiolos",
"About": "About",
"Hello world !": "Hello world !",
"Home": "Home",
"Version": "Version"
"Map": "Map",
"Chart": "Chart",
"Home | Aiolos": "Home | Aiolos",
"Map | Aiolos": "Map | Aiolos",
"Chart | Aiolos": "Chart | Aiolos",
"ChartTitle": "Sensor Readings"
}

7
src/translations/fr-FR.json

@ -1,7 +0,0 @@
{
"APP_NAME": "Aiolos",
"About": "A propos",
"Hello world !": "Bonjour le monde !",
"Home": "Accueil",
"Version": "Version"
}
Loading…
Cancel
Save