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

Fix header for JP language #1407

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/common/language/language.service.ts
Expand Up @@ -235,6 +235,13 @@ export class LanguageService {
return `&lang=${this.currentLanguage}`;
}

public shouldPlacePrepositionsAfter(): boolean {
// In Japanese, many prepositions like "of" or "in" must be placed after the word
// instead of before. So instead of "A of B", in Japanese you must say
// "B {{ 'of' | translate }} A".
return this.currentLanguage === 'ja';
}

private processTranslation(observer: Observer<any>, translations: any, key: string | string[]): void {
if (typeof key === 'string') {
observer.next(translations[key as string]);
Expand Down
15 changes: 11 additions & 4 deletions src/shared/header/header.component.html
Expand Up @@ -32,17 +32,24 @@ <h2 #headerTitle class="header-title heading pull-left"></h2>
class="filters-container"
[ngStyle]="{visibility: ((isCountryFilterReady && isThingFilterReady) || (isMapPage && isThingFilterReady)) ? 'visible' : 'hidden'}">

<things-filter (isFilterGotData)="isFilterGotData($event)"></things-filter>

<span *ngIf="isMapPage"
<span *ngIf="(isMapPage && shouldPlacePrepositionsAfter)"
class="map-things-text">{{ 'ON_THE_WORLD_MAP' | translate }}</span>
<things-filter *ngIf="!isMatrixPage" (isFilterGotData)="isFilterGotData($event)"></things-filter>
<span *ngIf="(isMapPage && !shouldPlacePrepositionsAfter)"
class="map-things-text">{{ 'ON_THE_WORLD_MAP' | translate }}</span>

<div *ngIf="isMatrixPage"
class="some-filter-container incomeby">
<span class="mobile-ver">{{ 'IN' | translate }}</span>
<things-filter *ngIf="!shouldPlacePrepositionsAfter" (isFilterGotData)="isFilterGotData($event)"></things-filter>

<span *ngIf="!shouldPlacePrepositionsAfter" class="mobile-ver">{{ 'IN' | translate }}</span>

<countries-filter (isFilterGotData)="isFilterGotData($event)"></countries-filter>

<span *ngIf="shouldPlacePrepositionsAfter" class="mobile-ver">{{ 'IN' | translate }}</span>

<things-filter *ngIf="shouldPlacePrepositionsAfter" (isFilterGotData)="isFilterGotData($event)"></things-filter>

<span #incomeTitleContainer
class="income-title-container">
<!--<span class="income-title filter"
Expand Down
2 changes: 2 additions & 0 deletions src/shared/header/header.component.ts
Expand Up @@ -122,6 +122,7 @@ export class HeaderComponent implements OnDestroy, AfterViewInit, OnInit {
incomeTitleText: string;
isIncomeFilter: boolean;
ngSubscriptions: SubscriptionsList = {};
shouldPlacePrepositionsAfter: boolean;
private headerTitle: ElementRef;

constructor(elementRef: ElementRef,
Expand Down Expand Up @@ -278,6 +279,7 @@ export class HeaderComponent implements OnDestroy, AfterViewInit, OnInit {
this.ngSubscriptions.combileTranslations = fromEvent(this.languageService.translationsLoadedEvent, this.languageService.translationsLoadedString)
.subscribe(( trans: TranslationsInterface ) => {
this.getTranslations(trans)
this.shouldPlacePrepositionsAfter = this.languageService.shouldPlacePrepositionsAfter();
});

this.ngSubscriptions.routerEvents = this.router.events.subscribe( event => {
Expand Down