Skip to content

Commit

Permalink
Updated workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
timurbabs committed Jun 13, 2021
2 parents ceb13b1 + f0e47ae commit 67a5c4d
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 24 deletions.
204 changes: 185 additions & 19 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,193 @@
name: Java CI with Gradle

on:
pull_request:
branches:
- '*'
push:
branches:
- 'master'

branches: [master]
pull_request:
branches: [develop]
jobs:
gradleValidation:
name: Gradle Wrapper
runs-on: ubuntu-latest
steps:
- name: Fetch Sources
uses: actions/[email protected]

- name: Gradle Wrapper Validation
uses: gradle/[email protected]

test:
name: Test
needs: gradleValidation
runs-on: ubuntu-latest
steps:
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11

- name: Fetch Sources
uses: actions/[email protected]

- name: Setup Gradle Dependencies Cache
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}

- name: Setup Gradle Wrapper Cache
uses: actions/[email protected]
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}

- name: Run Linters and Test
env:
URL: ${{ secrets.URL }}
run: ./gradlew check

- name: Verify Plugin
env:
URL: ${{ secrets.URL }}
run: ./gradlew verifyPlugin

build:
name: Build
needs: test
runs-on: ubuntu-latest
outputs:
name: ${{ steps.properties.outputs.name }}
version: ${{ steps.properties.outputs.version }}
artifact: ${{ steps.properties.outputs.artifact }}
steps:
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11

- name: Fetch Sources
uses: actions/[email protected]

- name: Setup Gradle Dependencies Cache
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}

- name: Setup Gradle Wrapper Cache
uses: actions/[email protected]
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}

- name: Export Properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
NAME="$(echo "$PROPERTIES" | grep "^archivesBaseName:" | cut -f2- -d ' ')"
ARTIFACT="${NAME}-${VERSION}.zip"
echo "::set-output name=version::$VERSION"
echo "::set-output name=name::$NAME"
echo "::set-output name=artifact::$ARTIFACT"
- name: Build Plugin
env:
URL: ${{ secrets.URL }}
run: ./gradlew buildPlugin

- name: Upload artifact
uses: actions/[email protected]
with:
name: plugin-artifact
path: ./build/distributions/${{ steps.properties.outputs.artifact }}

verify:
name: Verify
needs: build
runs-on: ubuntu-latest
steps:
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11

- name: Fetch Sources
uses: actions/[email protected]

- name: Setup Gradle Dependencies Cache
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}

- name: Setup Gradle Wrapper Cache
uses: actions/[email protected]
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}

- name: Export Properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
echo "::set-output name=ideVersions::$IDE_VERSIONS"
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
- name: Setup Plugin Verifier IDEs Cache
uses: actions/[email protected]
with:
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}

- name: Verify Plugin
run: ./gradlew verifyPlugin

releaseDraft:
name: Release Draft
if: github.event_name != 'pull_request'
needs: [build, verify]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
env:
URL: ${{ secrets.URL }}
run: ./gradlew build
- name: Fetch Sources
uses: actions/[email protected]

- name: Remove Old Release Drafts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
| tr '\r\n' ' ' \
| jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' \
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
- name: Create Release Draft
id: createDraft
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.build.outputs.version }}
release_name: v${{ needs.build.outputs.version }}
draft: true

- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: plugin-artifact

- name: Upload Release Asset
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.createDraft.outputs.upload_url }}
asset_path: ./${{ needs.build.outputs.artifact }}
asset_name: ${{ needs.build.outputs.artifact }}
asset_content_type: application/zip
76 changes: 74 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,74 @@
# IntelliJ-Translator
comming soon...
# IntelliJ Translator
### Simple IntelliJ IDEA plugin for translate
<p float="left">
<img alt="Qries" src="https://img.shields.io/github/workflow/status/timurbabs/IntelliJ-Translator/Java%20CI%20with%20Gradle?style=flat-square">
<img alt="Qries" src="https://img.shields.io/github/v/release/timurbabs/IntelliJ-Translator?style=flat-square">
<img alt="Qries" src="https://img.shields.io/github/repo-size/timurbabs/IntelliJ-Translator?style=flat-square">
</p>

## Features
- The ability to both **replace** and simply **display** the translation of the text, taking into account **all special characters**.;
- The quality of the translation is comparable to that of **google translator**, because we use its **API** :)


