DanielNT / ALTranslationCenter

Extension for improving speed in multilanguage developing with AL Language.
0 stars 0 forks source link

Set Default Language per Extension Setting #8

Closed wansinby closed 1 year ago

wansinby commented 1 year ago

Dear Daniel,

I tried to enhance the old extension "AL Language Tool" before I found your great improvements. One of the things I tried was to set the default language in the snippets by a setting in the extension settings, and I got it to work. Do you think you could improve your snippets with some features like:

Here is my code-example for a snippet with variable content (danm, markdown kills the code, I attach it as a file):

export function tcaptionWithComment() { vscode.languages.registerCompletionItemProvider('al', { provideCompletionItems(doc, pos, token, context) { var defaultLanguage = vscode.workspace.getConfiguration('al-myvscextension').get("defaultLanguage", "DEU"); var defaultLanguageInShortcut = vscode.workspace.getConfiguration('al-myvscextension').get("defaultLanguageInShortcut", "false"); var captionString = Caption = '\${1:EnglishText}', Comment = '; var shortcutcounter = 2; // the next shortcut if (defaultLanguageInShortcut) { captionString = captionString + \${${shortcutcounter}:${defaultLanguage}}; shortcutcounter = shortcutcounter + 1; } else { captionString = captionString + ${defaultLanguage}; } captionString = captionString + =\"\${${shortcutcounter}:YourLanguageText}\"';$0; shortcutcounter += 1; // not used now, but count up if used later return [ { label: "tcaptionWithComment (AL MyVSCExt)", insertText: new vscode.SnippetString(captionString), detail: "UI Texts: Caption with comment (AL MyVSCExt)", kind: vscode.CompletionItemKind.Snippet, }, ]; } }); }

(Please excuse if the code is bad, this is my first time I tried to code in Javascript/Typescript)

Best regards, Wolfram AL Snippet with variable content.txt

DanielNT commented 1 year ago

Hi @wansinby interesting feature and not too difficult to add. I will consider it for adding in next versions.

DanielNT commented 1 year ago

@wansinby I have published a new extension based in your suggestions. It is a preview version, try it and give me feedback.

AL Translation Snippets

wansinby commented 1 year ago

Dear Daniel, great new extension, works as expected. I will use it now (even it is marked as preview). Best regards, Wolfram