Bug 444795 - Using KDE_L10N_SYNC_TRANSLATIONS option does not lead to compiling translations
Summary: Using KDE_L10N_SYNC_TRANSLATIONS option does not lead to compiling translations
Status: RESOLVED FIXED
Alias: None
Product: extra-cmake-modules
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.87.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: ecm-bugs-null@kde.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-01 23:05 UTC by Andrew Shark
Modified: 2022-11-28 00:10 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Shark 2021-11-01 23:05:46 UTC
When user uses cmake option KDE_L10N_SYNC_TRANSLATIONS, he expect that the translations will be downloaded and built. However, it does not happen. I tried to understand how things work.

The l10n.rb defines get method with the parameter edit_cmake which defaults to true:
https://invent.kde.org/sdk/releaseme/-/blob/b830efbdd392150b0b56e944bb34c07606492d4b/lib/releaseme/l10n.rb#L29-30
That edit_cmake means the following lines will be added to cmakelists.txt (as needed):
```
find_package(KF5I18n CONFIG REQUIRED)
ki18n_install(po)
```

The tarme.rb calls that method without specifying edit_cmake parameter:
https://invent.kde.org/sdk/releaseme/-/blob/b830efbdd392150b0b56e944bb34c07606492d4b/tarme.rb#L81
and it becomes true (because of default in l10n.rb) and prepared tar will have edited cmakelists.txt.

The fetchpo.rb when running invoking get method specify the edit_cmake to false:
https://invent.kde.org/sdk/releaseme/-/blob/b830efbdd392150b0b56e944bb34c07606492d4b/fetchpo.rb#L60-61
so running it will not trigger editing cmakelists.txt

But that fetchpo.rb is invoked by cmake module KDECMakeSettings.cmake:
https://invent.kde.org/frameworks/extra-cmake-modules/-/blob/8f7831c83f11f38c060fd0717b925b1fa28cd3d8/kde-modules/KDECMakeSettings.cmake#L356-361
The result is that the translations are not compiled to the package.

STEPS TO REPRODUCE
1. git clone https://invent.kde.org/pim/zanshin.git
2. mkdir build
3. cd build
4. cmake -B . -S ../zanshin -DBUILD_TESTING=OFF -DKDE_L10N_SYNC_TRANSLATIONS=ON
6. cmake --build .
7. DESTDIR="$pkgdir" cmake --install build # from package() function in PKGBUILD

OBSERVED RESULT
The translations were downloaded, but not compiled. The built package does not contain translations.

EXPECTED RESULT
The translations are downloaded and compiled.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.2
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
The solution could be to make fetchpo.rb to be able to accept parameter --edit-cmake, and pass it to the get method. And then two variants to do:
Variant 1:
Then add "--edit-cmake TRUE" to fetch_commands in the KDECMakeSettings.cmake.
Variant 2:
Make --edit-cmake parameter default to true in fetchpo.rb. Then editing KDECMakeSettings.cmake will not be necessary.
Comment 1 Andrew Shark 2021-11-05 12:32:50 UTC
I tried to edit fetchpo.rb, lib/releaseme/l10n.rb and lib/releaseme/cmakeeditor.rb to enable cmake_edit thing. And now I realized that I am trying to edit a CMakeLists.txt that is currently executing (cmake called the fetchpo.rb script). This is not what I want. The cmake source dir should not be modified; po dir is created in cmake build dir, and that instruction to compile translations should be added to generated files in cmake build dir.
I think that KDECMakeSettings.cmake (or other extra cmake module?) should be modified to do that.

For reference, these are the lines that tarme.rb adds to main CMakeLists.txt:
```
find_package(KF5I18n CONFIG REQUIRED)
ki18n_install(po)
```
but in its case, the po dir is packed in source dir (unlike in fetchpo.rb case).
Comment 2 Bug Janitor Service 2021-11-12 17:35:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/sdk/releaseme/-/merge_requests/14
Comment 3 Andrew Shark 2022-11-28 00:10:13 UTC
Looks like https://invent.kde.org/sysadmin/l10n-scripty/-/merge_requests/16 got merged and translations periodically are commited directly to project repositories. Close.