Skip to content

Commit 3f7cea5

Browse files
chrisbobbegnprice
authored andcommitted
UserList: Translate section headers
1 parent d5f5fa7 commit 3f7cea5

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/common/SectionHeader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { View } from 'react-native';
55

66
import { ThemeContext, createStyleSheet } from '../styles';
77
import ZulipTextIntl from './ZulipTextIntl';
8+
import type { LocalizableReactText } from '../types';
89

910
const styles = createStyleSheet({
1011
header: {
@@ -14,7 +15,7 @@ const styles = createStyleSheet({
1415
});
1516

1617
type Props = $ReadOnly<{|
17-
text: string,
18+
text: LocalizableReactText,
1819
|}>;
1920

2021
export default function SectionHeader(props: Props): Node {

src/users/UserList.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import UserItem from './UserItem';
1212
import { sortUserList, filterUserList, groupUsersByStatus } from './userHelpers';
1313
import { getMutedUsers } from '../selectors';
1414
import { getPresence } from '../directSelectors';
15+
import { ensureUnreachable } from '../generics';
1516

1617
const styles = createStyleSheet({
1718
list: {
@@ -40,7 +41,7 @@ export default function UserList(props: Props): Node {
4041
const sortedUsers = sortUserList(filteredUsers, presences);
4142
const groupedUsers = groupUsersByStatus(sortedUsers, presences);
4243
const sections = Object.keys(groupedUsers).map(key => ({
43-
key: `${key.charAt(0).toUpperCase()}${key.slice(1)}`,
44+
key,
4445
data: groupedUsers[key].map(u => u.user_id),
4546
}));
4647

@@ -63,10 +64,24 @@ export default function UserList(props: Props): Node {
6364
renderSectionHeader={({ section }) =>
6465
section.data.length === 0 ? null : (
6566
<SectionHeader
66-
text={
67+
text={(() => {
6768
// $FlowIgnore[incompatible-cast] something wrong with SectionList
68-
(section.key: (typeof sections)[number]['key'])
69-
}
69+
const key = (section.key: (typeof sections)[number]['key']);
70+
switch (key) {
71+
case 'active':
72+
return 'Active';
73+
case 'idle':
74+
return 'Idle';
75+
case 'offline':
76+
return 'Offline';
77+
case 'unavailable':
78+
return 'Unavailable';
79+
default: {
80+
ensureUnreachable(key);
81+
return key;
82+
}
83+
}
84+
})()}
7085
/>
7186
)
7287
}

static/translations/messages_en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"If there are other details you would like to share, please write them here.": "If there are other details you would like to share, please write them here.",
44
"App version": "App version",
55
"Server version": "Server version",
6+
"Active": "Active",
7+
"Idle": "Idle",
8+
"Offline": "Offline",
9+
"Unavailable": "Unavailable",
610
"Quote and reply": "Quote and reply",
711
"{username} [said]({link_to_message}):": "{username} [said]({link_to_message}):",
812
"[Quoting…]": "[Quoting…]",

0 commit comments

Comments
 (0)