Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta 1 dev #1262

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
=lang: fix language Core & Admin
  • Loading branch information
lemagnifick committed Jul 16, 2020
commit 497b2a640fb9553c50ecbfc3c076772fc76d28ec
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BasicInfoFormComponent implements OnInit, AfterViewInit {
constructor(
private readonly fb: FormBuilder,
private readonly _langTranslateService: TranslateService
) {}
) { }

get image() {
return this.form.get('image');
Expand All @@ -77,20 +77,11 @@ export class BasicInfoFormComponent implements OnInit, AfterViewInit {
case 'en-US':
return 'en-US';

case 'bg-BG':
return 'bg-BG';

case 'he-IL':
return 'he-IL';

case 'ru-RU':
return 'ru-RU';

case 'es-ES':
return 'es-ES';
case 'fr-FR':
return 'fr-FR';

default:
return 'en-US';
return 'fr-FR';
}
}

Expand All @@ -113,9 +104,9 @@ export class BasicInfoFormComponent implements OnInit, AfterViewInit {
({ locale, value }) => {
return locale === usedLanguage
? {
locale: usedLanguage,
value: this.name.value,
}
locale: usedLanguage,
value: this.name.value,
}
: { locale, value };
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,8 @@ export class ThemeSettingsComponent {
name: 'English',
},
{
value: 'bg-BG',
name: 'Bulgarian',
},
{
value: 'he-IL',
name: 'Hebrew',
},
{
value: 'ru-RU',
name: 'Russian',
},
{
value: 'es-ES',
name: 'Spanish',
value: 'fr-FR',
name: 'Francais',
},
];

Expand Down Expand Up @@ -64,7 +52,7 @@ export class ThemeSettingsComponent {
];

currentTheme = 'everlight';
defaultLanguage = '';
defaultLanguage = 'fr-FR';

