Skip to content

Commit

Permalink
feat!: Upgrade Portuguese Dictionary to v2.0 (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Aug 12, 2022
1 parent feb38dc commit 7443cb6
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 274 deletions.
2 changes: 1 addition & 1 deletion extensions/portuguese/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "${workspaceRoot}/samples"],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/out/src/**/*.js"],
Expand Down
11 changes: 7 additions & 4 deletions extensions/portuguese/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
.vscode/**
.gitignore
.vscode-test/**
.vscode/**
**/*.d.ts
**/*.map
**/*.test.*
out/test/**
test/**
samples/**
src/**
**/*.map
.gitignore
test/**
tsconfig.json
vsc-extension-quickstart.md
3 changes: 3 additions & 0 deletions extensions/portuguese/cspell-ext.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"import": ["@cspell/dict-pt-pt/cspell-ext.json"]
}
254 changes: 5 additions & 249 deletions extensions/portuguese/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extensions/portuguese/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@
"test": "node ../../node_modules/vscode/bin/test"
},
"dependencies": {
"cspell-dict-pt-pt": "^1.1.2"
"@cspell/dict-pt-pt": "^2.0.0"
}
}
3 changes: 3 additions & 0 deletions extensions/portuguese/samples/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language": "pt"
}
5 changes: 5 additions & 0 deletions extensions/portuguese/samples/seattle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Seattle (pronuncia-se localmente [siːˈætɫ̩] ou [siːˈæɾɫ̩]) é uma cidade portuária e sede do Condado de King, no estado norte-americano de Washington. É a cidade mais populosa e mais densamente povoada do estado de Washington, sendo a 18ª mais populosa do país. A cidade é um importante porto marítimo situado num estreito istmo entre o Puget Sound (um braço do Oceano Pacífico, conhecido também como estuário de Puget) e o lago Washington, a aproximadamente 183 km ao sul da fronteira Canadá-Estados Unidos.

A área metropolitana de Seattle, com um pouco mais de quatro milhões de habitantes, é a 15ª maior área metropolitana nos Estados Unidos.[2] Seattle é a maior cidade da região Noroeste Pacífico e a maior cidade da costa oeste ao norte de São Francisco, sendo uma das cidades que mais crescem nos Estados Unidos.

A área de Seattle foi habitada por nativos americanos por, pelo menos, quatro mil anos antes do primeiro assentamento permanente de colonizadores.[3] O assentamento foi movido para o local atual e nomeado "Seattle", em 1853, em homenagem ao chefe Seattle. Seattle, por si, tem um histórico musical notável. Foi na cidade que surgiram artistas de jazz, como Ray Charles, Quincy Jones, Ernestine Anderson, entre outros. Seattle também é cidade natal do guitarrista Jimi Hendrix, e do estilo musical "grunge", que ficou famoso pelas bandas locais Nirvana, Pearl Jam, Soundgarden e Alice in Chains. A cidade também é famosa pelos seus artistas de hip hop, como os rappers Sir Mix-A-Lot e Macklemore.
36 changes: 17 additions & 19 deletions extensions/portuguese/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,55 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
import * as dict from 'cspell-dict-pt-pt';

interface CodeSpellCheckerExtension {
registerConfig(path: string): Promise<void>;
enableLocal(isGlobal: boolean, local: string): Promise<void>;
disableLocal(isGlobal: boolean, local: string): Promise<void>;
enableLocale(isGlobal: boolean, locale: string): Promise<void>;
disableLocale(isGlobal: boolean, locale: string): Promise<void>;
}

const local = 'pt,pt_PT';
//
const locale = 'pt';
//

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
const vscodeSpellCheckerExtension = 'streetsidesoftware.code-spell-checker';
const configLocation = context.asAbsolutePath('./cspell-ext.json');

const extension = vscode.extensions.getExtension<CodeSpellCheckerExtension>(vscodeSpellCheckerExtension);

if (extension) {
extension.activate().then((ext) => {
const path = dict.getConfigLocation();
// We need to register the dictionary configuration with the Code Spell Checker Extension
ext && ext.registerConfig && ext.registerConfig(path);
ext?.registerConfig?.(configLocation);
});
}

function enablePortuguese(isGlobal: boolean) {
//
function enable(isGlobal: boolean) {
extension &&
extension.activate().then((ext) => {
ext && ext.enableLocal && ext.enableLocal(isGlobal, local);
ext?.enableLocale?.(isGlobal, locale);
});
}

function disablePortuguese(isGlobal: boolean) {
function disable(isGlobal: boolean) {
extension &&
extension.activate().then((ext) => {
ext && ext.disableLocal && ext.disableLocal(isGlobal, local);
ext?.disableLocale?.(isGlobal, locale);
});
}

// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(
vscode.commands.registerCommand('cSpellExt_portuguese.enablePortuguese', () => enablePortuguese(true)),
vscode.commands.registerCommand('cSpellExt_portuguese.disablePortuguese', () => disablePortuguese(true)),
vscode.commands.registerCommand('cSpellExt_portuguese.enablePortugueseWorkspace', () =>
enablePortuguese(false)
),
vscode.commands.registerCommand('cSpellExt_portuguese.disablePortugueseWorkspace', () =>
disablePortuguese(false)
)
vscode.commands.registerCommand('cSpellExt_portuguese.enablePortuguese', () => enable(true)),
vscode.commands.registerCommand('cSpellExt_portuguese.disablePortuguese', () => disable(true)),
vscode.commands.registerCommand('cSpellExt_portuguese.enablePortugueseWorkspace', () => enable(false)),
vscode.commands.registerCommand('cSpellExt_portuguese.disablePortugueseWorkspace', () => disable(false))
);
//
}

// this method is called when your extension is deactivated
Expand Down

0 comments on commit 7443cb6

Please sign in to comment.