Skip to content

Commit

Permalink
feat!: Upgrade Catalan Dictionary to v2 (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Aug 12, 2022
1 parent b895f1e commit 7e16e1f
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 270 deletions.
2 changes: 1 addition & 1 deletion extensions/catalan/.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/catalan/.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/catalan/cspell-ext.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"import": ["@cspell/dict-ca/cspell-ext.json"]
}
254 changes: 5 additions & 249 deletions extensions/catalan/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/catalan/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-ca": "^1.1.2"
"@cspell/dict-ca": "^2.0.0"
}
}
3 changes: 3 additions & 0 deletions extensions/catalan/samples/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language": "ca"
}
3 changes: 3 additions & 0 deletions extensions/catalan/samples/seattle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Seattle (pronunciació pronunciació (?·pàg.) | IPA: [siːˈætəl]) és la ciutat més gran de l'estat de Washington, al nord-oest dels Estats Units d'Amèrica, i la més gran de la costa oest al nord de San Francisco. La ciutat està situada en un istme estret que separa el llac Washington i un braç de l'oceà Pacífic conegut com a Puget Sound. Es troba a 155 quilòmetres al sud de la frontera entre els Estats Units i el Canadà i dins de Washington s'ubica al Comtat de King. Va ser fundada en la dècada de 1850, en territoris del cap indígena Seath'tl, a qui deu el seu nom.

Seattle està en el centre econòmic de la regió coneguda com a "Greater Puget Sound". El seu sobrenom oficial és "La Ciutat Maragda" a causa dels boscos exuberants de la regió que l'envolta. Seattle és coneguda com a "Rainy City" (La Ciutat de la Pluja), encara que en realitat té menys pluja que moltes altres ciutats nord-americanes. La ciutat també és anomenada "Jet City", a causa de la gran influència del fabricant d'aeronaus Boeing. Econòmicament la ciutat destaca per les indústries punta i pel seu dinamisme. És considerada un dels millors llocs del país per iniciar negocis i un pol de desenvolupament sostenible.
32 changes: 17 additions & 15 deletions extensions/catalan/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +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-ca';

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 = 'ca';
//
const locale = 'ca';
//

// 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 enableCatalan(isGlobal: boolean) {
//
function enable(isGlobal: boolean) {
extension &&
extension.activate().then((ext) => {
ext && ext.enableLocal && ext.enableLocal(isGlobal, local);
ext?.enableLocale?.(isGlobal, locale);
});
}

function disableCatalan(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_catalan.enableCatalan', () => enableCatalan(true)),
vscode.commands.registerCommand('cSpellExt_catalan.disableCatalan', () => disableCatalan(true)),
vscode.commands.registerCommand('cSpellExt_catalan.enableCatalanWorkspace', () => enableCatalan(false)),
vscode.commands.registerCommand('cSpellExt_catalan.disableCatalanWorkspace', () => disableCatalan(false))
vscode.commands.registerCommand('cSpellExt_catalan.enableCatalan', () => enable(true)),
vscode.commands.registerCommand('cSpellExt_catalan.disableCatalan', () => disable(true)),
vscode.commands.registerCommand('cSpellExt_catalan.enableCatalanWorkspace', () => enable(false)),
vscode.commands.registerCommand('cSpellExt_catalan.disableCatalanWorkspace', () => disable(false))
);
//
}

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

0 comments on commit 7e16e1f

Please sign in to comment.