Skip to content

Commit

Permalink
fix: Language Options Sorting by Using 'Name' Property. (#33906)
Browse files Browse the repository at this point in the history
Co-authored-by: Tasso Evangelista <[email protected]>
  • Loading branch information
thepiyush-303 and tassoevan authored Nov 26, 2024
1 parent 8ade81b commit 7855bc3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
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

0 comments on commit 7855bc3

Please sign in to comment.