Skip to content

Commit

Permalink
feat!: Update Danish dictionary to v2 (#350)
Browse files Browse the repository at this point in the history
* feat!: Update Danish dictionary to v2
* Fix the Danish language code and add a sample file.
  Breaking change, the language code is now `da` instead of `dk`.
  • Loading branch information
Jason3S committed Aug 12, 2022
1 parent 1fb356a commit ce1a54b
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 272 deletions.
2 changes: 1 addition & 1 deletion extensions/danish/.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/danish/.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/danish/cspell-ext.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"import": ["@cspell/dict-da-dk/cspell-ext.json"]
}
258 changes: 7 additions & 251 deletions extensions/danish/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/danish/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-da-dk": "^1.1.3"
"@cspell/dict-da-dk": "^2.0.1"
}
}
3 changes: 3 additions & 0 deletions extensions/danish/samples/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language": "da"
}
5 changes: 5 additions & 0 deletions extensions/danish/samples/seattle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Seattle er den største by i delstaten Washington i den nordvestlige del af USA. Seattle har 737.015(2020)[1] indbyggere, og der bor omkring 3,5 millioner mennesker i byområdet på 15,265 km². Byen er beliggende mellem Puget Sound i vest og Lake Washington i øst. Det gør, at Seattleområdet er meget langstrakt. Byen ligger ca. 175 km syd for grænsen mellem USA og Canada, og er den nordligste større amerikanske by i de sammenhængende 48 stater.

Byen har en stor og alsidig industri med nogle af USA's førende firmaer inden for fly- og rumfartsindustri (Boeing), skibsværftsindustri (Vigor Shipyards), træ- og papirindustri (Weyerhaeuser) og computerindustri (Microsoft). Af betydning er også fødevareindustri (især fiskekonserves), forskningsindustrier (bl.a. biomedicin og oceanografi), bank- og forsikringsvirksomhed samt skibsfart, handel og fiskeri. Havnen er hjemsted for en stor fiskerflåde og talrige fragt- og passagerskibe. Ud over handelen med især Østasien er der færgefart til bl.a. Alaska og Vancouver Island (Canada).

Seattle er en velbesøgt turistby og med bl.a. University of Washington (1861) et stort uddannelsescenter. Byen er især kendt for sine mange kaffebarer og sin imponerende musikhistorie. Jazzmusikere som Quincy Jones og Ray Charles fik deres gennembrud mens de boede i byen. Byen er også fødested for Jimi Hendrix og den musikalske genre kaldet grunge, med bands som Pearl Jam, Nirvana og Soundgarden kommer fra Seattle.
32 changes: 17 additions & 15 deletions extensions/danish/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-da-dk';

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

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

function disableDanish(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_danish.enableDanish', () => enableDanish(true)),
vscode.commands.registerCommand('cSpellExt_danish.disableDanish', () => disableDanish(true)),
vscode.commands.registerCommand('cSpellExt_danish.enableDanishWorkspace', () => enableDanish(false)),
vscode.commands.registerCommand('cSpellExt_danish.disableDanishWorkspace', () => disableDanish(false))
vscode.commands.registerCommand('cSpellExt_danish.enableDanish', () => enable(true)),
vscode.commands.registerCommand('cSpellExt_danish.disableDanish', () => disable(true)),
vscode.commands.registerCommand('cSpellExt_danish.enableDanishWorkspace', () => enable(false)),
vscode.commands.registerCommand('cSpellExt_danish.disableDanishWorkspace', () => disable(false))
);
//
}

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

0 comments on commit ce1a54b

Please sign in to comment.