Skip to content

Commit

Permalink
Add option to search in any language (#5598)
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey authored Oct 4, 2024
1 parent ce53b3a commit 3f66531
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/screens/Search/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function makeSearchQuery(query: string, params: Params) {
return [
query,
Object.entries(params)
.filter(([_, value]) => value)
.map(([name, value]) => `${name}:${value}`)
.join(' '),
]
Expand Down
28 changes: 19 additions & 9 deletions src/view/screens/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,28 @@ function SearchLanguageDropdown({
onChange(value: string): void
}) {
const t = useThemeNew()
const {_} = useLingui()
const {contentLanguages} = useLanguagePrefs()

const items = React.useMemo(() => {
return LANGUAGES.filter(l => Boolean(l.code2))
.map(l => ({
label: l.name,
inputLabel: l.name,
value: l.code2,
key: l.code2 + l.code3,
}))
.sort(a => (contentLanguages.includes(a.value) ? -1 : 1))
}, [contentLanguages])
return [
{
label: _(msg`Any language`),
inputLabel: _(msg`Any language`),
value: '',
key: '*',
},
].concat(
LANGUAGES.filter(l => Boolean(l.code2))
.map(l => ({
label: l.name,
inputLabel: l.name,
value: l.code2,
key: l.code2 + l.code3,
}))
.sort(a => (contentLanguages.includes(a.value) ? -1 : 1)),
)
}, [_, contentLanguages])

const style = {
backgroundColor: t.atoms.bg_contrast_25.backgroundColor,
Expand Down

0 comments on commit 3f66531

Please sign in to comment.