Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support and automatic deployment #2

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
248ae0c
fix(#1): remove empty line only if its not in primary mutation
Aug 3, 2022
6c34fdb
fix(#1): do retries only in case of specific sheet exception (limit e…
Aug 3, 2022
45d50a2
Merge branch '1-removing-empty-lines-in-mutations' into 'master'
Aug 3, 2022
43ec5d6
Ignore JavaDoc errors.
Aug 25, 2022
3675a13
[maven-release-plugin] prepare release babylon-maven-plugin-2.0.9
Aug 25, 2022
95551c9
[maven-release-plugin] prepare for next development iteration
Aug 25, 2022
2132e91
feat(#2): add typescript support
Sep 23, 2023
8b2b37c
feat(#2): add typescript support
Sep 23, 2023
8cde91f
feat(#2): add typescript support
Sep 23, 2023
28c5920
feat(#2): add typescript support
Sep 24, 2023
0893b19
feat(#2): add typescript support
Sep 24, 2023
2001457
feat(#2): add typescript support
Sep 24, 2023
11adf57
feat(#2): replace with correct TS grammar
Oct 4, 2023
5e72689
feat(#3): escape new line from import and export
Jan 8, 2024
582d106
Merge branch '2-add-typescript-support' into deploy-test
Feb 20, 2024
b84040a
feat: github CI
Feb 20, 2024
0dc1e43
feat: github CI
Feb 20, 2024
7e6fc2c
feat: github CI
Feb 21, 2024
b4987eb
[maven-release-plugin] prepare release 2.0.11
Feb 21, 2024
b76eb1d
[maven-release-plugin] prepare for next development iteration
Feb 21, 2024
d0d5127
feat: github CI
Feb 21, 2024
ff368ae
feat: github CI
Feb 21, 2024
6f764c3
feat: github CI
Feb 21, 2024
6654bb8
feat: github CI
Feb 21, 2024
9152e3a
feat(#3): add Deepl automation integration
Feb 28, 2024
b9403fb
feat(#3): add Deepl automation integration - default lang
Feb 29, 2024
e2b495d
feat(#3): add Deepl automation integration - change params
Feb 29, 2024
a02b87c
feat(#3): add google translator
Mar 8, 2024
769da9a
feat(#3): add google translator
Mar 8, 2024
58ea24c
feat(#3): add chatgpt translator a configurations
Mar 10, 2024
f456970
feat(#3): add chatgpt translator a configurations
Mar 10, 2024
0476ba5
fix: typo
Mar 11, 2024
0cc15e7
fix: timeout
Mar 11, 2024
bf76a44
fix: locking sheets
Mar 13, 2024
95e9cd6
fix: debug
Mar 19, 2024
dce2761
feat: linux support
Mar 20, 2024
c66a0a1
Merge pull request #1 from Kamest/ska
Kamest Mar 20, 2024
70f1507
feat: NPE fix
Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
latest: 'true'

prerelease: true
prerelease-identifier: 'alpha'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
autolabeler:
- label: 'bug'
branch:
- '/fix\/.+/'
title:
- '/fix/i'
- label: 'enhancement'
branch:
- '/feature\/.+/'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.

template: |
## Changes

$CHANGES
120 changes: 120 additions & 0 deletions .github/workflows/ci-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Main build pipeline, operates on `master` branch which is our integration branch and creates release

name: CI Master branch

on:
push:
branches: [ "master" ] # trap each push to master branch TODO SKA change back to master
paths: # but react only to changes in code or pipeline definition
- src/**.*
- .github/**.*

concurrency:
group: ${{ github.ref_name }} # for the same branch
cancel-in-progress: true # run only one workflow at a time (cancel the previous)

jobs:
build:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
outputs:
release_id: ${{ steps.create_release.outputs.id }}
released_version: ${{ steps.release_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3 # checkout sources
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Resolve new release version
id: release_version
uses: lukashornych/[email protected]
with:
prefix: 'v'
year_switch_mode: 'OnMinor'
minor-identifier: '/feat(?:\\([^)]+\\))?:/'

- name: Setup Java JDK
uses: actions/setup-java@v3
with: # running setup-java again overwrites the settings.xml
java-version: 8
distribution: 'temurin'
cache: 'maven'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Build with Maven # run Maven without tests (tests must pass in dev branch)
run: |
export CURRENT_VERSION="${{ steps.release_version.outputs.version }}"
export NEW_VERSION="$( echo ${CURRENT_VERSION} | sed 's/^v//')"
mvn versions:set -DnewVersion=$NEW_VERSION
mvn -T 1C -B -P release-sign-artifacts -Dmaven.test.skip=true deploy --file pom.xml
env:
EVITA_BUILD_VERSION: ${{ steps.release_version.outputs.version }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Create distribution directory
run: |
mkdir -p ./dist
cp LICENSE ./dist
cp 'target/babylon-boot.jar' ./dist

- name: Create .zip of dist
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'dist.zip'
path: './dist'

- name: Create .tar.gz of dist
uses: thedoctor0/[email protected]
with:
type: 'tar'
filename: 'dist.tar.gz'
path: './dist'

- name: Create release
id: create_release
uses: release-drafter/release-drafter@v5
with:
version: ${{ steps.release_version.outputs.version }}
publish: true

- name: Upload dist.zip to release
uses: actions/upload-release-asset@v1
if: success()
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist.zip
asset_name: Dist (zip)
asset_content_type: application/zip

- name: Upload dist.tar.gz to release
uses: actions/upload-release-asset@v1
if: success()
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist.tar.gz
asset_name: Dist (tar.gz)
asset_content_type: application/gzip

- name: Upload babylon server artifact # upload `babylon-boot.jar` for `docker-latest.yml` to deploy to DockerHub
uses: actions/upload-artifact@v2
if: success()
with:
name: babylon-boot.jar
path: 'target/babylon-boot.jar'
File renamed without changes.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Babylon

## Tool to automate Java property file translation.
## Tool to automate translation files.

### Description and usage

Babylon is a tool to gather messages, and their translations from property files. It performs a round-trip consisting of
Babylon is a tool to gather messages, and their translations from translation files. It performs a round-trip consisting of
two phases: *export* phase and *import* phase.

In the export phase the messages are written to a [Google Sheets](https://www.google.com/sheets/about/) spreadsheet.
A translator will then fill in the missing translations.

In the import phase, the spreadsheet (with the missing translations filled out by a translator) is examined, and the
newly translated messages are used to update the respective translation property files. Also, the state of the translation,
newly translated messages are used to update the respective translation files. Also, the state of the translation,
*snapshot*, is written out to a disk in the form of JSON file.

Babylon can be run as a Maven plugin or as a standalone console application.
Expand All @@ -25,6 +25,8 @@ To run Babylon:
- A Json configuration file must exist (see the "Configuration" section).
- A Google Sheets spreadsheet must exist (empty for the export phase).

Currently only supported file types are **.properties** and **.ts**

### Google Cloud user credentials

You need a Google Cloud project with Sheets API enabled. Also, you need to download the `credentials.json` client
Expand Down Expand Up @@ -122,7 +124,7 @@ mvn babylon:import -Dconfig.file=test-config.json -Dgoogle.sheet.id=1xhnBAOpy8-9

### Running Babylon as a console application

Application needs the following arguments: 1.action 2.config.json 3.google sheet id
Application needs the following arguments: 1.action 2.config.json 3.google sheet id (4. optional combineSheets)

1. expected action (export, import)
* `export` - takes all properties files specified in configuration file and export their properties into specified the Google spreadsheet. Each property
Expand All @@ -132,10 +134,13 @@ Application needs the following arguments: 1.action 2.config.json 3.google sheet
properties file (are present only in concrete mutation properties file) is placed at the end of the target mutation file.
2. path to translator-config.json file. This file serves as database for translation process.
3. ID of the Google spreadsheet (e.g. 1xhnBAOpy8-9KWhl8NP0ZIy6mhlgXKnKcLJwKcIeyjPc)
4. **Optional** boolean value whether export should be placed into only one sheet (only usable for debugging translations)

Command line examples:

``` shell
java -jar babylon-1.0-SNAPSHOT.jar export test-config.json 1xhnBAOpy8-9KWhl8NP0ZIy6mhlgXKnKcLJwKcIeyjPc
java -jar babylon-1.0-SNAPSHOT.jar import test-config.json 1xhnBAOpy8-9KWhl8NP0ZIy6mhlgXKnKcLJwKcIeyjPc
```


109 changes: 73 additions & 36 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>one.edee.oss</groupId>
<artifactId>babylon-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>2.0.9-SNAPSHOT</version>
<version>2.0.12-SNAPSHOT</version>
<name>Babylon - translation utility</name>
<url>https://github.com/FgForrest/Babylon/</url>
<description>
Expand Down Expand Up @@ -65,11 +65,38 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
<kotlin.version>1.4.20</kotlin.version>
<kotlin.version>1.9.0</kotlin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>4.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.theokanning.openai-gpt3-java</groupId>
<artifactId>service</artifactId>
<version>0.18.2</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-translate</artifactId>
</dependency>

<dependency>
<groupId>com.deepl.api</groupId>
<artifactId>deepl-java</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand All @@ -84,7 +111,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
<version>1.18.28</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand All @@ -99,7 +126,7 @@
<dependency>
<groupId>de.poiu.apron</groupId>
<artifactId>apron</artifactId>
<version>2.1.1-FGFIX</version>
<version>2.1.1</version>
</dependency>
<!-- Support for working with google spreadsheets -->
<dependency>
Expand Down Expand Up @@ -140,7 +167,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -167,9 +194,15 @@
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>4.13.1</version>
</dependency>
</dependencies>

<build>
<finalName>babylon</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -181,6 +214,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<failOnError>false</failOnError>
<doclint>none</doclint>
</configuration>
</plugin>
Expand All @@ -205,7 +239,8 @@
<localCheckout>true</localCheckout>
<pushChanges>false</pushChanges>
<mavenExecutorId>forked-path</mavenExecutorId>
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
<arguments>-Dgpg.passphrase=${gpg.passphrase} -DskipTests=true</arguments>
<releaseProfiles>release-sign-artifacts</releaseProfiles>
</configuration>
<dependencies>
<dependency>
Expand Down Expand Up @@ -347,38 +382,40 @@
</execution>
</executions>
</plugin>

</plugins>
</build>

<profiles>
<!-- GPG Signature on release -->
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<!-- GPG Signature on release -->
<profile>
<id>release-sign-artifacts</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Prevent gpg from using pinentry programs -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
</project>
Loading