Skip to content

Commit

Permalink
chore: Translate birthday
Browse files Browse the repository at this point in the history
Untested, Rebased exclusive feature.
  • Loading branch information
null2264 committed Oct 26, 2023
1 parent cd2f8b7 commit ec246d6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 28 deletions.
15 changes: 14 additions & 1 deletion src/locales/en-US/app.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
# - MenuItem
# ID convention: "module-ComponentName--string-summary--MenuItem"
# Formatting: <icon></icon><wrapper>TEXT GOES HERE!</wrapper><emblem></emblem>
# - Icon
# ID convention: "module-ComponentName--string-summary--Icon"
# Formatting: <icon></icon>TEXT GOES HERE!

### Terms
# You don't need to add every new term here, just add if needed (e.g. the term is commonly used).
-back =
{ $case ->
*[title] Back
Expand Down Expand Up @@ -56,9 +60,18 @@ ui-CardHeader--back =
account-Badge--admin = Admin
account-Badge--bot = Bot
account-Badge--moderator = Moderator
-birthday-date =
{ $suffix ->
*[icon] <icon></icon>{ DATETIME($date, year: "numeric", month: "short", day: "numeric") }
[text] Born { DATETIME($date, year: "numeric", month: "short", day: "numeric") }
}
account-Birthday--date--Icon = { -birthday-date(suffix: "icon") }
.title = { -birthday-date(suffix: "text") }
account-Birthday--date = { -birthday-date(suffix: "text") }
.title = { -birthday-date(suffix: "text") }
account-Birthday--celebration = Birthday is today!
account-Header--manage-list--MenuItem = <icon></icon><wrapper>Add or Remove from lists</wrapper><emblem></emblem>
account-birthday = Born { $date }
account-birthday-today = Birthday is today!
account-block = Block @{ $name }
account-block-domain = Hide everything from { $domain }
Expand Down
10 changes: 10 additions & 0 deletions src/locales/id-ID/app.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ ui-CardHeader--back =

# Components that related to Account such as profile, hover card.

-birthday-date =
{ $suffix ->
*[icon] <icon></icon>{ DATETIME($date, year: "numeric", month: "short", day: "numeric") }
[text] Lahir tanggal { DATETIME($date, year: "numeric", month: "short", day: "numeric") }
}
account-Birthday--date--Icon = { -birthday-date(suffix: "icon") }
.title = { -birthday-date(suffix: "text") }
account-Birthday--date = { -birthday-date(suffix: "text") }
.title = { -birthday-date(suffix: "text") }
account-Birthday--celebration = Lahir hari ini!
account-Header--manage-list--MenuItem = <icon></icon><wrapper>Tambah atau Hapus dari daftar</wrapper><emblem></emblem>
account-birthday = Born { $date }
Expand Down
12 changes: 10 additions & 2 deletions src/locales/ja-JP/app.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ ui-CardHeader--back =

# Components that related to Account such as profile, hover card.

-birthday-date =
{ $suffix ->
*[icon] <icon></icon>{ DATETIME($date, year: "numeric", month: "short", day: "numeric") }
[text] 生年月日 { DATETIME($date, year: "numeric", month: "short", day: "numeric") }
}
account-Birthday--date--Icon = { -birthday-date(suffix: "icon") }
.title = { -birthday-date(suffix: "text") }
account-Birthday--date = { -birthday-date(suffix: "text") }
.title = { -birthday-date(suffix: "text") }
account-Birthday--celebration = 本日は誕生日です!
account-Header--manage-list--MenuItem = <icon></icon><wrapper>リストから追加または外す</wrapper><emblem></emblem>
account-birthday = Born { $date }
account-birthday-today = Birthday is today!
account-block = Block @{ $name }
account-block-domain = Hide everything from { $domain }
account-blocked = Blocked
Expand Down
32 changes: 16 additions & 16 deletions src/soapbox/features/birthdays/account.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import { Localized } from '@fluent/react';
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';

import { useAccount } from 'soapbox/api/hooks';
import AccountComponent from 'soapbox/components/account';
import Icon from 'soapbox/components/icon';
import { HStack } from 'soapbox/components/ui';

const messages = defineMessages({
birthday: { id: 'account.birthday', defaultMessage: 'Born {date}' },
});

interface IAccount {
accountId: string
}

const Account: React.FC<IAccount> = ({ accountId }) => {
const intl = useIntl();
const { account } = useAccount(accountId);

if (!account) return null;

const birthday = account.pleroma?.birthday;
if (!birthday) return null;

const formattedBirthday = intl.formatDate(birthday, { day: 'numeric', month: 'short', year: 'numeric' });

return (
<HStack space={1} alignItems='center' justifyContent='between' className='p-2.5'>
<div className='w-full'>
<AccountComponent account={account} withRelationship={false} />
</div>
<div
className='flex items-center gap-0.5'
title={intl.formatMessage(messages.birthday, {
date: formattedBirthday,
})}
{/* TODO: Test this, Akkoma don't have birthday feature */}
<Localized
id='account-Birthday--date--Icon'
vars={{ date: birthday }}
attrs={{ title: true }}
elems={{
icon: <Icon src={require('@tabler/icons/balloon.svg')} />,
}}
>
<Icon src={require('@tabler/icons/balloon.svg')} />
{formattedBirthday}
</div>
<div
className='flex items-center gap-0.5'
title={'Born $date'}
>
{'<icon></icon>$date'}
</div>
</Localized>
</HStack>
);
};
Expand Down
18 changes: 9 additions & 9 deletions src/soapbox/features/ui/components/profile-info-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ const ProfileInfoPanel: React.FC<IProfileInfoPanel> = ({ account, username }) =>
const birthday = account?.pleroma?.birthday;
if (!birthday) return null;

const formattedBirthday = intl.formatDate(birthday, { timeZone: 'UTC', day: 'numeric', month: 'long', year: 'numeric' });

const date = new Date(birthday);
const today = new Date();

Expand All @@ -107,13 +105,15 @@ const ProfileInfoPanel: React.FC<IProfileInfoPanel> = ({ account, username }) =>
className='h-4 w-4 text-gray-800 dark:text-gray-200'
/>

<Text size='sm'>
{hasBirthday ? (
<FormattedMessage id='account.birthday_today' defaultMessage='Birthday is today!' />
) : (
<FormattedMessage id='account.birthday' defaultMessage='Born {date}' values={{ date: formattedBirthday }} />
)}
</Text>
{/* TODO: Test this, Akkoma don't have birthday feature */}
<Localized
id={'account-Birthday--' + (hasBirthday ? 'celebration' : 'date')}
vars={{ date: birthday }}
>
<Text size='sm'>
{'Birthday'}
</Text>
</Localized>
</HStack>
);
};
Expand Down

0 comments on commit ec246d6

Please sign in to comment.