-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[USH-1699] Identify unlocalized strings in the web client and add the…
…m to en.json (#1494) * Translations - Breadcrumbs * Translations - Login/Authentication * Translations: Post timelines, posts loading message, date shows up here text * Reverting timeline translations for now * Translation: OK Button, Uploading, Activty View * Translation: Data source subheading * Slight adjustment to solve 'Add webhook' json file conflicts * Translations: Survey & General Confirm Modal, snackbar, Survey Colorpicker, default settings header * Translations: Activity page * Translations: Adding more strings into en.json for map view options * Translations: Onboarding modals * Translations: Sources Filters * Translations: Timelines for post metadata and post conversations * Just a slight fix * Translations: showError() in survey-item, user-settings components and polling service * Translations: Close button in all snackbars * Translations: Location Select strings * Translations: Image uploader special characters text * Translations: Post edit component * Translations: Post not authorized to edit * Translations: Remaining strings * Renamed 'displayNane' to 'displayName'
- Loading branch information
1 parent
bf7bceb
commit 8d77d79
Showing
45 changed files
with
371 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 22 additions & 10 deletions
32
apps/web-mzima-client/src/app/core/pipes/date-ago.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,37 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { TranslateService } from '@ngx-translate/core'; | ||
|
||
@Pipe({ | ||
name: 'dateAgo', | ||
}) | ||
export class DateAgoPipe implements PipeTransform { | ||
constructor(private translate: TranslateService) {} | ||
transform(value: any): unknown { | ||
if (!value) { | ||
return 'a long time ago'; | ||
return this.translate.instant('date.aLongTimeAgo'); | ||
} | ||
let time = (Date.now() - Date.parse(value)) / 1000; | ||
if (time < 10) { | ||
return 'just now'; | ||
return this.translate.instant('date.justNow'); | ||
} else if (time < 60) { | ||
return 'a moment ago'; | ||
return this.translate.instant('date.aMomentAgo'); | ||
} | ||
const divider = [60, 60, 24, 30, 12]; | ||
const string = [' second', ' minute', ' hour', ' day', ' month', ' year']; | ||
let i; | ||
for (i = 0; Math.floor(time / divider[i]) > 0; i++) { | ||
time /= divider[i]; | ||
|
||
const dividers = [60, 60, 24, 30, 12]; | ||
const string = ['second', 'minute', 'hour', 'day', 'month', 'year']; | ||
let i = 0; | ||
|
||
// Calculate the appropriate unit | ||
while (i < dividers.length && Math.floor(time / dividers[i]) > 0) { | ||
time /= dividers[i]; | ||
i++; | ||
} | ||
const plural = Math.floor(time) > 1 ? 's' : ''; | ||
return Math.floor(time) + string[i] + plural + ' ago'; | ||
|
||
const roundedTime = Math.floor(time); | ||
const unit = string[i]; | ||
const pluralization = roundedTime > 1 ? 'plural' : 'singular'; | ||
|
||
// Translate the string based on singular/plural | ||
return this.translate.instant(`date.${unit}.${pluralization}`, { time: roundedTime }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.