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

Epic/FOUR-18042: Admin Managed Platform AI Translations #7606

Merged
merged 8 commits into from
Oct 22, 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
10 changes: 8 additions & 2 deletions ProcessMaker/Http/Controllers/Api/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use ProcessMaker\Events\UserCreated;
Expand All @@ -18,7 +19,6 @@
use ProcessMaker\Http\Controllers\Controller;
use ProcessMaker\Http\Resources\ApiCollection;
use ProcessMaker\Http\Resources\Users as UserResource;
use ProcessMaker\Models\RecommendationUser;
use ProcessMaker\Models\User;
use ProcessMaker\RecommendationEngine;
use ProcessMaker\TwoFactorAuthentication;
Expand Down Expand Up @@ -144,7 +144,7 @@ public function index(Request $request)
/**
* Display a listing of users and their task counts.
*
* @param \Illuminate\Http\Request $request
* @param Request $request
* @return \Illuminate\Http\Response
*
* @OA\Get(
Expand Down Expand Up @@ -845,6 +845,12 @@ public function storeFilterConfiguration(String $name, Request $request)

public function updateLanguage(Request $request)
{
if (Auth::user()->is_system) {
Cache::put('LANGUAGE_ANON_WEBENTRY', $request->input('language'), 15);

return response([], 204);
}

$user = Auth::user();
$original = $user->getOriginal();
$user->language = $request->input('language')['code'];
Expand Down
9 changes: 9 additions & 0 deletions ProcessMaker/Managers/PackageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ public function createLanguageFile($code)

// Create file in package
file_put_contents("{$package}/{$code}.json", $baseFile);

// save new language backup
if (File::exists("{$package}.orig")) {
file_put_contents("{$package}.orig/{$code}.json", $baseFile);
}

//Add files gitignore
copy(base_path('resources') . '/.gitignore', $package . '/../.gitignore');
copy(lang_path() . '/.gitignore', $package . '/.gitignore');
}
}
}
Expand Down
1 change: 1 addition & 0 deletions resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lang.orig
3 changes: 2 additions & 1 deletion resources/js/app-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ window.ProcessMaker = {

window.ProcessMaker.i18nPromise = i18next.use(Backend).init({
lng: document.documentElement.lang,
fallbackLng: false,
fallbackLng: "en", // default language when no translations
returnEmptyString: false, // When a translation is an empty string, return the default language, not empty
nsSeparator: false,
keySeparator: false,
parseMissingKeyHandler(value) {
Expand Down
3 changes: 2 additions & 1 deletion resources/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ window.ProcessMaker = {

window.ProcessMaker.i18nPromise = i18next.use(Backend).init({
lng: document.documentElement.lang,
fallbackLng: false,
fallbackLng: "en", // default language when no translations
returnEmptyString: false, // When a translation is an empty string, return the default language, not empty
nsSeparator: false,
keySeparator: false,
parseMissingKeyHandler(value) {
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!en
!en.json
!.gitignore
Loading