diff --git a/app/Http/Controllers/AppFunctionsController.php b/app/Http/Controllers/AppFunctionsController.php index d2b95d65..8ad86dbf 100644 --- a/app/Http/Controllers/AppFunctionsController.php +++ b/app/Http/Controllers/AppFunctionsController.php @@ -279,8 +279,6 @@ class AppFunctionsController extends Controller return $lang->with('languageStrings')->first(); }); - // return $lang->with('languageStrings')->first(); - } } diff --git a/app/Http/Helpers/helpers.php b/app/Http/Helpers/helpers.php index 4f96a4f3..d6b05819 100644 --- a/app/Http/Helpers/helpers.php +++ b/app/Http/Helpers/helpers.php @@ -5,6 +5,8 @@ use App\FileManagerFolder; use App\User; use App\Setting; use App\Share; +use App\Language; +use App\LanguageString; use ByteUnits\Metric; use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; @@ -802,3 +804,29 @@ function set_time_by_user_timezone($time) return Carbon::parse($time); } + +function _t($key) +{ + if (Cache::has('language_strings')) { + + //Check if cash has string + $strings = Cache::get('language_strings') + ->languageStrings + ->toArray(); + + // Find the string by key + foreach($strings as $string) { + if($string['key'] === $key) { + return $string['value']; + } + } + } + + $language = Language::whereLocale(get_setting('language')) + ->first(); + + // If cash dont have string return string from database + return LanguageString::whereLangAndKey($language->locale, $key) + ->first() + ->value; +} diff --git a/app/Language.php b/app/Language.php index 0d325d99..0c93f8e2 100644 --- a/app/Language.php +++ b/app/Language.php @@ -5,6 +5,7 @@ namespace App; use App\LanguageString; use Illuminate\Support\Str; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Cache; use Illuminate\Database\Eloquent\Model; class Language extends Model @@ -29,7 +30,13 @@ class Language extends Model }); static::deleting(function ($language) { - $language->languageStrings()->delete(); + DB::table('language_strings') + ->where('lang', $language->locale) + ->delete(); + }); + + static::updated(function() { + Cache::forget('language_strings'); }); static::created(function ($language) { @@ -48,7 +55,8 @@ class Language extends Model })->toArray(); - DB::table('language_strings')->insert($strings); + DB::table('language_strings') + ->insert($strings); }); } diff --git a/app/LanguageString.php b/app/LanguageString.php index 208511e3..f1e35a55 100644 --- a/app/LanguageString.php +++ b/app/LanguageString.php @@ -2,6 +2,7 @@ namespace App; +use Illuminate\Support\Facades\Cache; use Illuminate\Database\Eloquent\Model; class LanguageString extends Model @@ -14,5 +15,14 @@ class LanguageString extends Model protected $fillable = ['value' ,'key', 'lang']; + protected static function boot() + { + parent::boot(); + + static::updated(function() { + dd('test'); + // Cache::forget('language_strings'); + }); + } } diff --git a/composer.json b/composer.json index e258b98d..e9b8ffb8 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,7 @@ "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^4.1", - "phpunit/phpunit": "^8.5", - "supliu/laravel-query-monitor": "^1.0" + "phpunit/phpunit": "^8.5" }, "config": { "optimize-autoloader": true, diff --git a/composer.lock b/composer.lock index 71fd0160..37efbfe3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8101b4e870a27d17a1e4c30c54489cb6", + "content-hash": "2753a719196cd76d1bd7ee346540266c", "packages": [ { "name": "asm89/stack-cors", @@ -7573,53 +7573,6 @@ ], "time": "2020-05-29T17:27:14+00:00" }, - { - "name": "evenement/evenement", - "version": "v3.0.1", - "source": { - "type": "git", - "url": "https://github.com/igorw/evenement.git", - "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7", - "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7", - "shasum": "" - }, - "require": { - "php": ">=7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "Evenement": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "description": "Événement is a very simple event dispatching library for PHP", - "keywords": [ - "event-dispatcher", - "event-emitter" - ], - "support": { - "issues": "https://github.com/igorw/evenement/issues", - "source": "https://github.com/igorw/evenement/tree/master" - }, - "time": "2017-07-23T21:35:13+00:00" - }, { "name": "facade/flare-client-php", "version": "1.3.4", @@ -8861,449 +8814,6 @@ ], "time": "2020-06-22T07:06:58+00:00" }, - { - "name": "react/cache", - "version": "v1.1.1", - "source": { - "type": "git", - "url": "https://github.com/reactphp/cache.git", - "reference": "4bf736a2cccec7298bdf745db77585966fc2ca7e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/cache/zipball/4bf736a2cccec7298bdf745db77585966fc2ca7e", - "reference": "4bf736a2cccec7298bdf745db77585966fc2ca7e", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "react/promise": "^3.0 || ^2.0 || ^1.1" - }, - "require-dev": { - "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Async, Promise-based cache interface for ReactPHP", - "keywords": [ - "cache", - "caching", - "promise", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/cache/issues", - "source": "https://github.com/reactphp/cache/tree/v1.1.1" - }, - "funding": [ - { - "url": "https://github.com/WyriHaximus", - "type": "github" - }, - { - "url": "https://github.com/clue", - "type": "github" - } - ], - "time": "2021-02-02T06:47:52+00:00" - }, - { - "name": "react/dns", - "version": "v1.5.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/dns.git", - "reference": "b22b0b20278e8535e633ab71a52472c5bf620aa1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/dns/zipball/b22b0b20278e8535e633ab71a52472c5bf620aa1", - "reference": "b22b0b20278e8535e633ab71a52472c5bf620aa1", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "react/cache": "^1.0 || ^0.6 || ^0.5", - "react/event-loop": "^1.0 || ^0.5", - "react/promise": "^3.0 || ^2.7 || ^1.2.1", - "react/promise-timer": "^1.2" - }, - "require-dev": { - "clue/block-react": "^1.2", - "phpunit/phpunit": "^9.3 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Dns\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Async DNS resolver for ReactPHP", - "keywords": [ - "async", - "dns", - "dns-resolver", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/dns/issues", - "source": "https://github.com/reactphp/dns/tree/v1.5.0" - }, - "funding": [ - { - "url": "https://github.com/WyriHaximus", - "type": "github" - }, - { - "url": "https://github.com/clue", - "type": "github" - } - ], - "time": "2021-03-05T12:16:50+00:00" - }, - { - "name": "react/event-loop", - "version": "v1.1.1", - "source": { - "type": "git", - "url": "https://github.com/reactphp/event-loop.git", - "reference": "6d24de090cd59cfc830263cfba965be77b563c13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/event-loop/zipball/6d24de090cd59cfc830263cfba965be77b563c13", - "reference": "6d24de090cd59cfc830263cfba965be77b563c13", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35" - }, - "suggest": { - "ext-event": "~1.0 for ExtEventLoop", - "ext-pcntl": "For signal handling support when using the StreamSelectLoop", - "ext-uv": "* for ExtUvLoop" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\EventLoop\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", - "keywords": [ - "asynchronous", - "event-loop" - ], - "support": { - "issues": "https://github.com/reactphp/event-loop/issues", - "source": "https://github.com/reactphp/event-loop/tree/v1.1.1" - }, - "time": "2020-01-01T18:39:52+00:00" - }, - { - "name": "react/promise", - "version": "v2.8.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise.git", - "reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/f3cff96a19736714524ca0dd1d4130de73dbbbc4", - "reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^7.0 || ^6.5 || ^5.7 || ^4.8.36" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com" - } - ], - "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "keywords": [ - "promise", - "promises" - ], - "support": { - "issues": "https://github.com/reactphp/promise/issues", - "source": "https://github.com/reactphp/promise/tree/v2.8.0" - }, - "time": "2020-05-12T15:16:56+00:00" - }, - { - "name": "react/promise-timer", - "version": "v1.6.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise-timer.git", - "reference": "daee9baf6ef30c43ea4c86399f828bb5f558f6e6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise-timer/zipball/daee9baf6ef30c43ea4c86399f828bb5f558f6e6", - "reference": "daee9baf6ef30c43ea4c86399f828bb5f558f6e6", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5", - "react/promise": "^3.0 || ^2.7.0 || ^1.2.1" - }, - "require-dev": { - "phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Promise\\Timer\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@lueck.tv" - } - ], - "description": "A trivial implementation of timeouts for Promises, built on top of ReactPHP.", - "homepage": "https://github.com/reactphp/promise-timer", - "keywords": [ - "async", - "event-loop", - "promise", - "reactphp", - "timeout", - "timer" - ], - "support": { - "issues": "https://github.com/reactphp/promise-timer/issues", - "source": "https://github.com/reactphp/promise-timer/tree/v1.6.0" - }, - "time": "2020-07-10T12:18:06+00:00" - }, - { - "name": "react/socket", - "version": "v1.6.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/socket.git", - "reference": "e2b96b23a13ca9b41ab343268dbce3f8ef4d524a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/socket/zipball/e2b96b23a13ca9b41ab343268dbce3f8ef4d524a", - "reference": "e2b96b23a13ca9b41ab343268dbce3f8ef4d524a", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.0", - "react/dns": "^1.1", - "react/event-loop": "^1.0 || ^0.5", - "react/promise": "^2.6.0 || ^1.2.1", - "react/promise-timer": "^1.4.0", - "react/stream": "^1.1" - }, - "require-dev": { - "clue/block-react": "^1.2", - "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", - "react/promise-stream": "^1.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Socket\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", - "keywords": [ - "Connection", - "Socket", - "async", - "reactphp", - "stream" - ], - "support": { - "issues": "https://github.com/reactphp/socket/issues", - "source": "https://github.com/reactphp/socket/tree/v1.6.0" - }, - "funding": [ - { - "url": "https://github.com/WyriHaximus", - "type": "github" - }, - { - "url": "https://github.com/clue", - "type": "github" - } - ], - "time": "2020-08-28T12:49:05+00:00" - }, - { - "name": "react/stream", - "version": "v1.1.1", - "source": { - "type": "git", - "url": "https://github.com/reactphp/stream.git", - "reference": "7c02b510ee3f582c810aeccd3a197b9c2f52ff1a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/stream/zipball/7c02b510ee3f582c810aeccd3a197b9c2f52ff1a", - "reference": "7c02b510ee3f582c810aeccd3a197b9c2f52ff1a", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.8", - "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5" - }, - "require-dev": { - "clue/stream-filter": "~1.2", - "phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Stream\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", - "keywords": [ - "event-driven", - "io", - "non-blocking", - "pipe", - "reactphp", - "readable", - "stream", - "writable" - ], - "support": { - "issues": "https://github.com/reactphp/stream/issues", - "source": "https://github.com/reactphp/stream/tree/v1.1.1" - }, - "time": "2020-05-04T10:17:57+00:00" - }, { "name": "scrivo/highlight.php", "version": "v9.18.1.1", @@ -10091,75 +9601,6 @@ ], "time": "2020-07-07T18:42:57+00:00" }, - { - "name": "supliu/laravel-query-monitor", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/supliu/laravel-query-monitor.git", - "reference": "f609e30cfc544a3621b8b4799aef6908f89c1ae8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/supliu/laravel-query-monitor/zipball/f609e30cfc544a3621b8b4799aef6908f89c1ae8", - "reference": "f609e30cfc544a3621b8b4799aef6908f89c1ae8", - "shasum": "" - }, - "require": { - "laravel/framework": "^5.6 || ^6.0 || ^7.0 || ^8.0", - "php": "^7.3", - "react/socket": "^1.4" - }, - "require-dev": { - "orchestra/testbench": "^3.6 || ^4.0 || ^5.0 || ^6.0", - "phpunit/phpunit": "^9.2@dev" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - }, - "laravel": { - "providers": [ - "Supliu\\LaravelQueryMonitor\\ServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Supliu\\LaravelQueryMonitor\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jansen Felipe", - "email": "jansen.felipe@gmail.com" - } - ], - "description": "Laravel Query Monitor", - "keywords": [ - "eloquent", - "laravel", - "monitor", - "query", - "sql" - ], - "support": { - "issues": "https://github.com/supliu/laravel-query-monitor/issues", - "source": "https://github.com/supliu/laravel-query-monitor/tree/1.0.2" - }, - "funding": [ - { - "url": "https://www.patreon.com/supliutech", - "type": "patreon" - } - ], - "time": "2021-03-04T14:35:53+00:00" - }, { "name": "symfony/filesystem", "version": "v5.1.3", diff --git a/config/language_strings.php b/config/language_strings.php index e8624eb1..81288548 100644 --- a/config/language_strings.php +++ b/config/language_strings.php @@ -609,7 +609,71 @@ return [ "user_subscription.status" => "Status", "user_subscription.title" => "Subscription Plan", "validation_errors.incorrect_password" => "Sorry, you passed incorrect password :(", - "validation_errors.wrong_image" => "You may have uploaded the wrong file, try again!" + "validation_errors.wrong_image" => "You may have uploaded the wrong file, try again!", + + // Laravel + 'app_description' => 'Your self-hosted storage cloud software powered by Laravel and Vue', + 'user_not_fount' => 'We can\'t find a user with that e-mail address.', + 'incorrect_password' => 'Sorry, your password is incorrect.', + 'time' => '%d. %B. %Y at %H:%M', + 'home' => 'Home', + + //Shared link email message + 'shared_link_email_subject' => '🙋 :user share some files with you. Look at it!', + 'shared_link_email_greeting' => 'Hello!', + 'shared_link_email_user' => ':user (:email) send you a link to shared files.', + 'shared_link_email_link' => 'Open your files', + 'shared_link_email_salutation' => 'Regards, :app_name', + + // Reset password email + 'reset_password_greeting' => 'Hello!', + 'reset_password_subject' => 'Reset password for your account on ', + 'reset_password_line_1' => 'You are receiving this email because we received a password reset request for your account.', + 'reset_password_line_2' => 'If you did not request a password reset, no further action is required.', + 'reset_password_action' => 'Reset Password', + + 'salutation' => 'Regards', + + // Invoice + 'print_button' => 'Print Document', + + 'vat' => 'VAT', + 'vat_included' => 'incl.', + 'subtotal' => 'Subtotal', + + 'tax_exempted' => 'Tax is exempted', + 'tax_be_paid_reverse' => 'Tax to be paid on reverse charge basis', + + 'invoice_title' => 'Invoice', + 'date' => 'Date', + 'product' => 'Product', + 'subscription' => 'Subscription', + 'invoice_number' => 'Invoice Number', + + 'seller' => 'Seller', + 'client' => 'Client', + + 'seller_vat' => 'VAT number', + 'seller_name' => 'Name', + 'seller_phone' => 'Phone', + + 'name' => 'Name', + 'phone' => 'Phone', + 'address' => 'Address', + 'city' => 'City', + 'state' => 'State', + 'postal_code' => 'Postal code', + 'country' => 'Country', + + 'col_description' => 'Description', + 'col_date' => 'Date', + 'col_amount' => 'Amount', + + 'total' => 'Total', + + // OG Page + 'user_sending' => ':name is sending you this file', + 'protected_file' => 'This link is protected by password', ], 'regular' => [ diff --git a/config/laravel-query-monitor.php b/config/laravel-query-monitor.php deleted file mode 100644 index d3597eb7..00000000 --- a/config/laravel-query-monitor.php +++ /dev/null @@ -1,7 +0,0 @@ - env('LARAVEL_QUERY_MONITOR', true), - 'host' => env('LARAVEL_QUERY_MONITOR_HOST', '0.0.0.0'), - 'port' => env('LARAVEL_QUERY_MONITOR_PORT', 8081), -]; diff --git a/routes/api.php b/routes/api.php index d4f836da..378bca58 100644 --- a/routes/api.php +++ b/routes/api.php @@ -171,6 +171,7 @@ Route::group(['middleware' => ['auth:api', 'auth.master', 'auth.admin', 'scope:m Route::get('/settings', 'SettingController@show'); Route::get('/flush-cache', 'AppFunctionsController@flush_cache'); + // Language Route::group(['prefix' => 'languages'], function () { Route::get('/{language}/strings', 'Admin\LanguageController@get_language_strings'); Route::patch('/{language}/string', 'Admin\LanguageController@update_string'); @@ -179,9 +180,6 @@ Route::group(['middleware' => ['auth:api', 'auth.master', 'auth.admin', 'scope:m Route::post('/', 'Admin\LanguageController@create_language'); Route::get('/', 'Admin\LanguageController@get_languages'); }); - - // Language - }); // Protected sharing routes for authenticated user @@ -206,9 +204,9 @@ Route::group(['middleware' => ['auth:api', 'auth.shared', 'auth.master', 'scope: Route::post('/upload', 'FileFunctions\EditItemsController@user_upload'); Route::post('/move', 'FileFunctions\EditItemsController@user_move'); - //Get translate - Route::get('/language/{lang}', 'AppFunctionsController@get_translate'); - //Get Emojis List Route::get('/emojis-list', 'AppFunctionsController@get_emojis_list'); }); + +//Get translate +Route::get('/language/{lang}', 'AppFunctionsController@get_translate');