From 7a791ace4d6b2bf31548c7018fcdeefb454dd12f Mon Sep 17 00:00:00 2001 From: Przemek Wiech Date: Wed, 6 Mar 2019 23:33:54 +0100 Subject: [PATCH] Translating tags on the details panel --- src/details.tsx | 41 ++++++++++++++++++++++++++++++---------- src/translations/pl.json | 11 ++++++++++- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/details.tsx b/src/details.tsx index 1aff637..f5af841 100644 --- a/src/details.tsx +++ b/src/details.tsx @@ -1,13 +1,38 @@ import * as React from 'react'; import {GedcomData} from './gedcom_util'; import {GedcomEntry} from 'parse-gedcom'; +import {FormattedMessage} from 'react-intl'; interface Props { gedcom: GedcomData; indi: string; } -function eventDetails(entry: GedcomEntry, header: string) { +const NAME_TAGS = ['NAME']; +const EVENT_TAGS = ['BIRT', 'BAPM', 'CHR', 'DEAT', 'BURI']; +const DATA_TAGS = ['TITL', 'OCCU', 'WWW', 'EMAIL']; +const TAG_DESCRIPTIONS = new Map([ + ['BAPM', 'Baptism'], + ['BIRT', 'Birth'], + ['BURI', 'Burial'], + ['CHR', 'Christening'], + ['DEAT', 'Death'], + ['EMAIL', 'E-mail'], + ['OCCU', 'Occupation'], + ['TITL', 'Title'], + ['WWW', 'WWW'], +]); + +function translateTag(tag: string) { + return ( + + ); +} + +function eventDetails(entry: GedcomEntry, tag: string) { const lines = []; const date = entry.tree.find((subentry) => subentry.tag === 'DATE'); if (date && date.data) { @@ -27,7 +52,7 @@ function eventDetails(entry: GedcomEntry, header: string) { } return ( <> -
{header}
+
{translateTag(tag)}
{lines.map((line) => ( <> @@ -40,7 +65,7 @@ function eventDetails(entry: GedcomEntry, header: string) { ); } -function dataDetails(entry: GedcomEntry, header: string) { +function dataDetails(entry: GedcomEntry, tag: string) { const lines = []; if (entry.data) { lines.push(entry.data); @@ -55,7 +80,7 @@ function dataDetails(entry: GedcomEntry, header: string) { } return ( <> -
{header}
+
{translateTag(tag)}
{lines.map((line) => ( <> @@ -68,7 +93,7 @@ function dataDetails(entry: GedcomEntry, header: string) { ); } -function nameDetails(entry: GedcomEntry, header: string) { +function nameDetails(entry: GedcomEntry, tag: string) { return (

{entry.data @@ -87,7 +112,7 @@ function nameDetails(entry: GedcomEntry, header: string) { function getDetails( entries: GedcomEntry[], tags: string[], - detailsFunction: (entry: GedcomEntry, header: string) => JSX.Element | null, + detailsFunction: (entry: GedcomEntry, tag: string) => JSX.Element | null, ): JSX.Element[] { return tags .flatMap((tag) => @@ -99,10 +124,6 @@ function getDetails( .map((element) =>
{element}
); } -const NAME_TAGS = ['NAME']; -const EVENT_TAGS = ['BIRT', 'BAPM', 'CHR', 'DEAT', 'BURI']; -const DATA_TAGS = ['TITL', 'OCCU', 'WWW', 'EMAIL']; - export class Details extends React.Component { render() { const entries = this.props.gedcom.indis[this.props.indi].tree; diff --git a/src/translations/pl.json b/src/translations/pl.json index 51c2d92..f31b195 100644 --- a/src/translations/pl.json +++ b/src/translations/pl.json @@ -17,5 +17,14 @@ "load_from_url.title": "Otwórz z adresu URL", "load_from_url.comment": "Dane z podanego adresu URL zostaną załadowane poprzez usługę {link} w celu uniknięcia problemów z CORS.", "load_from_url.cancel": "Anuluj", - "load_from_url.load": "Otwórz" + "load_from_url.load": "Otwórz", + "gedcom.BAPM": "Chrzest", + "gedcom.BIRT": "Narodziny", + "gedcom.BURI": "Pogrzeb", + "gedcom.CHR": "Chrzest", + "gedcom.DEAT": "Śmierć", + "gedcom.EMAIL": "E-mail", + "gedcom.OCCU": "Zawód", + "gedcom.TITL": "Tytuł", + "gedcom.WWW": "Strona WWW" }