## Installation
<a name="instruction"></a>
### Installation from disk
**1.** Download the **ZIP** file with the latest version of **IntelliJ Plugin** from [releases](https://github.com/timurbabs/IntelliJ-Translator/releases).
**2.** Press **Ctrl+Alt+S** to open IDE settings and select **Plugins**.
**3.** On the **Plugins** page, click :fa-cog: and then click **Install Plugin from Disk**.
**4.** Select the plugin archive file and click **OK**.
### Installation from source
**1.** Clone this repository.

`git clone https://github.com/timurbabs/IntelliJ-Translator.git`

**2.** In the cloned repository, run:

`~$ ./gradlew` for **Linux**
`> gradlew` for **Windows**

**3.** **ZIP** file with the plugin will appear in the **build/distributions** folder.
**4.** Follow [this](#instruction) instruction from **point 2**.

## Usage
### Replacing text

To translate text with replacement, press **Ctrl+\ , Ctrl+T** and select languages ​​for translation.

<img alt="Qries" src="https://sun9-9.userapi.com/impg/1xe7iskxjbplfrwG4Hc7ZxRItj1KC3IAU6KYNA/CJEE9SD6Lkk.jpg?size=407x135&quality=96&sign=4c529acda3237d3e4da4fee09c205330&type=album">

<img alt="Qries" src="https://sun9-28.userapi.com/impg/YIsrnC7b-GWDa6T0ojttj8LGNi23jJMpjBnjSA/SIgau3hve1w.jpg?size=173x69&quality=96&sign=dfe900630b91b9d9626eef4766772e9a&type=album">

<img alt="Qries" src="https://sun9-20.userapi.com/impg/OiQQ0Su4k95HmfAs9xIWAl-uTBt2IY_sT3c5Cg/aun01jM3hl8.jpg?size=173x72&quality=96&sign=01555b24b4d03c4ef60dfcefca2554c1&type=album">

You can also translate text with replacement **without choosing languages**. For this **select default languages ​​in the plugin settings** (**File -> Settings -> Tools -> Translator**) or by pressing **Ctrl+\ , Ctrl+S** , and then you do not have to select languages ​​for translation.
For replacing without choosing languages press **Ctrl+\ , Ctrl+P**.

If you do not know the language from which you are going to translate, you can use the **automatic language detection**. For this press **Ctrl+\ , Ctrl+[**. Тhe default language will be used as the language to translate into.

### Display text

If you **do not need to replace the text**, but you just want to find out its translation, then you can **display** it on the screen by pressing **Сtrl+\, Ctrl+R**, to choose language from menu.

[![](https://sun9-51.userapi.com/impg/JyO40X09FA_JhQk9dXWHzeS3pKNFAklEKNUQjA/PecfT-8k81w.jpg?size=177x94&quality=96&sign=5fd9d0bb58afcd4a4959619e464adcee&type=album)](https://sun9-51.userapi.com/impg/JyO40X09FA_JhQk9dXWHzeS3pKNFAklEKNUQjA/PecfT-8k81w.jpg?size=177x94&quality=96&sign=5fd9d0bb58afcd4a4959619e464adcee&type=album)


If you do not want to choose a language or do not know the word in which language in front of you, then you can use the option of **displaying without choosing** a language (**Ctrl+\, Ctrl+Q**) or the ability to **automatically detect** the language (**Ctrl+\ , Ctrl+]**).


------------


### You can access all previous hotkeys by pressing **right-click** and select IntelliJ Translator menu.

[![](https://sun9-32.userapi.com/impg/Sq6qQ4_lbuPlbjBsmzU3kMZiL6XE69u5teVQtA/CX9lqO6-X0s.jpg?size=767x480&quality=96&sign=2f4538ee6d515ce8ebc9e751e63d26c1&type=album)](https://sun9-32.userapi.com/impg/Sq6qQ4_lbuPlbjBsmzU3kMZiL6XE69u5teVQtA/CX9lqO6-X0s.jpg?size=767x480&quality=96&sign=2f4538ee6d515ce8ebc9e751e63d26c1&type=album)

------------

### You can change hotkeys in File -> Settings -> Keymap -> Plugins -> Translator.

------------


### IntelliJ Translator can translate only selected text!
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'com.devtools.java'
version '1.0-SNAPSHOT'
version '0.1.1'

repositories {
mavenCentral()
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pluginName_ = IntelliJ-Translator
pluginVersion = 0.1.1
pluginVerifierIdeVersions = 2019.3.5, 2020.1.4, 2020.2.3
27 changes: 26 additions & 1 deletion src/main/java/translators/Languages.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,32 @@ public enum Languages {
Chinese ("zh"),
Czech ("cs"),
Italian ("it"),
Japanese ("ja");
Japanese ("ja"),
Arabic ("ar"),
Afrikaans ("af"),
Bengali ("bn"),
Bulgarian ("bg"),
Danish ("da"),
Finnish ("fi"),
Georgian ("ka"),
Greek ("el"),
Hindi ("hi"),
Indonesian ("id"),
Irish ("ga"),
Kazakh ("kk"),
Latin ("la"),
Macedonian ("mk"),
Mongolian ("mn"),
Norwegian ("no"),
Polish ("pl"),
Portuguese ("pt"),
Romanian ("ro"),
Serbian ("sr"),
Slovak ("sk"),
Swedish ("sv"),
Thai ("th"),
Turkish ("tr"),
Vietnamese ("vi");

private final String title;

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<description>Student project. Plugin for intellij idea to translate text in code.</description>

<version>1.0.0</version>
<version>0.1.1</version>
<change-notes>Initial release of the plugin. vsem dobra kto chitaet :)</change-notes>

<depends>com.intellij.modules.platform</depends>
Expand Down

0 comments on commit 67a5c4d

Please sign in to comment.