forked from TabbyML/tabby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): fix programming name display format (TabbyML#1829)
* fix(ui): fix programming name display format * update * [autofix.ci] apply automated fixes * update * [autofix.ci] apply automated fixes * alias * [autofix.ci] apply automated fixes * update --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9af64ef
commit ab2ab49
Showing
9 changed files
with
83 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import path from 'path' | ||
import { has } from 'lodash-es' | ||
|
||
import { Language as ProgrammingLanguage } from '@/lib/gql/generates/graphql' | ||
|
||
import languages from './languages' | ||
|
||
// Fork from | ||
// https://github.com/TomerAberbach/filename2prism/ | ||
export const filename2prism: (filename: string) => Array<string> = filename => { | ||
const filenames: Record<string, string[]> = {} | ||
const extnames: Record<string, string[]> = {} | ||
|
||
for (const [alias, associations] of Object.entries(languages)) { | ||
for (const filename of associations.filenames) { | ||
if (!has(filenames, filename)) { | ||
filenames[filename] = [] | ||
} | ||
|
||
filenames[filename].push(alias) | ||
} | ||
|
||
for (const extname of associations.extnames) { | ||
if (!has(extnames, extname)) { | ||
extnames[extname] = [] | ||
} | ||
|
||
extnames[extname].push(alias) | ||
} | ||
} | ||
|
||
const result: string[] = [] | ||
return result | ||
.concat( | ||
filenames[path.basename(filename)], | ||
extnames[path.extname(filename).substring(1)] | ||
) | ||
.filter(Boolean) | ||
} | ||
|
||
export const toProgrammingLanguageDisplayName = ( | ||
lan: ProgrammingLanguage | ||
): string => { | ||
const displayName = | ||
Object.keys(ProgrammingLanguage)[ | ||
Object.values(ProgrammingLanguage).indexOf(lan) | ||
] || '' | ||
const mapping: Record<string, string> = { | ||
csharp: 'C#', | ||
cpp: 'C++', | ||
javascript: 'JavaScript', | ||
typescript: 'TypeScript' | ||
} | ||
return mapping[displayName.toLocaleLowerCase()] || displayName | ||
} |
File renamed without changes.