-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
179 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"copied_to_clipboard": "Copied results to clipboard", | ||
"description": "Find all occurrences of text in current file", | ||
"displayName": "Find All In File", | ||
"editorContextMenu": "Show items in editor context menu.", | ||
"enter_search_regex": "Please enter regular expression to search for", | ||
"enter_search_string": "Please enter string to search for", | ||
"error_no_document": "No active editor document", | ||
"error_regex": "Regex failure: {0}", | ||
"find_error": "ERROR: {0}", | ||
"find_result_string": "{0}\t{1}:{2}-{3}\t{4}", | ||
"findregexcase": "Find Regex (Case Sensitive)", | ||
"findregexcaseword": "Find Regex (Case Sensitive, Whole Word)", | ||
"findregexnocase": "Find Regex (Case Insensitive)", | ||
"findregexnocaseword": "Find Regex (Case Insensitive, Whole Word)", | ||
"findstringcase": "Find String (Case Sensitive)", | ||
"findstringcaseword": "Find String (Case Sensitive, Whole Word)", | ||
"findstringnocase": "Find String (Case Insensitive)", | ||
"findstringnocaseword": "Find String (Case Insensitive, Whole Word)", | ||
"regex_case": "case sensitive regex", | ||
"regex_no_case": "case insensitive regex", | ||
"search_footer": "Found {0} occurrences", | ||
"search_header": "Searching for {0}{1}\"{2}\" in \"{3}\":", | ||
"string_case": "case sensitive string", | ||
"string_no_case": "case insensitive string", | ||
"whole_word": "word" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2019 Benbuck Nason | ||
|
||
"use strict"; | ||
|
||
// Originally from https://github.com/shanalikhan/code-settings-sync/blob/master/src/localize.ts | ||
|
||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import * as vscode from "vscode"; | ||
|
||
interface ILanguagePack { | ||
[key: string]: string; | ||
} | ||
|
||
function recurseCandidates(rootPath: string, format: string, candidate: string): string { | ||
const filename: string = format.replace("{0}", `.${candidate}`); | ||
const filepath: string = path.resolve(rootPath, filename); | ||
if (fs.existsSync(filepath)) { | ||
return filename; | ||
} | ||
if (candidate.split("-")[0] !== candidate) { | ||
return recurseCandidates(rootPath, format, candidate.split("-")[0]); | ||
} | ||
|
||
return format.replace("{0}", ""); | ||
} | ||
|
||
function resolveLanguagePack(): ILanguagePack { | ||
let options: { locale: string } = { locale: "" }; | ||
try { | ||
const config: string = process.env.VSCODE_NLS_CONFIG ?? "{}"; | ||
options = { | ||
...options, | ||
...JSON.parse(config) | ||
}; | ||
} catch (err) { | ||
throw err; | ||
} | ||
|
||
// tslint:disable:no-any | ||
const languageFormat: string = "package.nls{0}.json"; | ||
const defaultLanguage: string = languageFormat.replace("{0}", ""); | ||
const extension: vscode.Extension<any> | undefined = vscode.extensions.getExtension("bnason-nf.findallinfile"); | ||
const rootPath: string = (extension === undefined) ? "" : extension.extensionPath; | ||
const resolvedLanguage: string = recurseCandidates(rootPath, languageFormat, options.locale); | ||
const languageFilePath: string = path.resolve(rootPath, resolvedLanguage); | ||
|
||
try { | ||
const defaultLanguageBundle: any = JSON.parse( | ||
(resolvedLanguage !== defaultLanguage) | ||
? fs.readFileSync(path.resolve(rootPath, defaultLanguage), "utf-8") | ||
: "{}" | ||
); | ||
|
||
const resolvedLanguageBundle: any = JSON.parse( | ||
fs.readFileSync(languageFilePath, "utf-8") | ||
); | ||
|
||
return { ...defaultLanguageBundle, ...resolvedLanguageBundle }; | ||
} catch (err) { | ||
throw err; | ||
} | ||
} | ||
|
||
const languagePack: ILanguagePack = resolveLanguagePack(); | ||
|
||
// tslint:disable:no-any no-unsafe-any | ||
export function localize(key: string, ...args: any[]): string { | ||
const localized: string = languagePack[key]; | ||
|
||
let formatted: string = localized; | ||
for (let index: number = 0; index < args.length; index += 1) { | ||
formatted = formatted.replace(`{${index}}`, `${args[index]}`); | ||
} | ||
|
||
return formatted; | ||
} |
Oops, something went wrong.