Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ To more informations about how this app works or to get examples, look at the ad
<bugs>https://github.com/librecodecoop/l10n_override/issues</bugs>
<repository type="git">https://github.com/librecodecoop/l10n_override</repository>
<dependencies>
<nextcloud min-version="28" max-version="28"/>
<nextcloud min-version="30" max-version="31"/>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also will be necessary bump the version:

<version>2.0.0</version>

Considering that is to be compatible with a newest version of Nextcloud server and considering the Nextcloud server as a framework, we can talk that it's should be a major increment.

What's you think about this? Maybe could be 3.0.0

Copy link
Copy Markdown
Author

@JonathanTreffler JonathanTreffler Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there are no breaking changes to public interfaces per Semantic Versioning the correct version would be 2.1.0, but I personally would also be OK with 3.0.0, if you prefer that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another point....

I know that could be a bit complex to make backports but we can set the min and max versionto 32 and after this, send the backport to a branch stable31.

We also can drop Nextcloud 30 because the official support by server will finish into September as we can see here: https://github.com/nextcloud/server/wiki/Maintenance-and-Release-Schedule

Copy link
Copy Markdown
Author

@JonathanTreffler JonathanTreffler Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I just realized I got the PR title wrong. NC 32 is not even out yet, i meant 30 and 31. And AFAIK apps should not mark themselves compatible with a version until that version is at least very close to a release.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any upside to going the backport way ?
I think normally this would be done when code changes to the app are needed between the two versions, so features can be backported to the old branch too.
Since this is only compatibility changes, no feature changes and no code changes between the versions are needed I think this approach would be simpler:
Releasing one version which covers both 30 and 31 and just drop NC 30 with any next release after September, when it is no longer supported.

</dependencies>
<commands>
<command>OCA\L10nOverride\Command\Add</command>
Expand Down
604 changes: 416 additions & 188 deletions composer.lock

Large diffs are not rendered by default.

21 changes: 4 additions & 17 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@

namespace OCA\L10nOverride\AppInfo;

use OC;
use OCA\L10nOverride\Service\OverrideService;
use OCA\L10nOverride\Listener\AppEnabledDisabledListener;
use OCP\App\Events\AppDisableEvent;
use OCP\App\Events\AppEnableEvent;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;

use OCP\AppFramework\Bootstrap\IRegistrationContext;

/**
Expand All @@ -46,23 +46,10 @@ public function __construct() {
}

public function boot(IBootContext $context): void {
$event = OC::$server->getEventDispatcher();
$event->addListener(AppEnableEvent::class, [$this, 'onAppEnabled']);
$event->addListener(AppDisableEvent::class, [$this, 'onAppDisabled']);
}

public function register(IRegistrationContext $context): void {
}

public function onAppEnabled(AppEnableEvent $event): void {
/** @var OverrideService */
$overrideService = OC::$server->get(OverrideService::class);
$overrideService->updateAllLanguages($event->getAppId());
}

public function onAppDisabled(AppDisableEvent $event): void {
/** @var OverrideService */
$overrideService = OC::$server->get(OverrideService::class);
$overrideService->deleteAllLanguages($event->getAppId());
$context->registerEventListener(AppEnableEvent::class, AppEnabledDisabledListener::class);
$context->registerEventListener(AppDisableEvent::class, AppEnabledDisabledListener::class);
}
}
31 changes: 31 additions & 0 deletions lib/Listener/AppEnabledDisabledListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace OCA\L10nOverride\Listener;

use OCA\L10nOverride\Service\OverrideService;
use OCP\App\Events\AppDisableEvent;
use OCP\App\Events\AppEnableEvent;
use OCP\EventDispatcher\Event;

use OCP\EventDispatcher\IEventListener;

/**
* @template-implements IEventListener<AppEnableEvent|AppDisableEvent>
*/
class AppEnabledDisabledListener implements IEventListener {

public function __construct(
private readonly OverrideService $overrideService,
) {
}

public function handle(Event $event): void {
if ($event instanceof AppEnableEvent) {
$this->overrideService->updateAllLanguages($event->getAppId());
} elseif ($event instanceof AppDisableEvent) {
$this->overrideService->deleteAllLanguages($event->getAppId());
}
}
}
15 changes: 8 additions & 7 deletions lib/Service/OverrideService.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function updateAllLanguages(string $appId): void {
appId: $appId,
);
foreach ($languages as $language) {
$this->update($this->text->getTheme(), $appId, $language);
$this->update($appId, $language);
}
}

Expand Down Expand Up @@ -103,15 +103,16 @@ private function updateFiles(): void {
private function removeFiles(): void {
$extensions = ['js', 'json'];
foreach ($extensions as $extension) {
if (file_exists($this->getThemeL10nFolder() . $this->text->getNewLanguage() . '.' . $extension)) {
$file = $this->getThemeL10nFolder() . $this->text->getNewLanguage() . '.' . $extension;
exec('rm -rf ' . escapeshellarg($file));
$file = $this->getThemeL10nFolder() . $this->text->getNewLanguage() . '.' . $extension;
if (is_file($file)) {
unlink($file);
}
}

$dir = $this->getThemeL10nFolder();
// Remove empty folders
while (!(new \FilesystemIterator($dir))->valid() && $dir !== $this->serverRoot . '/themes') {
exec('rm -rf ' . escapeshellarg($dir));
while (is_dir($dir) && !(new \FilesystemIterator($dir))->valid() && $dir !== $this->serverRoot . '/themes') {
rmdir($dir);
$dir = dirname($dir);
}
}
Expand Down Expand Up @@ -146,7 +147,7 @@ private function updateJsFile() {

private function write(string $format, string $content): void {
if (!is_dir($this->getThemeL10nFolder())) {
exec('mkdir -p ' . escapeshellarg($this->getThemeL10nFolder()));
mkdir($this->getThemeL10nFolder(), 0755, true);
}
$fileName = $this->getThemeL10nFolder() . $this->text->getNewLanguage() . '.' . $format;
file_put_contents($fileName, $content);
Expand Down
1 change: 1 addition & 0 deletions tests/php/Commands/CommandsTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (c) 2023 Vitor Mattos <vitor@php.rio>
*
Expand Down
1 change: 1 addition & 0 deletions tests/php/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
Expand Down
Loading
Loading