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

feat: HTSFA-890 - Improve the quality of the internationalization #57

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions projects/angular-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<a name="6.3.3"></a>
<a name="6.3.5"></a>

# 6.3.3 (2024-05-06)
# 6.3.5 (2024-05-21)

- Various improvements in label management.

<a name="6.3.4"></a>

# 6.3.4 (2024-05-06)

- Fix for datadog.

Expand Down
2 changes: 1 addition & 1 deletion projects/angular-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hopper-cloud-airlines/angular-sdk",
"version": "6.3.4",
"version": "6.3.5",
"license": "Apache-2.0",
"author": {
"name": "HTS - Airlines Team",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ <h4 class="offer-title m-0">
: offer?.currency
: 'symbol'
: undefined
: currentLang)
: currentCulturalLang)
}
}}
"
Expand Down Expand Up @@ -171,7 +171,7 @@ <h4 class="offer-title m-0">
: offer?.currency
: 'symbol'
: undefined
: currentLang)
: currentCulturalLang)
}
}}"
innerHtml="{{
Expand All @@ -184,7 +184,7 @@ <h4 class="offer-title m-0">
: offer?.currency
: 'symbol'
: undefined
: currentLang)
: currentCulturalLang)
}
}}"
></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h2>{{ 'CFAR_OFFER_DIALOG.TITLE' | translate }}</h2>
: offer?.currency
: 'symbol'
: undefined
: currentLang)
: currentCulturalLang)
}
}}
"
Expand All @@ -120,7 +120,7 @@ <h2>{{ 'CFAR_OFFER_DIALOG.TITLE' | translate }}</h2>
: offer?.currency
: 'symbol'
: undefined
: currentLang)
: currentCulturalLang)
}
}}
"
Expand All @@ -143,7 +143,7 @@ <h2>{{ 'CFAR_OFFER_DIALOG.TITLE' | translate }}</h2>
: offer?.currency
: 'symbol'
: undefined
: currentLang)
: currentCulturalLang)
}
}}
"
Expand All @@ -168,7 +168,7 @@ <h2>{{ 'CFAR_OFFER_DIALOG.TITLE' | translate }}</h2>
: offer?.currency
: 'symbol'
: undefined
: currentLang)
: currentCulturalLang)
}
}}"
innerHtml="{{
Expand All @@ -181,7 +181,7 @@ <h2>{{ 'CFAR_OFFER_DIALOG.TITLE' | translate }}</h2>
: offer?.currency
: 'symbol'
: undefined
: currentLang)
: currentCulturalLang)
}
}}"
></div>
Expand Down
27 changes: 23 additions & 4 deletions projects/angular-sdk/src/components/global.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class GlobalComponent implements OnChanges {
@Input() isFakeBackend?: boolean;
@Input() env?: string;

public currentCulturalLang!: string;

@Output() errorOccurred = new EventEmitter();

public errorCode?: string;
Expand Down Expand Up @@ -91,6 +93,8 @@ export class GlobalComponent implements OnChanges {
}

protected _updateLanguage(newLanguage: string): void {
this.currentCulturalLang = this._getCulturalLangFromLang(newLanguage);

// Set language for components
this._translateService.use(newLanguage);

Expand Down Expand Up @@ -393,10 +397,6 @@ export class GlobalComponent implements OnChanges {
return '';
}

// *********************
// Errors
// *********************

public handleApiError(error: any, errorEndPoint: string) {
const builtError = this._getHcAirlinesErrorResponse(error);

Expand Down Expand Up @@ -454,4 +454,23 @@ export class GlobalComponent implements OnChanges {
});
}
}

// -----------------------------------------------
// Privates Methods
// -----------------------------------------------

private _getCulturalLangFromLang(lang: string): string {
let result = 'en_US';

switch(lang) {
case 'fr':
result = 'fr_CA';
break;
case 'zh':
result = 'zh_CN';
break;
}

return result;
}
}
7 changes: 2 additions & 5 deletions projects/angular-sdk/src/i18n/i18n-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ export const I18N_SCHEMA = {
},
DATE: {
type: 'string',
},
HOUR_AND_DATE: {
type: 'string',
},
}
},
required: ['HOUR', 'DATE', 'HOUR_AND_DATE'],
required: ['HOUR', 'DATE'],
},
BUTTON: {
type: 'object',
Expand Down
6 changes: 3 additions & 3 deletions projects/angular-sdk/src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// http://www.loc.gov/standards/iso639-2/php/code_list.php

import * as English from './locales/en.json';
import * as French from './locales/fr.json';
import * as Chinese from './locales/zh.json';
import * as English from './locales/en/common.json';
import * as French from './locales/fr/common.json';
import * as Chinese from './locales/zh/common.json';

// Availables Languages
export const Locales: Map<string, Object> = new Map<string, Object>([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"COMMON": {
"DATE_FORMAT": {
"HOUR": "hh:mm a",
"DATE": "ddMMM",
"HOUR_AND_DATE": "EEEE, MMMM d, y, h:mm a z"
"DATE": "ddMMM"
},
"BUTTON": {
"CLOSE": "Close"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"COMMON": {
"DATE_FORMAT": {
"HOUR": "hh:mm a",
"DATE": "ddMMM",
"HOUR_AND_DATE": "EEEE d MMMM y à H:mm z"
"DATE": "ddMMM"
},
"BUTTON": {
"CLOSE": "Fermer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"COMMON": {
"DATE_FORMAT": {
"HOUR": "hh:mm a",
"DATE": "ddMMM",
"HOUR_AND_DATE": "EEEE, MMMM d, y, h:mm a z"
"DATE": "ddMMM"
},
"BUTTON": {
"CLOSE": "关"
Expand Down
Loading