import { basename } from 'path' ; import { TextDocument } from 'vscode' ; import { Framework } from './base' ; import { LanguageId } from '~/utils' ; class VSCodeFramework extends Framework { id = 'vscode' ; display = 'VS Code' ; detection = { packageJSON : [ 'vscode' , '@types/vscode' , ] , } ; enabledParsers = [ 'json' ] ; languageIds : LanguageId [ ] = [ 'json' , 'javascript' , 'typescript' , ] ; pathMatcher = ( ) => 'package.nls.?{locale?}.json' ; usageMatchRegex = ( languageIds ? , filename ? ) => { if ( filename && basename ( filename ) === 'package.json' ) return '"%({key})%"' ; return '(?:i18n[ (]path=|v-t=[\'"`{]|(?:this\\.|\\$|i18n\\.)(?:(?:d|n)\\(.*?,|(?:t|tc|te)\\()\\s*)[\'"`]({key})[\'"`]' ; } ; refactorTemplates ( keypath , args ? , doc ? ) { if ( doc ?. languageId === 'json' ) { return [ `%${ keypath }%` , keypath , ] ; } return [ `i18n.t('${ keypath }')` , keypath , ] ; } } export default VSCodeFramework ;