add phraseapp in context editor
This commit is contained in:
parent
e5ed1c7f6a
commit
8fc30fbe3a
5 changed files with 138 additions and 1 deletions
45
app/Extensions/Translator.php
Normal file
45
app/Extensions/Translator.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Pterodactyl - Panel
|
||||||
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Pterodactyl\Extensions;
|
||||||
|
|
||||||
|
use Illuminate\Translation\Translator as LaravelTranslator;
|
||||||
|
|
||||||
|
class Translator extends LaravelTranslator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the translation for the given key.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param array $replace
|
||||||
|
* @param string|null $locale
|
||||||
|
* @param bool $fallback
|
||||||
|
* @return string|array|null
|
||||||
|
*/
|
||||||
|
public function get($key, array $replace = [], $locale = null, $fallback = true)
|
||||||
|
{
|
||||||
|
$key = substr($key, strpos($key, '.') + 1);
|
||||||
|
return "{{__phrase_${key}__}}";
|
||||||
|
}
|
||||||
|
}
|
63
app/Providers/TranslationProvider.php
Normal file
63
app/Providers/TranslationProvider.php
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Pterodactyl - Panel
|
||||||
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Pterodactyl\Providers;
|
||||||
|
|
||||||
|
use Pterodactyl\Extensions\Translator as PterodactylTranslator;
|
||||||
|
use Illuminate\Translation\Translator;
|
||||||
|
use Illuminate\Translation\TranslationServiceProvider;
|
||||||
|
|
||||||
|
class TranslationProvider extends TranslationServiceProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->registerLoader();
|
||||||
|
|
||||||
|
$this->app->singleton('translator', function ($app) {
|
||||||
|
$loader = $app['translation.loader'];
|
||||||
|
|
||||||
|
// When registering the translator component, we'll need to set the default
|
||||||
|
// locale as well as the fallback locale. So, we'll grab the application
|
||||||
|
// configuration so we can easily get both of these values from there.
|
||||||
|
$locale = $app['config']['app.locale'];
|
||||||
|
|
||||||
|
if ($app['config']['app.phrase_in_context']) {
|
||||||
|
$trans = new PterodactylTranslator($loader, $locale);
|
||||||
|
} else {
|
||||||
|
$trans = new Translator($loader, $locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
$trans->setFallback($app['config']['app.fallback_locale']);
|
||||||
|
|
||||||
|
return $trans;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,8 @@ return [
|
||||||
|
|
||||||
'version' => env('APP_VERSION', 'canary'),
|
'version' => env('APP_VERSION', 'canary'),
|
||||||
|
|
||||||
|
'phrase_in_context' => env('PHRASE_IN_CONTEXT', false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Application Debug Mode
|
| Application Debug Mode
|
||||||
|
@ -137,7 +139,7 @@ return [
|
||||||
Illuminate\Redis\RedisServiceProvider::class,
|
Illuminate\Redis\RedisServiceProvider::class,
|
||||||
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
|
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
|
||||||
Illuminate\Session\SessionServiceProvider::class,
|
Illuminate\Session\SessionServiceProvider::class,
|
||||||
Illuminate\Translation\TranslationServiceProvider::class,
|
//Illuminate\Translation\TranslationServiceProvider::class,
|
||||||
Illuminate\Validation\ValidationServiceProvider::class,
|
Illuminate\Validation\ValidationServiceProvider::class,
|
||||||
Illuminate\View\ViewServiceProvider::class,
|
Illuminate\View\ViewServiceProvider::class,
|
||||||
Illuminate\Notifications\NotificationServiceProvider::class,
|
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||||
|
@ -149,6 +151,7 @@ return [
|
||||||
Pterodactyl\Providers\AuthServiceProvider::class,
|
Pterodactyl\Providers\AuthServiceProvider::class,
|
||||||
Pterodactyl\Providers\EventServiceProvider::class,
|
Pterodactyl\Providers\EventServiceProvider::class,
|
||||||
Pterodactyl\Providers\RouteServiceProvider::class,
|
Pterodactyl\Providers\RouteServiceProvider::class,
|
||||||
|
Pterodactyl\Providers\TranslationProvider::class,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Additional Dependencies
|
* Additional Dependencies
|
||||||
|
|
|
@ -49,5 +49,18 @@
|
||||||
</div>
|
</div>
|
||||||
{!! Theme::js('js/vendor/jquery/jquery.min.js') !!}
|
{!! Theme::js('js/vendor/jquery/jquery.min.js') !!}
|
||||||
{!! Theme::js('vendor/bootstrap/bootstrap.min.js') !!}
|
{!! Theme::js('vendor/bootstrap/bootstrap.min.js') !!}
|
||||||
|
|
||||||
|
@if(config('app.phrase_in_context'))
|
||||||
|
<script>
|
||||||
|
window.PHRASEAPP_CONFIG = {
|
||||||
|
projectId: '94f8b39450cd749ae9c3cc0ab8cdb61d'
|
||||||
|
};
|
||||||
|
(function() {
|
||||||
|
var phraseapp = document.createElement('script'); phraseapp.type = 'text/javascript'; phraseapp.async = true;
|
||||||
|
phraseapp.src = ['https://', 'phraseapp.com/assets/in-context-editor/2.0/app.js?', new Date().getTime()].join('');
|
||||||
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(phraseapp, s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
@endif
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -281,6 +281,19 @@
|
||||||
{!! Theme::js('vendor/adminlte/app.min.js') !!}
|
{!! Theme::js('vendor/adminlte/app.min.js') !!}
|
||||||
{!! Theme::js('js/vendor/socketio/socket.io.min.js') !!}
|
{!! Theme::js('js/vendor/socketio/socket.io.min.js') !!}
|
||||||
{!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js') !!}
|
{!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js') !!}
|
||||||
|
|
||||||
|
@if(config('app.phrase_in_context'))
|
||||||
|
<script>
|
||||||
|
window.PHRASEAPP_CONFIG = {
|
||||||
|
projectId: '94f8b39450cd749ae9c3cc0ab8cdb61d'
|
||||||
|
};
|
||||||
|
(function() {
|
||||||
|
var phraseapp = document.createElement('script'); phraseapp.type = 'text/javascript'; phraseapp.async = true;
|
||||||
|
phraseapp.src = ['https://', 'phraseapp.com/assets/in-context-editor/2.0/app.js?', new Date().getTime()].join('');
|
||||||
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(phraseapp, s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
@endif
|
||||||
@show
|
@show
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue