Skip to content

Commit

Permalink
Merge pull request #1526 from h3poteto/feat/emoji-picker-locale
Browse files Browse the repository at this point in the history
refs #1375 Set locale for emoji picker
  • Loading branch information
h3poteto authored Jul 5, 2024
2 parents 4e4e2b1 + d3247ee commit 35674a8
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/components/compose/Compose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const renderAccountIcon = (props: any, ref: any, account: [Account, Serve
type Props = {
setOpened: (value: boolean) => void
servers: Array<ServerSet>
locale: string
}

const Compose: React.FC<Props> = props => {
Expand Down Expand Up @@ -127,6 +128,7 @@ const Compose: React.FC<Props> = props => {
defaultVisibility={defaultVisibility}
defaultNSFW={defaultNSFW}
defaultLanguage={defaultLanguage}
locale={props.locale}
/>
)}
</Content>
Expand Down
4 changes: 4 additions & 0 deletions src/components/compose/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Props = {
defaultNSFW?: boolean
defaultLanguage?: string | null
onClose?: () => void
locale: string
}

type FormValue = {
Expand Down Expand Up @@ -425,6 +426,8 @@ const Status: React.FC<Props> = props => {
setFormValue(current => Object.assign({}, current, { spoiler: '' }))
}

const simpleLocale = props.locale ? props.locale.split('-')[0] : 'en'

const EmojiPicker = forwardRef<HTMLDivElement>((props, ref) => (
<Popover ref={ref} {...props}>
<Picker
Expand All @@ -435,6 +438,7 @@ const Status: React.FC<Props> = props => {
set="native"
perLine="7"
theme={theme === 'high-contrast' ? 'dark' : theme}
locale={simpleLocale}
/>
</Popover>
))
Expand Down
17 changes: 15 additions & 2 deletions src/components/detail/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Props = {
openFromOtherAccount: (status: Entity.Status) => void
openListMemberships: (list: Entity.List, client: MegalodonInterface) => void
openAddListMember: (user: Entity.Account, client: MegalodonInterface) => void
locale: string
}

const Detail: React.FC<Props> = props => {
Expand Down Expand Up @@ -59,6 +60,7 @@ const Detail: React.FC<Props> = props => {
}
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
locale={props.locale}
/>
)}
{target === 'profile' && (
Expand All @@ -67,14 +69,25 @@ const Detail: React.FC<Props> = props => {
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
openAddListMember={props.openAddListMember}
locale={props.locale}
/>
)}
{target === 'tag' && (
<TagDetail openMedia={props.openMedia} openReport={props.openReport} openFromOtherAccount={props.openFromOtherAccount} />
<TagDetail
openMedia={props.openMedia}
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
locale={props.locale}
/>
)}
{target === 'lists' && <ListsDetail openListMemberships={props.openListMemberships} />}
{target === 'list' && (
<ListDetail openMedia={props.openMedia} openReport={props.openReport} openFromOtherAccount={props.openFromOtherAccount} />
<ListDetail
openMedia={props.openMedia}
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
locale={props.locale}
/>
)}
{target === 'followed_hashtags' && <FollowedHashtags />}
</Container>
Expand Down
2 changes: 2 additions & 0 deletions src/components/detail/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Props = {
openMedia: (media: Array<Entity.Attachment>, index: number) => void
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
locale: string
}

export default function ListDetail(props: Props) {
Expand Down Expand Up @@ -169,6 +170,7 @@ export default function ListDetail(props: Props) {
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={customEmojis}
filters={filters}
locale={props.locale}
/>
</List.Item>
)}
Expand Down
2 changes: 2 additions & 0 deletions src/components/detail/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Props = {
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
openAddListMember: (user: Entity.Account, client: MegalodonInterface) => void
locale: string
}

const Profile: React.FC<Props> = props => {
Expand Down Expand Up @@ -163,6 +164,7 @@ const Profile: React.FC<Props> = props => {
openMedia={props.openMedia}
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
locale={props.locale}
ref={postsRef}
/>
)
Expand Down
2 changes: 2 additions & 0 deletions src/components/detail/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Props = {
openMedia: (media: Array<Entity.Attachment>, index: number) => void
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
locale: string
}

const StatusDetail: React.FC<Props> = props => {
Expand Down Expand Up @@ -179,6 +180,7 @@ const StatusDetail: React.FC<Props> = props => {
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={customEmojis}
locale={props.locale}
/>
</List.Item>
))}
Expand Down
2 changes: 2 additions & 0 deletions src/components/detail/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Props = {
openMedia: (media: Array<Entity.Attachment>, index: number) => void
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
locale: string
}

export default function TagDetail(props: Props) {
Expand Down Expand Up @@ -201,6 +202,7 @@ export default function TagDetail(props: Props) {
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={customEmojis}
locale={props.locale}
/>
</List.Item>
)}
Expand Down
3 changes: 3 additions & 0 deletions src/components/detail/profile/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ArgProps = {
openMedia: (media: Array<Entity.Attachment>, index: number) => void
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
locale: string
}

const Posts: React.ForwardRefRenderFunction<FuncProps, ArgProps> = (props, ref) => {
Expand Down Expand Up @@ -122,6 +123,7 @@ const Posts: React.ForwardRefRenderFunction<FuncProps, ArgProps> = (props, ref)
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={customEmojis}
locale={props.locale}
/>
</List.Item>
))}
Expand All @@ -140,6 +142,7 @@ const Posts: React.ForwardRefRenderFunction<FuncProps, ArgProps> = (props, ref)
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={customEmojis}
locale={props.locale}
/>
</List.Item>
))}
Expand Down
2 changes: 2 additions & 0 deletions src/components/fromOtherAccount/FromOtherAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Props = {
opened: boolean
status: Entity.Status
close: () => void
locale: string
}

export default function FromOtherAccount(props: Props) {
Expand Down Expand Up @@ -54,6 +55,7 @@ export default function FromOtherAccount(props: Props) {
reset()
props.close()
}}
locale={props.locale}
/>
)
}
Expand Down
13 changes: 12 additions & 1 deletion src/components/fromOtherAccount/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Props = {
account: Account
client: MegalodonInterface | null
next: () => void
locale: string
}
export default function Status(props: Props) {
const [statuses, setStatuses] = useState<Array<Entity.Status>>([])
Expand Down Expand Up @@ -90,6 +91,7 @@ export default function Status(props: Props) {
server={props.server}
account={props.account}
customEmojis={customEmojis}
locale={props.locale}
/>
))
) : (
Expand All @@ -115,6 +117,7 @@ type PostProps = {
client: MegalodonInterface
updateStatus: (status: Entity.Status) => void
customEmojis: Array<CustomEmojiCategory>
locale: string
}

function Post(props: PostProps) {
Expand Down Expand Up @@ -173,13 +176,21 @@ function Post(props: PostProps) {
setShowReply={setShowReply}
updateStatus={props.updateStatus}
customEmojis={props.customEmojis}
locale={props.locale}
/>
</div>
</FlexboxGrid.Item>
</FlexboxGrid>
{showReply && (
<div style={{ padding: '8px 12px' }}>
<Reply client={client} server={props.server} account={props.account} in_reply_to={status} onClose={() => setShowReply(false)} />
<Reply
client={client}
server={props.server}
account={props.account}
in_reply_to={status}
onClose={() => setShowReply(false)}
locale={props.locale}
/>
</div>
)}
</>
Expand Down
2 changes: 2 additions & 0 deletions src/components/search/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Props = {
openMedia: (media: Array<Entity.Attachment>, index: number) => void
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
locale: string
}

export default function Results(props: Props) {
Expand Down Expand Up @@ -184,6 +185,7 @@ export default function Results(props: Props) {
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={customEmojis}
locale={props.locale}
/>
</div>
</List.Item>
Expand Down
2 changes: 2 additions & 0 deletions src/components/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Props = {
openMedia: (media: Array<Entity.Attachment>, index: number) => void
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
locale: string
}

export default function Search(props: Props) {
Expand Down Expand Up @@ -87,6 +88,7 @@ export default function Search(props: Props) {
openMedia={props.openMedia}
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
locale={props.locale}
/>
)}
</Content>
Expand Down
2 changes: 2 additions & 0 deletions src/components/timelines/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Props = {
openMedia: (media: Array<Entity.Attachment>, index: number) => void
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
locale: string
}

const Notifications: React.FC<Props> = props => {
Expand Down Expand Up @@ -404,6 +405,7 @@ const Notifications: React.FC<Props> = props => {
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={customEmojis}
filters={filters}
locale={props.locale}
/>
</List.Item>
)
Expand Down
3 changes: 3 additions & 0 deletions src/components/timelines/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Props = {
openMedia: (media: Array<Entity.Attachment>, index: number) => void
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
locale: string
}

const Show: React.FC<Props> = props => {
Expand All @@ -27,6 +28,7 @@ const Show: React.FC<Props> = props => {
openMedia={props.openMedia}
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
locale={props.locale}
/>
)
} else if (props.timeline.kind === 'direct') {
Expand All @@ -39,6 +41,7 @@ const Show: React.FC<Props> = props => {
openMedia={props.openMedia}
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
locale={props.locale}
/>
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/timelines/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Props = {
openMedia: (media: Array<Entity.Attachment>, index: number) => void
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
locale: string
}

export default function TimelineColumn(props: Props) {
Expand Down Expand Up @@ -535,6 +536,7 @@ export default function TimelineColumn(props: Props) {
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={customEmojis}
filters={filters}
locale={props.locale}
/>
</List.Item>
)}
Expand Down
3 changes: 3 additions & 0 deletions src/components/timelines/notification/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Props = {
openFromOtherAccount: (status: Entity.Status) => void
customEmojis: Array<CustomEmojiCategory>
filters: Array<Entity.Filter>
locale: string
}

const notification = (props: Props) => {
Expand Down Expand Up @@ -67,6 +68,7 @@ const notification = (props: Props) => {
openReport={props.openReport}
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={props.customEmojis}
locale={props.locale}
/>
)
} else {
Expand All @@ -91,6 +93,7 @@ const notification = (props: Props) => {
openFromOtherAccount={props.openFromOtherAccount}
customEmojis={props.customEmojis}
filters={props.filters}
locale={props.locale}
/>
)
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/components/timelines/notification/Reaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Props = {
openReport: (status: Entity.Status, client: MegalodonInterface) => void
openFromOtherAccount: (status: Entity.Status) => void
customEmojis: Array<CustomEmojiCategory>
locale: string
}

const actionIcon = (notification: Entity.Notification) => {
Expand Down Expand Up @@ -315,6 +316,7 @@ const Reaction: React.FC<Props> = props => {
openReport={() => props.openReport(status, props.client)}
openFromOtherAccount={() => props.openFromOtherAccount(status)}
customEmojis={props.customEmojis}
locale={props.locale}
/>
</div>
</div>
Expand All @@ -326,6 +328,7 @@ const Reaction: React.FC<Props> = props => {
account={props.account}
in_reply_to={status}
onClose={() => setShowReply(false)}
locale={props.locale}
/>
</div>
)}
Expand All @@ -337,6 +340,7 @@ const Reaction: React.FC<Props> = props => {
account={props.account}
edit_target={status}
onClose={() => setShowEdit(false)}
locale={props.locale}
/>
</div>
)}
Expand Down
Loading

0 comments on commit 35674a8

Please sign in to comment.