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

Expose language display names to extension API #17885

Closed
Nicd opened this issue Dec 28, 2016 · 7 comments
Closed

Expose language display names to extension API #17885

Nicd opened this issue Dec 28, 2016 · 7 comments
Assignees
Labels
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality languages-basic Basic language support issues
Milestone

Comments

@Nicd
Copy link

Nicd commented Dec 28, 2016

  • VSCode Version: 1.8.1
  • OS Version: Irrelevant

Currently it seems it is not possible to get the name of the language of a document in an extension. The document object contains a property languageId which has an internal ID for the language. vscode.languages.getLanguages() can also be used to get all registered language IDs. There is no method to get the actual names of the languages.

The editor displays the name of the language in the status bar and in the language mode menu, but the names are not exposed to extensions. Personally I am working on an extension for my web service which requires the actual language names and not the IDs.

@jrieken jrieken assigned jrieken and unassigned joaomoreno Dec 29, 2016
@jrieken jrieken added api feature-request Request for new features or functionality labels Dec 29, 2016
@jrieken jrieken changed the title Expose language names to extension API Expose language display names to extension API Dec 29, 2016
@Nicd
Copy link
Author

Nicd commented Mar 24, 2017

The extension https://marketplace.visualstudio.com/items?itemName=juha-ristolainen.code-stats-vscode requires this feature to be implemented for proper functionality. Without it, it can only work with a hardcoded mapping of language IDs to language names, which will obviously fail when new programming languages and other syntaxes are created.

@jrieken jrieken added this to the Backlog milestone Oct 31, 2019
@tjx666

This comment has been minimized.

@wraith13
Copy link

Is this problem still unsolved?
I am also having trouble with this problem now.

@wraith13
Copy link

Here is the code I wrote for someone who is having the same problem.
This code seems to be generally fine, but I can't get the localized plaintext name.

const getLanguageName = (languageId: string) => vscode.extensions.all
    .map(i => <any[]>(i.packageJSON as any)?.contributes?.languages)
    .filter(i => i)
    .reduce((a, b) => a.concat(b), [])
    .filter(i => i.id === languageId && 0 < (i.aliases?.length ?? 0))
    .map(i => i?.aliases?.[0])?.[0] ?? languageId;

@jrieken jrieken added the languages-basic Basic language support issues label Nov 9, 2020
@worksofliam
Copy link

Came here to say this would be a nice to have.

@jrieken
Copy link
Member

jrieken commented Oct 12, 2021

/duplicate of #2871

@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality languages-basic Basic language support issues
Projects
None yet
Development

No branches or pull requests

7 participants
@joaomoreno @Nicd @wraith13 @jrieken @worksofliam @tjx666 and others