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

Allow filtering to reduce the total number of languages listed #488

Open
westonruter opened this issue Nov 22, 2021 · 6 comments · May be fixed by #766
Open

Allow filtering to reduce the total number of languages listed #488

westonruter opened this issue Nov 22, 2021 · 6 comments · May be fixed by #766
Labels
enhancement New feature or request

Comments

@westonruter
Copy link
Owner

From a plugin review by @SvenWoltmann:

It would be great if one could select a subset of the available languages for the dropdown, so you don’t always have to scroll through all 185 languages.

@westonruter westonruter added the enhancement New feature or request label Nov 22, 2021
@westonruter
Copy link
Owner Author

This could be achieved by adding a PHP WP filter to the get_language_names() function:

/**
* Language names.
*
* @return array Mapping slug to name.
*/
function get_language_names() {
return require __DIR__ . '/language-names.php';
}

@allejo
Copy link
Collaborator

allejo commented Nov 22, 2021

This could probably be merged in with functionality for #191

@westonruter
Copy link
Owner Author

Ah yes, of course.

ronalfy pushed a commit to DLXPlugins/syntax-highlighting-code-block that referenced this issue Oct 7, 2023
…nguage names.

Filter: `syntax_highlighting_code_block_language_names` - Resolves issue: westonruter#488
@ronalfy ronalfy linked a pull request Oct 7, 2023 that will close this issue
@avillegasn
Copy link

I'd like the related PR to be merged. Having the filter syntax_highlighting_code_block_language_names is a nice feature.

@westonruter
Copy link
Owner Author

The scope of the related PR is too large and there are aspects which I don't think are needed. The scope should be reduced down to just fix the issue of reducing the total number of languages.

Also, there is perhaps a better approach that could be taken than just to filtering the language names. Perhaps it could reuse the syntax_highlighting_code_block_auto_detect_languages filter so that only those languages are listed in the dropdown as well as being used for auto-detection. I don't think it really makes a lot of sense to have languages listed if they're never going to be used for auto-detection. In that case, perhaps the filter should be renamed to just syntax_highlighting_code_block_languages with the old filter deprecated.

@avillegasn
Copy link

I agree with your proposal. In fact, at first I expected the syntax_highlighting_code_block_auto_detect_languages to filter the languages from the list too. It makes sense to only have the syntax_highlighting_code_block_languages filter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants