Live Template: use i18n attributes, update docs

This commit is contained in:
Yann Cébron 2024-04-03 10:49:45 +02:00
parent 28e9ef8dc4
commit e4cfe8aeec
4 changed files with 14 additions and 8 deletions

View File

@ -32,6 +32,8 @@
<!-- Text to display as company information on Settings | Plugin page --> <!-- Text to display as company information on Settings | Plugin page -->
<vendor url="https://plugins.jetbrains.com">IntelliJ Platform SDK</vendor> <vendor url="https://plugins.jetbrains.com">IntelliJ Platform SDK</vendor>
<resource-bundle>messages.LiveTemplates</resource-bundle>
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
<defaultLiveTemplates file="/liveTemplates/Markdown.xml"/> <defaultLiveTemplates file="/liveTemplates/Markdown.xml"/>
<liveTemplateContext implementation="org.intellij.sdk.liveTemplates.MarkdownContext" <liveTemplateContext implementation="org.intellij.sdk.liveTemplates.MarkdownContext"

View File

@ -1,9 +1,9 @@
<templateSet group="Markdown"> <templateSet group="Markdown">
<template name="{" <template name="{"
value="[$TEXT$]($LINK$)$END$" value="[$TEXT$]($LINK$)$END$"
description="SDK: New link reference"
toReformat="false" toReformat="false"
toShortenFQNames="false"> toShortenFQNames="false"
key="live.template.{.description" resource-bundle="messages.LiveTemplates">
<variable name="TEXT" expression="" defaultValue="" alwaysStopAt="true"/> <variable name="TEXT" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="LINK" expression="complete()" defaultValue="" alwaysStopAt="true"/> <variable name="LINK" expression="complete()" defaultValue="" alwaysStopAt="true"/>
<context> <context>
@ -12,12 +12,12 @@
</template> </template>
<template name="mc" <template name="mc"
value="$TITLE$" value="$TITLE$"
description="SDK: Convert to title case"
toReformat="true" toReformat="true"
toShortenFQNames="false"> toShortenFQNames="false"
key="live.template.mc.description" resource-bundle="messages.LiveTemplates">
<variable name="TITLE" expression="titleCase(SELECTION)" defaultValue="the quick brown fox" alwaysStopAt="true" /> <variable name="TITLE" expression="titleCase(SELECTION)" defaultValue="the quick brown fox" alwaysStopAt="true" />
<context> <context>
<option name="MARKDOWN" value="true" /> <option name="MARKDOWN" value="true" />
</context> </context>
</template> </template>
</templateSet> </templateSet>

View File

@ -0,0 +1,2 @@
live.template.mc.description=SDK: Convert to title case
live.template.{.description=SDK: New link reference

View File

@ -1,6 +1,6 @@
# Providing Live Templates <!-- Copyright 2000-2024 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
<!-- Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. --> # Providing Live Templates
<link-summary>Adding custom Live Templates.</link-summary> <link-summary>Adding custom Live Templates.</link-summary>
@ -57,7 +57,9 @@ The export produces a file called <path>Markdown.xml</path> with the following c
</templateSet> </templateSet>
``` ```
The display `name` can also provide localized variants by specifying `key` and `resource-bundle` attributes additionally (2020.3 and later). The display `description` can also provide localized variants by specifying
`key` and `resource-bundle` attributes instead (code insight is available in 2020.3 and later).
A quick fix to extract the localized key is available since 2024.2.
Copy this file into the [plugin's resources folder](%gh-sdk-samples%/live_templates/src/main/resources/liveTemplates). Copy this file into the [plugin's resources folder](%gh-sdk-samples%/live_templates/src/main/resources/liveTemplates).