constructor(
protected stateService: StateService,
Expand All @@ -73,17 +61,17 @@ export class ThemeSettingsComponent {
) {
this.defaultLanguage = environment['DEFAULT_LANGUAGE'];

translate.addLangs(['en-US', 'bg-BG', 'he-IL', 'ru-RU', 'es-ES']);
translate.setDefaultLang('en-US');
translate.addLangs(['en-US', 'fr-FR']);
translate.setDefaultLang('fr-FR');

const browserLang = translate.getBrowserLang();
if (this.defaultLanguage) {
translate.use(this.defaultLanguage);
} else {
translate.use(
browserLang.match(/en-US|bg-BG|he-IL|ru-RU|es-ES/)
browserLang.match(/en-US|fr-FR/)
? browserLang
: 'en-US'
: 'fr-FR'
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,8 @@ export class ProductComponent implements OnInit, OnDestroy {
switch (langAbbreviation) {
case 'en-US':
return 'English';
case 'bg-BG':
return 'Български';
case 'he-IL':
return 'עברית';
case 'ru-RU':
return 'Русский';
case 'es-ES':
return 'Spanish';
case 'fr-FR':
return 'Francais';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ServerDownPage implements OnDestroy {
private serverConnectionService: ServerConnectionService
) {
const browserLang = translate.getBrowserLang();
translate.use(browserLang.match(/en|bg|he|ru/) ? browserLang : 'en-US');
translate.use(browserLang.match(/en|fr/) ? browserLang : 'fr-FR');

this.noInternetLogo = environment['NO_INTERNET_LOGO'];
this.testConnection();
Expand Down
14 changes: 3 additions & 11 deletions packages/common-angular/src/locale/product-locales.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ProductLocalesService {

public currentLocale: string;

constructor(private readonly _translateService: TranslateService) {}
constructor(private readonly _translateService: TranslateService) { }

public get isServiceStateValid() {
return (
Expand Down Expand Up @@ -103,16 +103,8 @@ export class ProductLocalesService {
case 'en-US':
translateLang = 'en-US';
break;
case 'he-IL':
translateLang = 'he-IL';
break;
case 'ru-RU':
translateLang = 'ru-RU';
break;
case 'bg-BG':
translateLang = 'bg-BG';
case 'es-ES':
translateLang = 'es-ES';
case 'fr-FR':
translateLang = 'fr-FR';
break;
}
return translateLang;
Expand Down
4 changes: 1 addition & 3 deletions packages/common/src/consts/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ export class Consts {
static get langAbbreviations() {
return {
en: 'en',
bg: 'bg',
he: 'he',
ru: 'ru',
fr: 'fr',
};
}
}
1 change: 1 addition & 0 deletions packages/common/src/entities/Currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ export const countriesDefaultCurrencies = {
RU: 'RUB',
US: 'USD',
BG: 'BGN',
CM: 'XAF',
};
83 changes: 9 additions & 74 deletions packages/common/src/entities/Order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,8 @@ class Order extends DBObject<IOrder, IOrderCreateObject> implements IOrder {
switch (language) {
case 'en-US':
return this._getStatusTextEnglish();
case 'he-IL':
return this._getStatusTextHebrew();
case 'ru-RU':
return this._getStatusTextRussian();
case 'bg-BG':
return this._getStatusTextBulgarian();
case 'es-ES':
return this._getStatusTextSpanish();
case 'fr-FR':
return this._getStatusTextFrench();
default:
return 'BAD_STATUS';
}
Expand Down Expand Up @@ -380,85 +374,26 @@ class Order extends DBObject<IOrder, IOrderCreateObject> implements IOrder {
}
}

private _getStatusTextBulgarian(): string {
private _getStatusTextFrench(): string {
switch (this.status) {
case OrderStatus.WarehousePreparation:
return 'Подготовка';
case OrderStatus.InDelivery:
return 'Доставя се';
case OrderStatus.Delivered:
return 'Доставено';
case OrderStatus.CanceledWhileWarehousePreparation:
case OrderStatus.CanceledWhileInDelivery:
return 'Отказана';
case OrderStatus.WarehouseIssue:
return 'Проблем при подготовката';
case OrderStatus.CarrierIssue:
return 'Проблем при доставката';
default:
return 'Проблем с поръчката';
}
}

private _getStatusTextHebrew(): string {
switch (this.status) {
case OrderStatus.WarehousePreparation:
return 'בהכנה';
case OrderStatus.InDelivery:
return 'במשלוח';
case OrderStatus.Delivered:
return 'הסתיים בצלחה';
case OrderStatus.CanceledWhileWarehousePreparation:
case OrderStatus.CanceledWhileInDelivery:
return 'התבטל';
case OrderStatus.WarehouseIssue:
return 'בעייה בהכנה';
case OrderStatus.CarrierIssue:
return 'בעייה במשלוח';
default:
return 'BAD_STATUS';
}
}

private _getStatusTextRussian(): string {
switch (this.status) {
case OrderStatus.WarehousePreparation:
return 'В подготовке';
return 'Preparation';
case OrderStatus.InDelivery:
return 'В доставки';
return 'In Delivery';
case OrderStatus.Delivered:
return 'Доставлено';
return 'Delivered';
case OrderStatus.CanceledWhileWarehousePreparation:
case OrderStatus.CanceledWhileInDelivery:
return 'Отменено';
return 'Cancelled';
case OrderStatus.WarehouseIssue:
return 'Проблема с подготовкой';
return 'Preparation Issue';
case OrderStatus.CarrierIssue:
return 'Проблема с доставкой';
return 'Delivery Issue';
default:
return 'BAD_STATUS';
}
}

private _getStatusTextSpanish() {
switch (this.status) {
case OrderStatus.WarehousePreparation:
return 'Preparación';
case OrderStatus.InDelivery:
return 'En la entrega';
case OrderStatus.Delivered:
return 'Entregado';
case OrderStatus.CanceledWhileWarehousePreparation:
case OrderStatus.CanceledWhileInDelivery:
return 'Cancelado';
case OrderStatus.WarehouseIssue:
return 'Problema de preparación';
case OrderStatus.CarrierIssue:
return 'Problema de envio';
default:
return 'BAD_STATUS';
}
}
}

export default Order;
1 change: 0 additions & 1 deletion packages/core/res/views/about_us_bg.hbs

This file was deleted.

1 change: 1 addition & 0 deletions packages/core/res/views/about_us_fr.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{> about_us/fr-FR }}
1 change: 0 additions & 1 deletion packages/core/res/views/privacy_bg.hbs

This file was deleted.

1 change: 1 addition & 0 deletions packages/core/res/views/privacy_fr.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{> privacy/fr-FR }}
1 change: 0 additions & 1 deletion packages/core/res/views/terms_of_use_bg.hbs

This file was deleted.

1 change: 1 addition & 0 deletions packages/core/res/views/terms_of_use_fr.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{> terms_of_use/fr-FR }}
4 changes: 1 addition & 3 deletions packages/core/src/graphql/devices/devices.types.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ type Subscription {
}

enum Language {
he_IL
en_US
ru_RU
bg_BG
fr_FR
}
40 changes: 12 additions & 28 deletions packages/core/src/services/services.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ export class ServicesApp {
this.db.close(() => {
this.log.info(
'Mongoose default connection with DB :' +
this.db_server +
' is disconnected through app termination'
this.db_server +
' is disconnected through app termination'
);
process.exit(0);
});
Expand Down Expand Up @@ -199,16 +199,16 @@ export class ServicesApp {
this.db.on('disconnected', () => {
this.log.warn(
'Mongoose default connection to DB :' +
this.db_server +
' disconnected'
this.db_server +
' disconnected'
);
});

this.db.on('connected', () => {
this.log.info(
'Mongoose default connection to DB :' +
this.db_server +
' connected'
this.db_server +
' connected'
);
});
}
Expand Down Expand Up @@ -570,40 +570,24 @@ export class ServicesApp {
res.render('about_us_en');
});

this.expressApp.get('/he/about', function (req, res) {
res.render('about_us_he');
});

this.expressApp.get('/ru/about', function (req, res) {
res.render('about_us_ru');
this.expressApp.get('/fr/about', function (req, res) {
res.render('about_us_fr');
});

this.expressApp.get('/en/privacy', function (req, res) {
res.render('privacy_en');
});

this.expressApp.get('/he/privacy', function (req, res) {
res.render('privacy_he');
});

this.expressApp.get('/ru/privacy', function (req, res) {
res.render('privacy_ru');
this.expressApp.get('/fr/privacy', function (req, res) {
res.render('privacy_fr');
});

this.expressApp.get('/en/terms', function (req, res) {
res.render('terms_of_use_en');
});

this.expressApp.get('/he/terms', function (req, res) {
res.render('terms_of_use_he');
});

this.expressApp.get('/ru/terms', function (req, res) {
res.render('terms_of_use_ru');
});

this.expressApp.get('/bg/terms', function (req, res) {
res.render('terms_of_use_bg');
this.expressApp.get('/fr/terms', function (req, res) {
res.render('terms_of_use_fr');
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/services/users/UsersService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export class UsersService extends DBService<User>
['aboutUs', 'privacy', 'termsOfUse'],
_.map(['about_us', 'privacy', 'terms_of_use'], (folder) =>
_.zipObject(
['en-US', 'he-IL', 'ru-RU', 'bg-BG'],
_.map(['en-US', 'he-IL', 'ru-RU', 'bg-BG'], (language) =>
['en-US', 'fr-FR'],
_.map(['en-US', 'fr-FR'], (language) =>
observeFile(
`${__dirname}/../../../../res/templates/${folder}/${language}.hbs`
).pipe(
Expand Down