5 | GPT will ask you for a new value, and translate all other selected languages, too.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/changetranslation/domain/controller/ChangeTranslationController.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.changetranslation.domain.controller
2 |
3 | class ChangeTranslationController(
4 | ) {
5 | fun changeTranslation() {
6 |
7 | }
8 | }
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/domain/client/PartialFileTranslationResponse.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.client
2 |
3 | data class PartialFileTranslationResponse(
4 | val entry: Map = mutableMapOf(),
5 | )
6 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/psiutils/filter/DartStringLiteralFilter.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.psiutils.filter
2 |
3 | import com.intellij.psi.PsiElement
4 |
5 | interface DartStringLiteralFilter {
6 | fun filter(psiElement: PsiElement): Boolean
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/infrastructure/search/Suggestion.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.infrastructure.search
2 |
3 | data class Suggestion(
4 | val key: String,
5 | val value: String,
6 | val score: Double
7 | )
8 |
9 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/src/test/resources/psiutils/dart/const_modifier_finder/class_declaration_2.dart:
--------------------------------------------------------------------------------
1 | void main() {
2 | const Outer(Hello("Hello world"));
3 | }
4 |
5 | class Hello{
6 | final String text;
7 | const Hello(this.text);
8 | }
9 |
10 | class Outer{
11 | final Hello hello;
12 | const Outer(this.hello);
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/Translation.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | /**
4 | * represents a translation for a single language
5 | */
6 | data class Translation(val lang: Language, val entry: SimpleTranslationEntry) {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/ReplacementOfTranslationFailedException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | class ReplacementOfTranslationFailedException(message: String) : TranslationFileModificationException(message) {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/dto/GPTArbTranslationResponse.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.dto
2 |
3 | data class GPTArbTranslationResponse(
4 | val content: Map,
5 | ) {
6 | //toString, just print the de map
7 | }
8 |
--------------------------------------------------------------------------------
/qodana.yml:
--------------------------------------------------------------------------------
1 | # Qodana configuration:
2 | # https://www.jetbrains.com/help/qodana/qodana-yaml.html
3 |
4 | version: "1.0"
5 | linter: jetbrains/qodana-jvm-community:2024.3
6 | projectJDK: "21"
7 | profile:
8 | name: qodana.recommended
9 | some:
10 | more: nice
11 | exclude:
12 | - name: All
13 | paths:
14 | - .qodana
15 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/psiutils/arb/StringArrayContent.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.psiutils.arb
2 |
3 | /**
4 | * Often used in arb intl files
5 | * e.g. "de" -> "key1", "key2"
6 | */
7 | data class StringArrayContent(
8 | val key: String,
9 | val values: List,
10 | )
--------------------------------------------------------------------------------
/src/main/java/de/keeyzar/gpthelper/gpthelper/features/flutterarb/presentation/handler/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * we need to parse .arb files and also untranslated_messages.txt (which is json) to get keys and values which are not (yet) translated or must be updated
3 | */
4 | package de.keeyzar.gpthelper.gpthelper.features.flutterarb.presentation.handler;
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/review/domain/entity/AskUserForReviewResult.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.review.domain.entity
2 |
3 | data class AskUserForReviewResult(
4 | val closedWithReview: Boolean,
5 | val closedWithShouldAskLater: Boolean,
6 | val closedWithDontAskAgain: Boolean,
7 | )
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/UserAddNewLanguageRequest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | data class UserAddNewLanguageRequest(
4 | val oldFileContent: String,
5 | // format is either en_US or en
6 | val targetLanguage: String,
7 | )
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/shared/domain/service/InstallFileProvider.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.shared.domain.service
2 |
3 | interface InstallFileProvider {
4 | fun fileExists(path: String): Boolean
5 | fun readFile(path: String): String?
6 | fun writeFile(path: String, content: String)
7 | }
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/infrastructure/search/ArbIndexEntry.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.infrastructure.search
2 |
3 | data class ArbIndexEntry(
4 | val key: String,
5 | val value: String,
6 | val normalizedValue: String,
7 | val trigrams: Set
8 | )
9 |
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/client/BestGuessRequest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.client
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity.FileBestGuessContext
4 |
5 | data class BestGuessRequest(
6 | val context: FileBestGuessContext,
7 | ) {
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/repository/TranslationCredentialsServiceRepository.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.repository
2 |
3 | interface TranslationCredentialsServiceRepository {
4 | fun persistKey(key: String)
5 | fun getKey(): String?
6 | fun hasPassword(): Boolean
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/review/domain/service/AskUserForReviewService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.review.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.review.domain.entity.AskUserForReviewResult
4 |
5 | fun interface AskUserForReviewService {
6 | fun askUserForReview(): AskUserForReviewResult?
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/client/ClientConnectionTester.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.client
2 |
3 | /**
4 | * should be used to find out whether the client has a connection
5 | */
6 | fun interface ClientConnectionTester {
7 | suspend fun testClientConnection(key: String): Throwable?
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/ConsoleService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | /**
4 | *
5 | */
6 | interface ConsoleService {
7 | /**
8 | * opens console, executes command, closes console
9 | */
10 | fun executeCommand(command: String)
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/shared/domain/service/PathProvider.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.shared.domain.service
2 |
3 | /**
4 | * Provides paths for the current project.
5 | */
6 | interface PathProvider {
7 | /**
8 | * Returns the root path of the project.
9 | */
10 | fun getRootPath(): String
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/infrastructure/service/TargetLanguageProvider.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.infrastructure.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
4 |
5 | fun interface TargetLanguageProvider {
6 | fun getTargetLanguage(): Language?
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/flutter_intl/domain/exceptions/FlutterIntlFileNotFound.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.flutter_intl.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | open class FlutterIntlFileNotFound(message: String) : GPTHelperBaseException(message) {
6 | }
7 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/client/BatchPartialTranslationResponse.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.client
2 |
3 | /**
4 | * Response containing multiple partial translations
5 | */
6 | data class BatchPartialTranslationResponse(
7 | val responses: List
8 | )
9 |
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/infrastructure/model/AutoLocalizeContext.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.infrastructure.model
2 |
3 | import com.intellij.openapi.project.Project
4 | import com.intellij.psi.PsiFile
5 |
6 | data class AutoLocalizeContext(
7 | val project: Project,
8 | val baseFile: PsiFile,
9 | )
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/ChangeTranslationContext.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | /**
4 | * contains information for changing a single translation
5 | */
6 | class ChangeTranslationContext(
7 | var key: String,
8 | var value: String,
9 | var description: String,
10 | )
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/TranslationProgressBus.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.TranslationProgress
4 |
5 | interface TranslationProgressBus {
6 | fun pushPercentage(translationProgress: TranslationProgress)
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/CurrentFileModificationContext.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | /**
4 | * what is required to modify the current file, i.e. fix imports, fix current statement
5 | */
6 | data class CurrentFileModificationContext(
7 | val userTranslationInput: UserTranslationInput,
8 | )
9 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/domain/entity/Context.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.entity
2 |
3 | /**
4 | * Context for the translation in general,
5 | * while metadata is some extra data you can use to push some additional data through the domain
6 | */
7 | interface Context {
8 | fun getMetadata(): T
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/missingtranslations/domain/entity/ExistingTranslation.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.entity
2 |
3 | /**
4 | * the translation that is already present in the arb files
5 | */
6 | class ExistingTranslation(
7 | val key: String,
8 | val value: String,
9 | val description: String?,
10 | ) {
11 | }
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/model/TranslateWholeFileContext.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.model
2 |
3 | import com.intellij.openapi.project.Project
4 | import com.intellij.psi.PsiFile
5 |
6 | class TranslateWholeFileContext(
7 | val baseFile: PsiFile,
8 | val project: Project,
9 | ) {
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/review/domain/repository/ReviewRepository.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.review.domain.repository
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.review.domain.entity.ReviewSettings
4 |
5 | interface ReviewRepository {
6 | fun getReviewSettings(): ReviewSettings
7 | fun saveReviewSettings(reviewSettings: ReviewSettings)
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/domain/service/FinishedFileTranslationHandler.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.entity.TranslateFileContext
4 |
5 | fun interface FinishedFileTranslationHandler {
6 | fun finishedTranslation(context: TranslateFileContext)
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/UserTranslationResponse.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | /**
4 | * represents all translations for all files, because the original translation might be modified because
5 | * of wording etc.
6 | */
7 | class UserTranslationResponse(var translations: List) {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/ExternalTranslationProcessService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | /**
4 | * in flutter e.g. you need to trigger a process after modification, might not be necessary for different languages
5 | */
6 | fun interface ExternalTranslationProcessService {
7 | fun postTranslationProcess()
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/service/WaitingIndicatorService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.service
2 |
3 | import java.util.*
4 |
5 | interface WaitingIndicatorService {
6 | fun startWaiting(uuid: UUID, title: String, description: String)
7 | fun stopWaiting()
8 | fun updateProgress(uuid: UUID, progressText: String)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/flutter_intl/domain/exceptions/FlutterIntlFileParseException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.flutter_intl.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | open class FlutterIntlFileParseException(message: String, cause: Throwable) : GPTHelperBaseException(message, cause) {
6 | }
7 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/client/BestGuessResponse.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.client
2 |
3 | /**
4 | * this is a simple Best Guess Response.
5 | * There is also some more complex l10n possibilities, but let's ignore them for now
6 | */
7 | data class BestGuessResponse(
8 | val responseEntries: List
9 | )
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/domain/client/FileTranslationRequest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.client
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
4 |
5 | data class FileTranslationRequest(
6 | val content: String,
7 | val targetLanguage: Language,
8 | val baseLanguage: Language,
9 | )
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/setup/domain/service/YamlModificationService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.setup.domain.service
2 |
3 | interface YamlModificationService {
4 | fun addDependency(yamlContent: String, dependencyName: String, dependencyValue: Any): String
5 | fun addFlutterGenerate(yamlContent: String): String
6 | fun createL10nYaml(l10nConfigMap: Map): String
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/FormatTranslationFileContentService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.FileToTranslate
4 |
5 | fun interface FormatTranslationFileContentService {
6 | fun formatTranslationFileContent(fileToTranslate: FileToTranslate): FileToTranslate
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/UserTranslateStringRequest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | data class UserTranslateStringRequest(
4 | val desiredKey: String,
5 | val desiredValue: String,
6 | val desiredDescription: String,
7 | /**
8 | * format is either en_US or en
9 | */
10 | val langsToTranslate: Set,
11 | )
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/service/MultiKeyTranslationTaskSizeEstimator.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity.MultiKeyTranslationContext
4 |
5 | fun interface MultiKeyTranslationTaskSizeEstimator {
6 | fun estimateTaskSize(multiKeyTranslationContext: MultiKeyTranslationContext): Int
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/UserTranslationRequest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | data class UserTranslationRequest (
4 | /**
5 | * the languages to translate to
6 | */
7 | val targetLanguages: List,
8 | /**
9 | * the base translation to translate from
10 | */
11 | val baseTranslation: Translation,
12 | ) {
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/presentation/pojo/TranslationDialogUserInput.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.presentation.pojo
2 |
3 | data class TranslationDialogUserInput(
4 | val translationsChecked: MutableMap,
5 | var desiredValue: String,
6 | var desiredKey: String,
7 | var desiredDescription: String,
8 | var translateNow: Boolean // NEU: Checkbox-Wert
9 | )
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/missingtranslations/domain/entity/MissingTranslation.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.entity
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
4 |
5 | /**
6 | * e.g. "greeting" might be missing in "de, pl, fr"
7 | */
8 | data class MissingTranslation(
9 | val key: String,
10 | var languagesMissing : List,
11 | )
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/service/LastStatementProviderForFlutterArbTranslation.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.service
2 |
3 | import com.intellij.psi.PsiElement
4 |
5 | /**
6 | * TODO this is an issue, I need to fix... I need some kind of map at least
7 | */
8 | class LastStatementProviderForFlutterArbTranslation {
9 | var lastStatement: PsiElement? = null
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/presentation/dto/BestGuessWithPsiReference.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.presentation.dto
2 |
3 | import com.intellij.psi.PsiElement
4 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.client.BestGuessResponseEntry
5 |
6 | data class BestGuessWithPsiReference(
7 | val id: String,
8 | val psiElement: PsiElement,
9 | val bestGuess: BestGuessResponseEntry,
10 | ) {
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/client/BestGuessResponseEntry.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.client
2 |
3 | /**
4 | * this is a simple Best Guess Response.
5 | * There is also some more complex l10n possibilities, but let's ignore them for now
6 | */
7 | data class BestGuessResponseEntry(
8 | val id: String,
9 | val key: String,
10 | val description: String,
11 | val placeholder: Map? = null
12 | )
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/entity/PreFilterResponse.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity
2 |
3 | /**
4 | * Response from pre-filtering indicating which literals should be translated
5 | */
6 | data class PreFilterResponse(
7 | val results: List
8 | )
9 |
10 | data class PreFilterResult(
11 | val id: String,
12 | val shouldTranslate: Boolean,
13 | val reason: String? = null
14 | )
15 |
16 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/shared/domain/exception/ProgrammerException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | open class ProgrammerException : GPTHelperBaseException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/missingtranslations/domain/entity/MissingTranslationAndExistingTranslation.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.entity
2 |
3 | /**
4 | * contains the missing translations and the corresponding existing translation which the user wants to translate
5 | */
6 | data class MissingTranslationAndExistingTranslation(
7 | val missingTranslation: MissingTranslation,
8 | var existingTranslation: ExistingTranslation?
9 | )
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/setup/domain/model/SetupProcessModel.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.setup.domain.model
2 |
3 | /**
4 | * A simple domain model to pass data between the steps of the setup process.
5 | */
6 | data class SetupProcessModel(
7 | var pubspecContent: String,
8 | var l10nFileContent: String? = null,
9 | var mainAppFileContent: String,
10 | var mainAppFilePath: String = "lib/main.dart" // Default path, can be updated
11 | )
12 |
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/client/BatchClientTranslationRequest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.client
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
4 |
5 | /**
6 | * Batch request for creating multiple complex ARB entries at once
7 | */
8 | data class BatchClientTranslationRequest(
9 | val targetLanguages: List,
10 | val requests: List
11 | )
12 |
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/BasePathSettingMissing.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | class BasePathSettingMissing : UserSettingsException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/GatherTranslationContextService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.TranslateKeyContext
4 |
5 | /**
6 | * gather information required to request the information from the user
7 | */
8 | fun interface GatherTranslationContextService {
9 | fun gatherTranslationContext(statement: String?): TranslateKeyContext
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/FilePrefixSettingMissing.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | class FilePrefixSettingMissing : UserSettingsException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/GatherContextException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | open class GatherContextException : GPTHelperBaseException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/UserSettingsException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | open class UserSettingsException : GPTHelperBaseException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/exception/BestGuessClientException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.exception
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | open class BestGuessClientException : GPTHelperBaseException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/client/TaskAmountCalculator.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.client
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.TranslateKeyContext
4 |
5 | /**
6 | * Because the translation is broken down into multiple tasks, and we don't know how many tasks, we need to get the information
7 | */
8 | fun interface TaskAmountCalculator {
9 | fun calculate(context: TranslateKeyContext): Int
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/domain/factories/TranslationRequestFactory.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.factories
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.client.FileTranslationRequest
4 | import de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.entity.TranslateFileContext
5 |
6 | fun interface TranslationRequestFactory {
7 | fun createRequest(translateFileContext: TranslateFileContext): FileTranslationRequest
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/TranslationRequestException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Translation
5 |
6 | class TranslationRequestException(message: String, cause: Throwable, private var targetTranslation: Translation) : GPTHelperBaseException(message, cause) {
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/UserSettingsCorruptException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions.UserSettingsException
4 |
5 | class UserSettingsCorruptException : UserSettingsException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/UserSettingsMissingException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions.UserSettingsException
4 |
5 | class UserSettingsMissingException : UserSettingsException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/domain/service/GatherFileTranslationContext.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.entity.TranslateFileContext
4 | import java.util.UUID
5 |
6 | /**
7 | * gather information required to request the information from the user
8 | */
9 | fun interface GatherFileTranslationContext {
10 | fun gatherTranslationContext(uuid: UUID): TranslateFileContext?
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/missingtranslations/domain/repository/ExistingTranslationRepository.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.repository
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.entity.ExistingTranslation
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
5 |
6 | interface ExistingTranslationRepository {
7 | fun getExistingTranslation(reference: T, baseLanguage: Language, key: String): ExistingTranslation?
8 | }
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/VerifyTranslationSettingsService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | /**
4 | * ensure that all settings are set, which are required to fulfill the current translation request
5 | */
6 | fun interface VerifyTranslationSettingsService {
7 | /**
8 | * whether the settings are set, if not, the user should be informed / asked to set them
9 | */
10 | fun verifySettingsAndInformUserIfInvalid(): Boolean
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/TranslationClientConnectionException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | open class TranslationClientConnectionException : GPTHelperBaseException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/domain/service/PartialFileResponseHandler.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.client.PartialFileTranslationResponse
4 | import de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.entity.TranslateFileContext
5 |
6 | fun interface PartialFileResponseHandler {
7 | fun handlePartialFileResponse(context: TranslateFileContext, partialFileTranslationResponse: PartialFileTranslationResponse)
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/shared/presentation/mapper/UserSettingsDTOMapper.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.shared.presentation.mapper
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.infrastructure.model.UserSettings
4 | import de.keeyzar.gpthelper.gpthelper.features.shared.presentation.dto.UserSettingsDTO
5 | import org.mapstruct.Mapper
6 |
7 | @Mapper
8 | interface UserSettingsDTOMapper {
9 | fun toModel(userSettingsDTO: UserSettingsDTO): UserSettings
10 | fun toDTO(userSettings: UserSettings): UserSettingsDTO
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/FileToTranslate.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | /**
4 | * is the representation of a file in our domain
5 | */
6 | data class FileToTranslate(
7 | /**
8 | * the language of the file
9 | */
10 | val language: Language,
11 | /**
12 | * the content of the file, e.g. arb is JSON, but there might be other formats
13 | * might theoretically be a simple translation entry
14 | */
15 | val content: String,
16 | ) {
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/translationdialogdata/TranslationDialogDataException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions.translationdialogdata
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | open class TranslationDialogDataException : GPTHelperBaseException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/entity/PreFilterRequest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity
2 |
3 | import com.intellij.psi.PsiElement
4 |
5 | /**
6 | * Request for pre-filtering string literals to determine which ones should be translated
7 | */
8 | data class PreFilterRequest(
9 | val literals: List
10 | )
11 |
12 | data class PreFilterLiteral(
13 | val id: String,
14 | val literalText: String,
15 | val context: String,
16 | val psiElement: PsiElement
17 | )
18 |
19 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/review/infrastructure/mapper/ReviewSettingsMapper.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.review.infrastructure.mapper
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.review.domain.entity.ReviewSettings
4 | import de.keeyzar.gpthelper.gpthelper.features.review.infrastructure.model.ReviewSettingsModel
5 | import org.mapstruct.Mapper
6 |
7 | @Mapper
8 | interface ReviewSettingsMapper {
9 | fun toModel(entity: ReviewSettings): ReviewSettingsModel
10 | fun toEntity(model: ReviewSettingsModel): ReviewSettings
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/infrastructure/mapper/FileTranslationRequestMapper.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.infrastructure.mapper
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper
4 | import de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.client.FileTranslationRequest
5 |
6 | class FileTranslationRequestMapper(
7 | private val objectMapper: ObjectMapper,
8 | ) {
9 | fun mapToContentString(fileTranslationRequest: FileTranslationRequest): List {
10 | TODO()
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/presentation/exception/PsiElementException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.presentation.exception
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | /**
6 | * when there was some issue with the statements
7 | */
8 | class PsiElementException : GPTHelperBaseException {
9 | constructor() : super()
10 | constructor(message: String?) : super(message)
11 | constructor(message: String?, cause: Throwable?) : super(message, cause)
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/translationdialogdata/TranslationDialogDataCorruptException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions.translationdialogdata
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions.UserSettingsException
4 |
5 | class TranslationDialogDataCorruptException : UserSettingsException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/translationdialogdata/TranslationDialogDataMissingException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions.translationdialogdata
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions.UserSettingsException
4 |
5 | class TranslationDialogDataMissingException : UserSettingsException {
6 | constructor() : super()
7 | constructor(message: String?) : super(message)
8 | constructor(message: String?, cause: Throwable?) : super(message, cause)
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/psiutils/PsiElementIdGenerator.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.psiutils
2 |
3 | import com.intellij.openapi.application.runReadAction
4 | import com.intellij.psi.PsiElement
5 |
6 | class PsiElementIdGenerator {
7 | /**
8 | * hash the psi element and return a unique id
9 | * TODO: this id generation here is not really secure
10 | */
11 | fun createIdFromPsiElement(psiElement: PsiElement): String {
12 | return runReadAction {
13 | psiElement.text.hashCode().toString()
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/client/TranslateKeyTaskAmountCalculator.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.client
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.client.TaskAmountCalculator
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.TranslateKeyContext
5 |
6 | class TranslateKeyTaskAmountCalculator : TaskAmountCalculator {
7 | override fun calculate(context: TranslateKeyContext): Int {
8 | return context.availableLanguages.size
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/shared/infrastructure/service/IdeaPathProvider.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.shared.infrastructure.service
2 |
3 | import com.intellij.openapi.project.Project
4 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.service.PathProvider
5 |
6 | /**
7 | * IntelliJ IDEA implementation of the PathProvider.
8 | * For this example, it returns a dummy path.
9 | */
10 | class IdeaPathProvider(val project: Project) : PathProvider {
11 | override fun getRootPath(): String {
12 | return project.basePath!!
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/NoTranslationFilesException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | /**
6 | * one could theoretically ask the user to create translation files
7 | */
8 | open class NoTranslationFilesException : GPTHelperBaseException {
9 | constructor() : super()
10 | constructor(message: String?) : super(message)
11 | constructor(message: String?, cause: Throwable?) : super(message, cause)
12 | }
13 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
16 |
17 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/ExecuteGenCommandProcessServiceException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | /**
6 | * when there was an issue executing the gen command
7 | */
8 | open class ExecuteGenCommandProcessServiceException : GPTHelperBaseException {
9 | constructor() : super()
10 | constructor(message: String?) : super(message)
11 | constructor(message: String?, cause: Throwable?) : super(message, cause)
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/ContentModificationService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.FileToTranslate
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Translation
5 |
6 | interface ContentModificationService {
7 | fun appendTranslation(fileToTranslate: FileToTranslate, translation: Translation) : FileToTranslate
8 | fun replaceWithNewTranslation(fileToTranslate: FileToTranslate, translation: Translation) : FileToTranslate
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/client/ClientTranslationRequest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.client
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Translation
5 |
6 | data class ClientTranslationRequest (
7 | /**
8 | * the languages to translate to
9 | */
10 | val targetLanguages: List,
11 | /**
12 | * this is the base translation to translate from
13 | */
14 | val translation: Translation,
15 | ) {
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/mapper/UserSettingsMapper.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.mapper
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.infrastructure.model.UserSettings
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.repository.UserSettingsPersistentStateComponent.UserSettingsModel
5 | import org.mapstruct.Mapper
6 |
7 | @Mapper
8 | interface UserSettingsMapper {
9 | fun toEntity(userSettingsModel: UserSettingsModel): UserSettings
10 | fun toModel(userSettings: UserSettings): UserSettingsModel
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/psiutils/filter/ImportStatementFilterDartString.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.psiutils.filter
2 |
3 | import com.intellij.psi.PsiElement
4 | import com.intellij.psi.util.parentOfType
5 | import com.jetbrains.lang.dart.psi.DartImportOrExportStatement
6 |
7 | /**
8 | * filters importStatements
9 | */
10 | class ImportStatementFilterDartString : DartStringLiteralFilter {
11 | override fun filter(psiElement: PsiElement): Boolean {
12 | psiElement.parentOfType()?.let {
13 | return false
14 | }
15 | return true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/repository/UserSettingsRepository.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.repository
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.infrastructure.model.UserSettings
4 |
5 | interface UserSettingsRepository {
6 | /**
7 | * provides the old userSettings, so you can modify it, and return it with the copy function
8 | */
9 | fun overrideSettings(callback: (oldUserSettings: UserSettings) -> UserSettings)
10 | fun getSettings(): UserSettings
11 | fun saveSettings(userSettings: UserSettings)
12 | fun wipeUserSettings()
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/repository/UserTranslationInputRepository.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.repository
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.UserTranslationInput
4 |
5 | interface UserTranslationInputRepository {
6 | fun appendTranslationDialogData(userTranslationInput: UserTranslationInput)
7 | fun saveTranslationDialogData(userTranslationDialogData: List)
8 | fun getLatestTranslationDialogData(): UserTranslationInput?
9 | fun getAllTranslationDialogData(): List
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/client/BestGuessL10nClient.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.client
2 |
3 | /**
4 | * will provide best guesses for translation keys, so the user does not have to type so many manually
5 | */
6 | interface BestGuessL10nClient {
7 | /**
8 | * provides, based on context, l10n keys and descriptions
9 | * simple in context of the l10n type, i.e. you could have a more complex type having parameters for example
10 | */
11 | suspend fun simpleGuess(bestGuessRequest: BestGuessRequest, progressReport: (() -> Unit)? = null): BestGuessResponse
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/CurrentFileModificationException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | /**
6 | * when there were issues with manipulation of the current file, where we want to fix the statements / imports
7 | */
8 | open class CurrentFileModificationException : GPTHelperBaseException {
9 | constructor() : super()
10 | constructor(message: String?) : super(message)
11 | constructor(message: String?, cause: Throwable?) : super(message, cause)
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/missingtranslations/domain/service/MissingTranslationInputService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.entity.MissingTranslationFilteredTargetTranslation
4 | import de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.entity.MissingTranslationAndExistingTranslation
5 |
6 | interface MissingTranslationInputService {
7 | fun collectMissingTranslationInput(missingTranslationAndExistingTranslations: List): List
8 | }
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/shared/domain/exception/GPTHelperBaseException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception
2 |
3 | open class GPTHelperBaseException : Throwable {
4 | constructor(message: String?, cause: Throwable?) : super(message, cause)
5 | constructor(message: String?) : super(message)
6 | constructor(cause: Throwable?) : super(cause)
7 | constructor() : super()
8 | constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super(
9 | message,
10 | cause,
11 | enableSuppression,
12 | writableStackTrace
13 | )
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/SimpleTranslationEntry.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | /**
4 | * single entry in a translation file
5 | */
6 | data class SimpleTranslationEntry(
7 | //used as some kind of identifier
8 | //TODO remove the nullable id, translation process is the culprit
9 | val id: String?,
10 | val desiredKey: String,
11 | val desiredValue: String,
12 | val desiredDescription: String,
13 | /**
14 | * placeholder might be null, when there is nothing to replace
15 | */
16 | val placeholder: Map? = null
17 | ) {
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/github/keeyzar/gpthelper/MyBundle.kt:
--------------------------------------------------------------------------------
1 | package com.github.keeyzar.gpthelper
2 |
3 | import com.intellij.DynamicBundle
4 | import org.jetbrains.annotations.NonNls
5 | import org.jetbrains.annotations.PropertyKey
6 |
7 | @NonNls
8 | private const val BUNDLE = "messages.MyBundle"
9 |
10 | object MyBundle : DynamicBundle(BUNDLE) {
11 |
12 | @JvmStatic
13 | fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
14 | getMessage(key, *params)
15 |
16 | @Suppress("unused")
17 | @JvmStatic
18 | fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
19 | getLazyMessage(key, *params)
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/review/domain/entity/ReviewSettings.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.review.domain.entity
2 |
3 | data class ReviewSettings(
4 | /**
5 | * so we can ensure to ask only once a week or something like that
6 | */
7 | val lastReviewRequestTimestamp: Long?,
8 | /**
9 | * how many times the user
10 | */
11 | val timesReviewRequestSkipped: Long,
12 | /**
13 | * if the user has not yet answered on this one
14 | */
15 | val shouldAskLater: Boolean?,
16 | /**
17 | * if the user has already reviewed, or does not wish to review
18 | */
19 | val reviewed: Boolean,
20 | )
21 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/parser/GPTARBResponseParser.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.parser
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.dto.GPTArbTranslationResponse
5 |
6 | class GPTARBResponseParser(private val jacksonMapper: ObjectMapper) {
7 |
8 | fun parseResponse(response: String): GPTArbTranslationResponse {
9 | val readValue = jacksonMapper.readValue(response, Map::class.java) as Map
10 | return GPTArbTranslationResponse(content = readValue)
11 | }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/flutter_intl/domain/repository/FlutterIntlSettingsRepository.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.flutter_intl.domain.repository
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.flutter_intl.domain.entity.FlutterIntlSettings
4 | import java.nio.file.Path
5 |
6 | /**
7 | * provides flutter intl settings, if there are any
8 | * caution, the user might have settings, which he uses in the console, therefore this might not be the ground truth
9 | */
10 | interface FlutterIntlSettingsRepository {
11 | fun getFlutterIntlSettings(): FlutterIntlSettings
12 | fun loadFlutterIntlSettingsByPath(path: Path): FlutterIntlSettings
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/service/ARBTemplateService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.service
2 |
3 | class ARBTemplateService {
4 | fun fillTemplate(key: String, value: String, description: String): String {
5 | return template.replace("", key)
6 | .replace("", value)
7 | .replace("", description)
8 | }
9 |
10 | private val template = """
11 | {
12 | "": "",
13 | "@": {
14 | "description": ""
15 | }
16 | }
17 | """.trimIndent()
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/CurrentFileModificationService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Translation
4 |
5 | /**
6 | * differs from [ArbFileModificationService] because this should modify the current file, e.g. often you need to add e.g. an import, change some variable names... whatever
7 | */
8 | fun interface CurrentFileModificationService {
9 | /**
10 | * this is something, which should be executed immediately, e.g. when the user presses a button
11 | */
12 | fun modifyCurrentFile(translation: Translation)
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/service/TranslationProgressChangeNotifier.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.service
2 |
3 | import com.intellij.util.messages.Topic
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.TranslationProgress
5 |
6 |
7 | interface TranslationProgressChangeNotifier {
8 | fun afterAction(translationProgress: TranslationProgress)
9 |
10 | companion object {
11 | val CHANGE_ACTION_TOPIC = Topic.create(
12 | "web browser",
13 | TranslationProgressChangeNotifier::class.java, Topic.BroadcastDirection.TO_PARENT
14 | )
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/resources/intentionDescriptions/GenerateArbIntentionAction/description.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | translate this string and put it into the ARB files
4 |
5 | 1. Will replace the string with the accessor to the translations (currently S, can be configured)
6 | 2. Will add imports, if necessary
7 | 3. Will put a dummy translation first, so that the UI is not blocked
8 | 4. When the translation, in the background, finished, it will replace the dummy translation with the real one
9 | 5. Will call flutter gen-l10n when the dummy has been put into place
10 |
11 |
12 |
There is no more information. Hello world, this is my first real plugin. Sorry for that.
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/TranslationFileNotFound.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
5 | import java.nio.file.Path
6 |
7 | class TranslationFileNotFound(message: String, private var language: Language, private var targetPath: Path) : GPTHelperBaseException(message) {
8 |
9 | override val message: String = ""
10 | get() = "Target file not found for language '${language.toISOLangString()}'. File path searched: '$targetPath' + $field"
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/missingtranslations/domain/service/MissingTranslationCollectionService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.entity.MissingTranslationContext
4 |
5 | interface MissingTranslationCollectionService {
6 |
7 | /**
8 | * Search for missing translations based on the given context and their reference.
9 | * In intelliJ the reference is a reference to the File, but e.g. in visual studio code it would be something else
10 | */
11 | fun collectMissingTranslations(missingTranslationContext: MissingTranslationContext): MissingTranslationContext
12 | }
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/infrastructure/service/OpenAIMultiKeyTranslationTaskSizeEstimator.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.infrastructure.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity.MultiKeyTranslationContext
4 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.service.MultiKeyTranslationTaskSizeEstimator
5 |
6 | class OpenAIMultiKeyTranslationTaskSizeEstimator : MultiKeyTranslationTaskSizeEstimator {
7 | override fun estimateTaskSize(multiKeyTranslationContext: MultiKeyTranslationContext): Int {
8 | return multiKeyTranslationContext.translationEntries.size * multiKeyTranslationContext.targetLanguages.size
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/client/PartialTranslationResponse.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.client
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Translation
5 |
6 | /**
7 | * represents all translations for all files, because the original translation might be modified because
8 | * of wording etc.
9 | */
10 | class PartialTranslationResponse(var translation: Translation) {
11 |
12 | fun getTranslationKey(): String {
13 | return translation.entry.desiredKey
14 | }
15 |
16 | fun getTargetLanguage(): Language {
17 | return translation.lang
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/filetranslation/domain/entity/TranslateFileContext.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.filetranslation.domain.entity
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
4 | import java.nio.file.Path
5 |
6 | /**
7 | * contains information about the current request to translate a key,
8 | * though from the perspective of us, asking the user for information
9 | *
10 | */
11 | data class TranslateFileContext(
12 | /**
13 | * the current statement to be translated
14 | * most of the time a StringLiteral, but might be something different in the future
15 | */
16 | val baseLanguage: Language,
17 | val targetLanguage: Language,
18 | val absolutePath: Path,
19 | ) {
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/Language.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | //en_US or en
4 | data class Language(val lang: String, val country: String?) {
5 | companion object {
6 | fun fromISOLangString(isoLang: String): Language {
7 | val split = isoLang.split("_")
8 | return if (split.size == 2) {
9 | Language(split[0], split[1])
10 | } else {
11 | Language(split[0], null)
12 | }
13 | }
14 | }
15 |
16 |
17 | fun toISOLangString(): String {
18 | return if (country != null) {
19 | "${lang}_${country}"
20 | } else {
21 | lang
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/client/SingleTranslationRequestClient.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.client
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.dto.GPTArbTranslationResponse
5 |
6 | interface SingleTranslationRequestClient {
7 | suspend fun requestTranslation(key: String, value: String, description: String, targetLanguage: String): GPTArbTranslationResponse
8 | suspend fun requestTranslation(content: String, targetLanguage: String): GPTArbTranslationResponse
9 | suspend fun requestTranslation(content: String, baseLanguage: Language, targetLanguage: Language): GPTArbTranslationResponse
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/service/GatherBestGuessContext.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.service
2 |
3 | import com.intellij.psi.PsiElement
4 | import com.intellij.psi.PsiFile
5 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity.FileBestGuessContext
6 | import java.util.*
7 |
8 | interface GatherBestGuessContext {
9 | /**
10 | * Gathers the context from multiple files, usually without user interaction for string selection.
11 | * @return null, if no relevant literals are found.
12 | */
13 | fun fromMultipleFiles(processUUID: UUID, files: List): FileBestGuessContext?
14 |
15 | fun fromPsiElements(processUUID: UUID, elements: List): FileBestGuessContext?
16 | }
17 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | # libraries
3 | junit = "4.13.2"
4 | opentest4j = "1.3.0"
5 |
6 | # plugins
7 | changelog = "2.4.0"
8 | intelliJPlatform = "2.7.1"
9 | kotlin = "2.2.0"
10 | kover = "0.9.1"
11 | qodana = "2025.1.1"
12 |
13 | [libraries]
14 | junit = { group = "junit", name = "junit", version.ref = "junit" }
15 | opentest4j = { group = "org.opentest4j", name = "opentest4j", version.ref = "opentest4j" }
16 |
17 | [plugins]
18 | changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
19 | intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" }
20 | kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
21 | kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
22 | qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
23 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/exceptions/TranslationFileModificationException.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.exceptions
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.shared.domain.exception.GPTHelperBaseException
4 |
5 | open class TranslationFileModificationException : GPTHelperBaseException {
6 | constructor(message: String?, cause: Throwable?) : super(message, cause)
7 | constructor(message: String?) : super(message)
8 | constructor(cause: Throwable?) : super(cause)
9 | constructor() : super()
10 | constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super(
11 | message,
12 | cause,
13 | enableSuppression,
14 | writableStackTrace
15 | )
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/UserTranslationInput.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | /**
4 | * contains information about the translation
5 | */
6 | data class UserTranslationInput(
7 | /**
8 | * the desired key of the translation
9 | */
10 | val desiredKey: String,
11 | /**
12 | * the desired value of the translation
13 | */
14 | val desiredValue: String,
15 | /**
16 | * the desired description
17 | */
18 | val desiredDescription: String,
19 | /**
20 | * normally, the user wants to translate all languages
21 | */
22 | val languagesToTranslate: Map,
23 | /**
24 | * Checkbox value for 'Translate Now'
25 | */
26 | val translateNow: Boolean
27 | ) {
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/GatherUserInputService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.TranslateKeyContext
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.UserTranslationInput
5 |
6 | /**
7 | * get information from the user, like the desired key, description, ...
8 | */
9 | fun interface GatherUserInputService {
10 | /**
11 | * e.g. get the data from the user, or calculate it based on the class, whatever
12 | * @param translateKeyContext is information, which helps the process of getting the information from the user
13 | */
14 | fun requestInformationFromUser(translateKeyContext: TranslateKeyContext): UserTranslationInput?
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/repository/TranslationFileRepository.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.repository
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.FileToTranslate
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
5 | import java.nio.file.Path
6 |
7 | /**
8 | * this repository is for the domain representation of a translation file.
9 | */
10 | interface TranslationFileRepository {
11 | fun getTranslationFileByLanguage(language: Language): FileToTranslate
12 | fun createOrGetTranslationFileByLanguage(language: Language): FileToTranslate
13 | fun saveTranslationFile(fileToTranslate: FileToTranslate)
14 | fun getPathsToTranslationFiles(): List
15 | fun getPathToFile(language: Language): Path
16 | }
17 |
--------------------------------------------------------------------------------
/src/test/kotlin/features/translations/domain/mapper/ArbFilenameParserTest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.mapper
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.parser.ArbFilenameParser
4 | import org.junit.Test
5 | import org.junit.jupiter.api.Assertions.*
6 |
7 | class ArbFilenameParserTest {
8 | private val sut = ArbFilenameParser()
9 |
10 | @Test
11 | fun `getArbFilePrefix returns correct prefix`() {
12 | assertEquals("ABC", sut.getArbFilePrefix("ABCen_US.arb"))
13 | assertEquals("AB_", sut.getArbFilePrefix("AB_en.arb"))
14 | assertEquals("qw_", sut.getArbFilePrefix("qw_de.arb"))
15 | assertEquals("q123_", sut.getArbFilePrefix("q123_de_DE.arb"))
16 | assertEquals("", sut.getArbFilePrefix("test"))
17 | assertEquals("", sut.getArbFilePrefix(""))
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/service/PreFilterRequestBuilder.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.service
2 |
3 | import com.intellij.psi.PsiElement
4 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity.PreFilterRequest
5 | import de.keeyzar.gpthelper.gpthelper.features.psiutils.SmartPsiElementWrapper
6 |
7 | /**
8 | * Service to prepare pre-filter requests from PSI elements
9 | */
10 | interface PreFilterRequestBuilder {
11 | /**
12 | * Builds a pre-filter request from a map of PSI elements wrapped in SmartPointers
13 | * @param elements Map of SmartPsiElementWrapper to their pre-selection state
14 | * @return PreFilterRequest ready to be sent to the AI
15 | */
16 | fun buildRequest(elements: Map, Boolean>): PreFilterRequest
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/shared/presentation/actions/ProjectAwareAction.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.shared.presentation.actions
2 |
3 | import com.intellij.openapi.actionSystem.AnActionEvent
4 | import com.intellij.openapi.project.DumbAwareAction
5 | import com.intellij.openapi.project.Project
6 | import de.keeyzar.gpthelper.gpthelper.features.translations.presentation.dependencyinjection.FlutterArbTranslationInitializer
7 |
8 | abstract class ProjectAwareAction : DumbAwareAction() {
9 | override fun actionPerformed(e: AnActionEvent) {
10 | val project = e.project ?: return
11 | val initializer = FlutterArbTranslationInitializer.create(project)
12 | actionPerformed(e, project, initializer)
13 | }
14 |
15 | abstract fun actionPerformed(e: AnActionEvent, project: Project, initializer: FlutterArbTranslationInitializer)
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/review/infrastructure/model/ReviewSettingsModel.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.review.infrastructure.model
2 |
3 | class ReviewSettingsModel(
4 | /**
5 | * so we can ensure to ask only once a week or something like that
6 | */
7 | val lastReviewRequestTimestamp: Long?,
8 | /**
9 | * how many times the user
10 | */
11 | val timesReviewRequestSkipped: Long,
12 | /**
13 | * if the user has not yet answered on this one
14 | */
15 | val shouldAskLater: Boolean?,
16 | val reviewed: Boolean,
17 | ) {
18 | companion object {
19 | val DEFAULT: ReviewSettingsModel = ReviewSettingsModel(
20 | lastReviewRequestTimestamp = null,
21 | timesReviewRequestSkipped = 0,
22 | shouldAskLater = null,
23 | reviewed = false,
24 | )
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/review/domain/config/ReviewConfig.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.review.domain.config
2 |
3 | import java.net.URI
4 |
5 | data class ReviewConfig(
6 | val timeBetweenReviewRequestsInSeconds: Int = TIME_BETWEEN_REVIEW_REQUESTS_IN_SECONDS,
7 | val minimumTranslationsBeforeWeAskForReview: Int = MINIMUM_TRANSLATIONS_BEFORE_WE_ASK_FOR_REVIEW,
8 | val uriFromPlugin: URI = URI_FROM_PLUGIN,
9 | ) {
10 | companion object {
11 | //is there any cool utilities function for this?
12 | private const val TWO_DAYS_IN_SECONDS = 2 * 24 * 60 * 60
13 | private const val TIME_BETWEEN_REVIEW_REQUESTS_IN_SECONDS = TWO_DAYS_IN_SECONDS
14 | private const val MINIMUM_TRANSLATIONS_BEFORE_WE_ASK_FOR_REVIEW = 10
15 | private val URI_FROM_PLUGIN = URI("https://plugins.jetbrains.com/plugin/21732-gpt-flutter-intl/reviews")
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/mapper/TranslationRequestMapper.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.mapper
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.client.ClientTranslationRequest
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.UserTranslationRequest
5 | import org.mapstruct.Mapper
6 | import org.mapstruct.Mapping
7 |
8 | /**
9 | * map from UserTranslationRequest to ClientTranslationRequest
10 | */
11 | @Mapper
12 | interface TranslationRequestMapper {
13 | @Mapping(source = "baseTranslation", target = "translation")
14 | fun toClientRequest(userTranslationRequest: UserTranslationRequest): ClientTranslationRequest
15 | @Mapping(source = "translation", target = "baseTranslation")
16 | fun toUserRequest(clientTranslationRequest: ClientTranslationRequest): UserTranslationRequest
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/presentation/service/ArbFormatTranslationFileContentService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.presentation.service
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.FileToTranslate
5 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.service.FormatTranslationFileContentService
6 |
7 | class ArbFormatTranslationFileContentService(
8 | private val objectMapper: ObjectMapper
9 | ) : FormatTranslationFileContentService {
10 | override fun formatTranslationFileContent(fileToTranslate: FileToTranslate): FileToTranslate {
11 | val newContent = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(objectMapper.readTree(fileToTranslate.content))
12 | return fileToTranslate.copy(content = newContent)
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/shared/presentation/dto/UserSettingsDTO.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.shared.presentation.dto
2 |
3 | data class UserSettingsDTO(
4 | /**
5 | * where is the directory containing the arb files
6 | */
7 | var arbDir: String = "",
8 | /**
9 | * how is the key names (e.g. S, AppLocalizations)
10 | */
11 | var outputClass: String = "",
12 | /**
13 | * whether we're working with a nullable getter
14 | */
15 | var nullableGetter: Boolean = true,
16 | /**
17 | * base file for the translations, i.e. here you can find the prefix
18 | */
19 | var templateArbFile: String = "",
20 | var intlConfigFile: String = "",
21 | var watchIntlConfigFile: Boolean = true,
22 | /**
23 | * here you can find the file, where the outputClass is located in
24 | */
25 | var outputLocalizationFile: String = ""
26 | )
27 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/client/GptModelProviderImpl.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.client
2 |
3 | import com.google.genai.types.ListModelsConfig
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.client.GPTModelProvider
5 | import de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.configuration.LLMConfigProvider
6 | import kotlinx.coroutines.runBlocking
7 |
8 | class GptModelProviderImpl (
9 | private val LLMConfigProvider: LLMConfigProvider,
10 | ) : GPTModelProvider() {
11 | override fun getAllModels(): List {
12 | return runBlocking {
13 | LLMConfigProvider.getInstanceGemini().models.list(ListModelsConfig.builder().pageSize(20).build()).page()
14 | .map { e -> e.name().orElse("no name") }
15 | .toList();
16 | }
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/presentation/actions/AutoLocalizeDirectory.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.presentation.actions
2 |
3 | import com.intellij.openapi.actionSystem.AnActionEvent
4 | import com.intellij.openapi.actionSystem.CommonDataKeys
5 | import com.intellij.openapi.project.Project
6 | import de.keeyzar.gpthelper.gpthelper.features.shared.presentation.actions.ProjectAwareAction
7 | import de.keeyzar.gpthelper.gpthelper.features.translations.presentation.dependencyinjection.FlutterArbTranslationInitializer
8 |
9 | class AutoLocalizeDirectory : ProjectAwareAction() {
10 | override fun actionPerformed(e: AnActionEvent, project: Project, initializer: FlutterArbTranslationInitializer) {
11 | val directory = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return
12 | initializer.orchestrator.orchestrate(project, directory, "Auto Localizing Directory")
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/configuration/LLMConfigProvider.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.configuration
2 |
3 | import com.google.genai.Client
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.repository.TranslationCredentialsServiceRepository
5 |
6 | class LLMConfigProvider(private val credentialsServiceRepository: TranslationCredentialsServiceRepository) {
7 |
8 | fun getInstanceGemini(): Client {
9 | return credentialsServiceRepository.getKey()?.let {
10 | withKeyGemini(it)
11 | } ?: withoutGeminiKey()
12 | }
13 |
14 | private fun withoutGeminiKey(): Client {
15 | return Client.builder()
16 | .build()
17 | }
18 |
19 | fun withKeyGemini(key: String): Client {
20 | return Client.builder()
21 | .apiKey(key)
22 | .build()
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/infrastructure/search/ArbFileContentProvider.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.infrastructure.search
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.flutter_intl.infrastructure.service.ArbFilesService
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
5 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.repository.TranslationFileRepository
6 |
7 | class ArbFileContentProvider(
8 | private val arbFilesService: ArbFilesService,
9 | private val translationFileRepository: TranslationFileRepository,
10 | ) {
11 | fun getBaseLangContent(): String {
12 | val lang = com.intellij.openapi.application.ReadAction.compute {
13 | arbFilesService.getBaseLanguage(null)
14 | }
15 | return translationFileRepository.getTranslationFileByLanguage(lang).content
16 | }
17 | }
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/service/GuessAdaptionService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.client.BestGuessResponse
4 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity.MultiKeyTranslationContext
5 | import java.util.*
6 |
7 | /**
8 | * we have a lot of guesses now, that must be checked and modified (by the user most definitely)
9 | */
10 | fun interface GuessAdaptionService {
11 | /**
12 | * the user now has a lot of possible translation entries, we need to allow him to modify them
13 | * afterward we take all these l10n translation requests and exchange them in the file
14 | *
15 | * @return null, when the user has interrupted the process
16 | */
17 | fun adaptBestGuess(processUUID: UUID, bestGuessResponse: BestGuessResponse): MultiKeyTranslationContext?
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/service/ImmediateTranslationService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.dto.GPTArbTranslationResponse
4 | import de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.parser.GPTARBResponseParser
5 |
6 |
7 | /**
8 | * will immediately provide a translation
9 | */
10 | class ImmediateTranslationService(
11 | private val templateService: ARBTemplateService,
12 | private val responseParser: GPTARBResponseParser,
13 | ) {
14 | /**
15 | * gpt skips the own translation, therefore we provide multiple "responses"
16 | */
17 | fun requestTranslation(key: String, value: String, description: String): GPTArbTranslationResponse {
18 | return responseParser.parseResponse(templateService.fillTemplate(key, value, description));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/presentation/actions/DartStringRequiredPattern.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.presentation.actions
2 |
3 | import com.intellij.patterns.PatternCondition
4 | import com.intellij.psi.PsiElement
5 | import com.intellij.psi.util.PsiTreeUtil
6 | import com.intellij.psi.util.elementType
7 | import com.intellij.util.ProcessingContext
8 | import com.jetbrains.lang.dart.DartTokenTypes
9 |
10 |
11 | class DartStringRequiredPattern : PatternCondition("DartStringRequiredPattern") {
12 | override fun accepts(
13 | t: PsiElement,
14 | context: ProcessingContext?
15 | ): Boolean {
16 | val types = listOf(
17 | DartTokenTypes.ARGUMENT_LIST,
18 | DartTokenTypes.VAR_DECLARATION_LIST
19 | )
20 |
21 | return PsiTreeUtil.findFirstParent(t) {
22 | types.contains(it.elementType)
23 | } != null
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/entity/TranslateKeyContext.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity
2 |
3 | /**
4 | * contains information about the current request to translate a key,
5 | * though from the perspective of us, asking the user for information
6 | *
7 | */
8 | data class TranslateKeyContext(
9 | /**
10 | * the current statement to be translated
11 | * most of the time a StringLiteral, but might be something different in the future
12 | */
13 | val statement: String,
14 | /**
15 | * which is the language this translation stems from?
16 | */
17 | val baseLanguage: Language,
18 | /**
19 | * we might want to show user information based on the last input
20 | */
21 | val lastUserInput: List?,
22 | val availableLanguages: List,
23 | var changeTranslationContext: ChangeTranslationContext? = null
24 | ) {
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/flutter_intl/domain/entity/FlutterIntlSettings.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.flutter_intl.domain.entity
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties
4 | import com.fasterxml.jackson.annotation.JsonProperty
5 |
6 | @JsonIgnoreProperties(ignoreUnknown = true)
7 | data class FlutterIntlSettings(
8 | @JsonProperty("arb-dir")
9 | var arbDir: String = "lib/l10n",
10 | @JsonProperty("template-arb-file")
11 | var templateArbFile: String = "app_en.arb",
12 | @JsonProperty("output-localization-file")
13 | var outputLocalizationFile: String = "lib/l10n/app_localizations.dart",
14 | @JsonProperty("output-class")
15 | var outputClass: String = "AppLocalizations",
16 | @JsonProperty("nullable-getter")
17 | var nullableGetter: Boolean = true,
18 | @JsonProperty("untranslated-messages-file")
19 | var untranslatedMessagesFile: String = "untranslated_messages.txt",
20 | )
21 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/missingtranslations/domain/entity/MissingTranslationFilteredTargetTranslation.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.missingtranslations.domain.entity
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Language
4 |
5 | /**
6 | * the missing translation e.g. "greeting" for de and pl - the user said he wants to translate it to de only
7 | */
8 | data class MissingTranslationFilteredTargetTranslation(
9 | val missingTranslationAndExistingTranslation: MissingTranslationAndExistingTranslation,
10 | val languagesToTranslateTo: List,
11 | val uuid: String,
12 | ) {
13 | override fun equals(other: Any?): Boolean {
14 | if (this === other) return true
15 | if (other !is MissingTranslationFilteredTargetTranslation) return false
16 | return uuid == other.uuid
17 | }
18 |
19 | override fun hashCode(): Int {
20 | return uuid.hashCode()
21 | }
22 | }
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/autofilefixer/domain/client/PreFilterClient.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.client
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity.PreFilterRequest
4 | import de.keeyzar.gpthelper.gpthelper.features.autofilefixer.domain.entity.PreFilterResponse
5 |
6 | /**
7 | * Client for AI-based pre-filtering of string literals to determine which should be translated
8 | */
9 | interface PreFilterClient {
10 | /**
11 | * Analyzes string literals and determines which ones should be translated
12 | * @param request The pre-filter request containing literals with context
13 | * @param progressCallback Optional callback invoked after each batch is processed
14 | * @return Response indicating which literals should be translated
15 | */
16 | suspend fun preFilter(request: PreFilterRequest, progressCallback: ((Int, Int) -> Unit)? = null): PreFilterResponse
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/TranslationTriggeredHooks.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.Translation
4 |
5 | /**
6 | * different kind of translation process hooks
7 | */
8 | interface TranslationTriggeredHooks {
9 | /**
10 | * when you have a single key translation and want it to be triggered
11 | * combines [translationTriggeredInit] + [translationTriggeredPartial]
12 | */
13 | fun translationTriggered(translation: Translation)
14 |
15 | /**
16 | * when you have multiple keys, which must be replaced
17 | */
18 | fun translationTriggeredPartial(translation: Translation)
19 |
20 | /**
21 | * If there is some kind of initial task to be done once, which is kinda expensive
22 | */
23 | fun translationTriggeredInit()
24 | fun translationTriggeredPostTranslation()
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/kotlin/features/psiutils/filter/ImportStatementFilterDartStringTest.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.psiutils.filter
2 |
3 | import com.intellij.psi.util.descendantsOfType
4 | import com.intellij.testFramework.fixtures.BasePlatformTestCase
5 | import com.jetbrains.lang.dart.psi.DartStringLiteralExpression
6 |
7 | class ImportStatementFilterDartStringTest : BasePlatformTestCase() {
8 |
9 | private lateinit var sut: ImportStatementFilterDartString
10 |
11 | override fun setUp() {
12 | super.setUp()
13 | sut = ImportStatementFilterDartString()
14 | myFixture.testDataPath = "src/test/resources/psiutils/dart/filter"
15 | }
16 |
17 | fun testShouldFilterImportStatements() {
18 | val psiFile = myFixture.configureByFile("import_string_literal.dart")
19 | val stringLiteral = psiFile.descendantsOfType().first()
20 |
21 | val filter = sut.filter(stringLiteral)
22 |
23 | assertFalse(filter)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/KoinInstances.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper
2 |
3 | import com.intellij.openapi.project.Project
4 | import org.koin.core.Koin
5 | import org.koin.core.KoinApplication
6 | import org.koin.core.module.Module
7 | import org.koin.dsl.koinApplication
8 |
9 | object KoinInstances {
10 | private val projectKoinApps = mutableMapOf()
11 |
12 | fun start(project: Project, modules: List) {
13 | println("Starting Koin for project ${project.name}")
14 | val koinApp = koinApplication {
15 | modules(modules)
16 | }
17 | projectKoinApps[project] = koinApp
18 | }
19 |
20 | fun get(project: Project): Koin {
21 | return projectKoinApps[project]?.koin ?: error("Koin not started for project ${project.name}")
22 | }
23 |
24 | fun close(project: Project) {
25 | projectKoinApps.remove(project)?.close()
26 | println("Closed Koin for project ${project.name}")
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/domain/service/IdeaTranslationErrorProcessHandlerImpl.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.domain.service
2 |
3 | import com.intellij.openapi.application.ApplicationManager
4 | import com.intellij.openapi.ui.DialogBuilder
5 | import com.intellij.ui.dsl.builder.panel
6 |
7 | class IdeaTranslationErrorProcessHandlerImpl : TranslationErrorProcessHandler {
8 | override fun displayErrorToUser(e: Throwable) {
9 | e.printStackTrace()
10 | ApplicationManager.getApplication().invokeAndWait {
11 | DialogBuilder().apply {
12 | setTitle("Error")
13 | setCenterPanel(
14 | panel {
15 | row {
16 | label(e.message ?: "Unknown Error, please check logs")
17 | }
18 | }
19 | )
20 | addOkAction()
21 | }.showAndGet()
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/features/translations/infrastructure/service/IdeaTranslationProgressBus.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.translations.infrastructure.service
2 |
3 | import com.intellij.openapi.project.Project
4 | import com.intellij.util.messages.MessageBus
5 | import com.intellij.util.messages.MessageBusConnection
6 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.entity.TranslationProgress
7 | import de.keeyzar.gpthelper.gpthelper.features.translations.domain.service.TranslationProgressBus
8 |
9 | class IdeaTranslationProgressBus(
10 | val project: Project
11 | ) : TranslationProgressBus {
12 |
13 | override fun pushPercentage(translationProgress: TranslationProgress) {
14 | val messageBus: MessageBus = project.messageBus
15 | val connection: MessageBusConnection = messageBus.connect()
16 | messageBus.syncPublisher(TranslationProgressChangeNotifier.CHANGE_ACTION_TOPIC)
17 | .afterAction(translationProgress)
18 | connection.disconnect()
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/kotlin/de/keeyzar/gpthelper/gpthelper/project/ProjectKoinService.kt:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.project
2 |
3 | import com.intellij.openapi.Disposable
4 | import com.intellij.openapi.project.Project
5 | import de.keeyzar.gpthelper.gpthelper.KoinInstances
6 | import de.keeyzar.gpthelper.gpthelper.createAppModule
7 | import org.koin.core.Koin
8 |
9 | class ProjectKoinService(private val project: Project) : Disposable {
10 |
11 | fun start() {
12 | //Each project will have its own Koin context, isolated from others.
13 | KoinInstances.start(project, listOf(createAppModule(project)))
14 | }
15 |
16 | fun getKoin(): Koin {
17 | return KoinInstances.get(project)
18 | }
19 |
20 | override fun dispose() {
21 | // We must stop Koin to prevent memory leaks when the project is closed.
22 | KoinInstances.close(project)
23 | }
24 |
25 | companion object {
26 | fun getInstance(project: Project): ProjectKoinService {
27 | return project.getService(ProjectKoinService::class.java)
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/de/keeyzar/gpthelper/gpthelper/features/flutterarb/presentation/handler/ArbFileType.java:
--------------------------------------------------------------------------------
1 | package de.keeyzar.gpthelper.gpthelper.features.flutterarb.presentation.handler;
2 |
3 | import com.intellij.icons.AllIcons;
4 | import com.intellij.json.JsonLanguage;
5 | import com.intellij.openapi.fileTypes.LanguageFileType;
6 | import org.jetbrains.annotations.NotNull;
7 |
8 | import javax.swing.*;
9 |
10 | public class ArbFileType extends LanguageFileType {
11 | public static final ArbFileType INSTANCE = new ArbFileType();
12 |
13 | private ArbFileType() {
14 | super(JsonLanguage.INSTANCE);
15 | }
16 |
17 | @NotNull
18 | @Override
19 | public String getName() {
20 | return "ARB File";
21 | }
22 |
23 | @NotNull
24 | @Override
25 | public String getDescription() {
26 | return "Application resource bundle (.arb) file";
27 | }
28 |
29 | @NotNull
30 | @Override
31 | public String getDefaultExtension() {
32 | return "arb";
33 | }
34 |
35 | @Override
36 | public Icon getIcon() {
37 | return AllIcons.FileTypes.Json;
38 | }
39 | }
--------------------------------------------------------------------------------
/.run/Run Tests.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |