Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Language Options Sorting by Using 'Name' Property. #33906

Merged
merged 7 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strange-bulldogs-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Sorts the list of language options by name correctly
14 changes: 8 additions & 6 deletions apps/meteor/client/providers/TranslationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,14 @@ const TranslationProvider = ({ children }: TranslationProviderProps): ReactEleme
ogName: i18nextInstance.t('Default'),
key: '',
},
...[...new Set([...i18nextInstance.languages, ...languages])].map((key) => ({
en: key,
name: getLanguageName(key, language),
ogName: getLanguageName(key, key),
key,
})),
...[...new Set([...i18nextInstance.languages, ...languages])]
.map((key) => ({
en: key,
name: getLanguageName(key, language),
ogName: getLanguageName(key, key),
key,
}))
.sort(({ name: nameA }, { name: nameB }) => nameA.localeCompare(nameB)),
],
[language, i18nextInstance],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ const PreferencesLocalizationSection = () => {

const { control } = useFormContext();

const languageOptions = useMemo(() => {
const mapOptions: SelectOption[] = languages.map(({ key, name }) => [key, name]);
mapOptions.sort(([a], [b]) => a.localeCompare(b));
return mapOptions;
}, [languages]);
const languageOptions = useMemo(() => languages.map(({ key, name }): SelectOption => [key, name]), [languages]);

const languageId = useUniqueId();

Expand Down
Loading