Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix updating new language variables for secondary languages #6622

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 config/areas/languages/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
},
'submit' => function (string $languageCode, string $translationKey) {
Find::language($languageCode)->variable($translationKey, true)->update(
App::instance()->request()->get('value')
App::instance()->request()->get('value', '')
);

return true;
Expand Down
8 changes: 4 additions & 4 deletions src/Cms/LanguageVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function create(
throw new DuplicateException('The variable is part of the core translation and cannot be overwritten');
}

$translations[$key] = trim($value ?? '');
$translations[$key] = $value ?? '';

$language->update(['translations' => $translations]);

Expand Down Expand Up @@ -102,10 +102,10 @@ public function key(): string
/**
* Sets a new value for the language variable
*/
public function update(string $value): static
public function update(string|null $value = null): static
{
$translations = $this->language->translations();
$translations[$this->key] = $value;
$translations = $this->language->translations();
$translations[$this->key] = $value ?? '';
afbora marked this conversation as resolved.
Show resolved Hide resolved

$language = $this->language->update(['translations' => $translations]);

Expand Down
Loading