Skip to content

Commit

Permalink
always translate folder name if config value is an array
Browse files Browse the repository at this point in the history
  • Loading branch information
bennet0496 committed Nov 21, 2024
1 parent d7ef76f commit 36cb343
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
14 changes: 6 additions & 8 deletions config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ $config["nextcloud_attachment_dont_try_mail_password"] = false;
// Name for the sub-folder to upload to
// Defaults to "Mail Attachments"
// Can't be sub-folder of sub-folder link folder/sub
//
// The folder name can also be translated according to the users configured locale
// by setting the value to a locale-keyed array like
// ["en_US" => "Mail Attachments", "de_DE" => "E-Mail Anhänge"]
// If locale doesn't exist, en_US or first will be used
$config["nextcloud_attachment_folder"] = "Mail Attachments";
// $config["nextcloud_attachment_folder"] = ["en_US" => "Mail Attachments", "de_DE" => "E-Mail Anhänge"]

// Folder Layout
// "flat" => Flat folder layout, everything in the Folder
Expand Down Expand Up @@ -52,14 +58,6 @@ $config["nextcloud_attachment_softlimit"] = "25M";
// Defaults to "prompt"
$config["nextcloud_attachment_behavior"] = "prompt";

// Translate the folder name according to the users configured locale
// When activating this $config["nextcloud_attachment_folder"] has to be an array
// of locale => name, e.g.
// $config["nextcloud_attachment_folder"] = ["en_US" => "Mail Attachments", "de_DE" => "E-Mail Anhänge"]
// If locale doesn't exist, en_US or first will be used
// Defaults to false
$config["nextcloud_attachment_folder_translate_name"] = false;

// Checksum Algorithm for Attachment Page
// Defaults to sha256
// see https://www.php.net/manual/en/function.hash-algos.php
Expand Down
5 changes: 2 additions & 3 deletions traits/UploadFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,10 @@ public function upload(array $data): array
protected function get_folder(): mixed
{
$folder = $this->rcmail->config->get(__("folder"), "Mail Attachments");
$tr_folder = $this->rcmail->config->get(__("folder_translate_name"), false);
if (is_array($folder)) {
if ($tr_folder && key_exists($this->rcmail->get_user_language(), $folder)) {
if (key_exists($this->rcmail->get_user_language(), $folder)) {
$folder = $folder[$this->rcmail->get_user_language()];
} else if ($tr_folder && key_exists("en_US", $folder)) {
} else if (key_exists("en_US", $folder)) {
$folder = $folder["en_US"];
} else {
$folder = array_first($folder);
Expand Down

0 comments on commit 36cb343

Please sign in to comment.