Sort categories by translated name (#5307)

* Sort categories by translated name

* Use locale and numeric

* Remove @modrinth/ui import
This commit is contained in:
Jerozgen
2026-02-09 04:19:04 +03:00
committed by GitHub
parent 4eb0f0c206
commit a8c5e036d0
4 changed files with 26 additions and 73 deletions

View File

@@ -154,19 +154,23 @@ interface Category {
}
const tags = useGeneratedState()
const { formatMessage } = useVIntl()
const { formatMessage, locale } = useVIntl()
const { projectV2: project, patchProject } = injectProjectPageContext()
const formatCategoryName = (categoryName: string) => {
return formatCategory(formatMessage, categoryName)
}
const { saved, current, saving, reset, save } = useSavable(
() => ({
selectedTags: sortedCategories(tags.value).filter(
selectedTags: sortedCategories(tags.value, formatCategoryName, locale.value).filter(
(x: Category) =>
x.project_type === project.value.actualProjectType &&
(project.value.categories.includes(x.name) ||
project.value.additional_categories.includes(x.name)),
) as Category[],
featuredTags: sortedCategories(tags.value).filter(
featuredTags: sortedCategories(tags.value, formatCategoryName, locale.value).filter(
(x: Category) =>
x.project_type === project.value.actualProjectType &&
project.value.categories.includes(x.name),
@@ -212,7 +216,7 @@ const { saved, current, saving, reset, save } = useSavable(
const categoryLists = computed(() => {
const lists: Record<string, Category[]> = {}
sortedCategories(tags.value).forEach((x: Category) => {
sortedCategories(tags.value, formatCategoryName, locale.value).forEach((x: Category) => {
if (x.project_type === project.value.actualProjectType) {
const header = x.header
if (!lists[header]) {
@@ -253,9 +257,11 @@ const multipleResolutionTagsWarning = computed(() => {
})
const allTagsSelectedWarning = computed(() => {
const categoriesForProjectType = sortedCategories(tags.value).filter(
(x: Category) => x.project_type === project.value.actualProjectType,
)
const categoriesForProjectType = sortedCategories(
tags.value,
formatCategoryName,
locale.value,
).filter((x: Category) => x.project_type === project.value.actualProjectType)
const totalSelectedTags = current.value.selectedTags.length
if (