kvision icon indicating copy to clipboard operation
kvision copied to clipboard

trying to generate .pot files

Open CodeServant opened this issue 1 year ago • 11 comments

I am trying to generate pot file via ./gradlew :subproject:generatePotFile Everything I did as in here, but it does not seem to work becouse files not appear. gradlew command result is below

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 up-to-date
  • dependency set up
  • example tr and gettext usage in code
  • set the code below at start
I18n.manager = DefaultI18nManager(
            mapOf(
                "en" to require("i18n/messages-en.json"),
                "pl" to require("i18n/messages-pl.json"),
            )
        )
  • even
if (!(I18n.language in listOf("en", "pl"))) {
            I18n.language = "en"
        }

from the showcase example

The showcase is working normally. Added .getttext.json but not working either. I have no idea what is wrong, please help.

kvision 7.3.1 windows 10 kotlin 1.9.22 gradle 8.5

CodeServant avatar Jan 16 '24 21:01 CodeServant

There are paths in .gettext.json file (pattern, output). You are building a subproject. Have you adjusted those paths to match your subproject?

rjaros avatar Jan 16 '24 22:01 rjaros

"output": "src/jsMain/resources/i18n/messages.pot" the file is in my subproject downgraded kotlin to 1.9.20 and works fine but for a while done clean generatePotFile and no file still with kotlin 1.9.20

CodeServant avatar Jan 16 '24 22:01 CodeServant

Ok that seems i can generate this .pot file only after i run command gradle subproject:run -t which generate error at first run. Works with kotlin 1.9.22.

CodeServant avatar Jan 16 '24 22:01 CodeServant

Can you share your project?

rjaros avatar Jan 17 '24 17:01 rjaros

No sorry. I am planning to do it, but i should consult with receipant and my university. Hope to pass the engineer exam with this. But as i told earlier. First had to run and then generate pot file.

Running .\gradlew.bat clean generatePotFile gives me

Starting a Gradle Daemon, 2 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :webCli:generatePotFile FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':webCli:generatePotFile' (type 'KVGeneratePotTask').
  - In plugin 'io.kvision.gradle.KVisionPlugin$Inject' type 'io.kvision.gradle.tasks.KVGeneratePotTask' property 'getTextExtractBin' specifies file 'C:\Users\macie\IdeaProj
ects\printing-house\build\js\node_modules\gettext-extract\bin\gettext-extract' which doesn't exist.

    Reason: An input file was expected to be present but it doesn't exist.

    Possible solutions:
      1. Make sure the file exists before the task is called.
      2. Make sure that the task which produces the file is declared as an input.

    For more information, please refer to https://docs.gradle.org/8.5/userguide/validation_problems.html#input_file_does_not_exist in the Gradle documentation.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 32s
10 actionable tasks: 7 executed, 3 up-to-date

But when I do .\gradlew.bat generatePotFile after ./gradlew :subproject:run -t works fine.

CodeServant avatar Jan 17 '24 18:01 CodeServant

I would assume something like this is happening. The generatePotFile task depends on some NPM tools to be installed in the project. These tools are installed by the kotlinNpmInstall gradle task, so it isconfigured as a dependency for generatePotFile. It works with standard, simple project layout - you run generatePotFile, gradle calls kotlinNpmInstall first, the tools get installed and pot generation can do its job. But I see you have kvision project in a subproject. When generatePotFile taks is called, it executes kotlinNpmInstall from the root project. But in the root project you have no kvision dependencies, so the tools are not installed and pot generation fails. To fix the issue you probably should call .\gradlew.bat :subproject:generatePotFile or add task dependencies manually.

rjaros avatar Jan 18 '24 06:01 rjaros

After a while of debugging I have concluded that the KVisionPlugin.apply() function is never run when you conf KVision as a subproject and hence configureNodeEcosystem never gets executed. Anyone know why this is?

edit: And ofc configureProject wont be ran, either!

a-cosmic-jaw avatar Feb 15 '24 21:02 a-cosmic-jaw

Can you share your project?

rjaros avatar Feb 15 '24 22:02 rjaros

Sure can!

I also find the paths of ./css/kvapp.css, ./i18n/messages-en.json, ./i18n/messages-pl.json in App.kt and ./webpack/bin/webpack.js on line 453 in KVisionPlugin.kt (tag:7.3.1) need the ./ before the paths.

a-cosmic-jaw avatar Feb 15 '24 22:02 a-cosmic-jaw

The problem with KVision subproject is caused by the strange behaviour of Kotlin/JS gradle plugin. Despite this plugin being applied in a subproject, it creates some tasks (e.g. kotlinNpmInstall) in the root project. This breaks KVision tasks dependencies. I've fixed this and it should work correctly in the next release.

The problem with paths to resources is different. We can use paths without ./, because all KVision apps define this line in the webpack.config.d/webpack.js:

config.resolve.modules.push("../../processedResources/js/main");

Unfortunately this is a relative path resolved from the root project. You need to change this line to this:

config.resolve.modules.push("../../../addressbook-fullstack-micronaut/build/processedResources/js/main");

and paths without ./ wil work fine.

rjaros avatar Feb 16 '24 10:02 rjaros

Thanks for the feedback! Looking forward to the next release!

a-cosmic-jaw avatar Feb 16 '24 16:02 a-cosmic-jaw

Fixed in 7.4.1

rjaros avatar Feb 25 '24 08:02 rjaros