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

Update plugin category labels #6276

Merged
merged 1 commit into from
Nov 1, 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
15 changes: 15 additions & 0 deletions src/apps/dashboard/features/plugins/constants/categoryLabels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** A mapping of category names used by the plugin repository to translation keys. */
export const CATEGORY_LABELS = {
Administration: 'HeaderAdmin',
Anime: 'Anime',
Authentication: 'LabelAuthProvider', // Legacy
Books: 'Books',
Channel: 'Channels', // Unused?
General: 'General',
LiveTV: 'LiveTV',
Metadata: 'LabelMetadata', // Legacy
MoviesAndShows: 'MoviesAndShows',
Music: 'TabMusic',
Subtitles: 'Subtitles',
Other: 'Other'
};
35 changes: 16 additions & 19 deletions src/controllers/dashboard/plugins/available/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import escapeHTML from 'escape-html';

import loading from '../../../../components/loading/loading';
import globalize from '../../../../lib/globalize';
import '../../../../components/cardbuilder/card.scss';
import '../../../../elements/emby-button/emby-button';
import '../../../../elements/emby-checkbox/emby-checkbox';
import '../../../../elements/emby-select/emby-select';
import { getDefaultBackgroundClass } from '../../../../components/cardbuilder/cardBuilderUtils';
import { CATEGORY_LABELS } from 'apps/dashboard/features/plugins/constants/categoryLabels';
import { getDefaultBackgroundClass } from 'components/cardbuilder/cardBuilderUtils';
import loading from 'components/loading/loading';
import globalize from 'lib/globalize';

import 'components/cardbuilder/card.scss';
import 'elements/emby-button/emby-button';
import 'elements/emby-checkbox/emby-checkbox';
import 'elements/emby-select/emby-select';

function reloadList(page) {
loading.show();
Expand All @@ -23,27 +25,22 @@ function reloadList(page) {
}

function getHeaderText(category) {
category = category.replace(' ', '');
// TODO: Replace with switch
if (category === 'Channel') {
category = 'Channels';
} else if (category === 'Theme') {
category = 'Themes';
} else if (category === 'LiveTV') {
category = 'LiveTV';
} else if (category === 'ScreenSaver') {
category = 'HeaderScreenSavers';
const categoryKey = category.replaceAll(' ', '');

if (CATEGORY_LABELS[categoryKey]) {
return globalize.translate(CATEGORY_LABELS[categoryKey]);
}

return globalize.translate(category);
console.warn('[AvailablePlugins] unmapped category label', category);
return category;
}

function populateList(options) {
const availablePlugins = options.availablePlugins;
const installedPlugins = options.installedPlugins;

availablePlugins.forEach(function (plugin, index, array) {
plugin.category = plugin.category || 'General';
plugin.category = plugin.category || 'Other';
plugin.categoryDisplayName = getHeaderText(plugin.category);
array[index] = plugin;
});
Expand Down
2 changes: 2 additions & 0 deletions src/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"AlwaysRemuxFlacAudioFilesHelp": "If you have files that your browser rejects to play or where it inaccurately calculates timestamps, enable this as a workaround.",
"AlwaysRemuxMp3AudioFilesHelp": "If you have files that your browser inaccurately calculates timestamps, enable this as a workaround.",
"AndOtherArtists": "{0} and {1} other artists.",
"Anime": "Anime",
"AnyLanguage": "Any Language",
"Anytime": "Anytime",
"ApiKeysCaption": "List of the currently enabled API keys",
Expand Down Expand Up @@ -1181,6 +1182,7 @@
"Movie": "Movie",
"MovieLibraryHelp": "Review the {0}movie naming guide{1}.",
"Movies": "Movies",
"MoviesAndShows": "Movies and Shows",
"MusicAlbum": "Music Album",
"MusicArtist": "Music Artist",
"MusicLibraryHelp": "Review the {0}music naming guide{1}.",
Expand Down
Loading