Skip to content

Commit

Permalink
Move sorting to TranslationProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Nov 25, 2024
1 parent ace19a6 commit bca670c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
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,15 +12,7 @@ const PreferencesLocalizationSection = () => {

const { control } = useFormContext();

const languageOptions = useMemo(() => {
const mapOptions: SelectOption[] = languages.map(({ key, name }) => {
// Add a space to the name of the default language to bring it to the top
const displayName = key === '' && name === 'Default' ? ' Default' : name;
return [key, displayName];
});
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 bca670c

Please sign in to comment.