mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
Merge pull request #848 from openclassify/vedatakdogan
Changing texts according to project
This commit is contained in:
commit
70e8d039a9
@ -67,7 +67,7 @@ return [
|
|||||||
'user' => [
|
'user' => [
|
||||||
'title' => 'visiosoft.module.advs::section.user',
|
'title' => 'visiosoft.module.advs::section.user',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'register_email_field',
|
'register_email_field'
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'filter' => [
|
'filter' => [
|
||||||
@ -76,6 +76,12 @@ return [
|
|||||||
'hide_price_filter', 'hide_date_filter', 'hide_photo_filter', 'hide_map_filter', 'user_filter_limit'
|
'hide_price_filter', 'hide_date_filter', 'hide_photo_filter', 'hide_map_filter', 'user_filter_limit'
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'translations' => [
|
||||||
|
'title' => 'visiosoft.module.advs::section.translations',
|
||||||
|
'fields' => [
|
||||||
|
'override_text',
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -339,4 +339,9 @@ return [
|
|||||||
'mode' => 'checkbox'
|
'mode' => 'checkbox'
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'override_text' => [
|
||||||
|
'type' => 'anomaly.field_type.tags',
|
||||||
|
'bind' => 'override_text',
|
||||||
|
'env' => 'OVERRIDE_TEXT',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -42,4 +42,5 @@ return [
|
|||||||
'replicate' => 'Replicate',
|
'replicate' => 'Replicate',
|
||||||
'fast_create' => 'Fast create',
|
'fast_create' => 'Fast create',
|
||||||
'publish' => 'Publish',
|
'publish' => 'Publish',
|
||||||
|
'import' => 'Import',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -55,4 +55,5 @@ return [
|
|||||||
'option_configuration' => [
|
'option_configuration' => [
|
||||||
'title' => 'Configuration',
|
'title' => 'Configuration',
|
||||||
],
|
],
|
||||||
|
'translations' => 'Translations',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -205,4 +205,8 @@ return [
|
|||||||
'name' => 'Show Post Ad Agreement',
|
'name' => 'Show Post Ad Agreement',
|
||||||
'instructions' => 'Turn this on if you want to display a privacy policy agreement on the ad creation page',
|
'instructions' => 'Turn this on if you want to display a privacy policy agreement on the ad creation page',
|
||||||
],
|
],
|
||||||
|
'override_text' => [
|
||||||
|
'name' => 'Override Text',
|
||||||
|
'instructions' => 'Old Value:New Value'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
19
addons/default/visiosoft/advs-module/src/Adv/AdvsImport.php
Normal file
19
addons/default/visiosoft/advs-module/src/Adv/AdvsImport.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
namespace Visiosoft\AdvsModule\Adv;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Maatwebsite\Excel\Concerns\ToModel;
|
||||||
|
|
||||||
|
class AdvsImport implements ToModel
|
||||||
|
{
|
||||||
|
public function model(array $row)
|
||||||
|
{
|
||||||
|
return new AdvModel([
|
||||||
|
'name' => $row[0],
|
||||||
|
'slug' => Str::slug($row[0]),
|
||||||
|
'price' => $row[1],
|
||||||
|
'currency' => $row[2],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,13 +25,7 @@ class AdvTableButtons
|
|||||||
return ($entry->getStatus() == 'approved') ? "danger" : "success";
|
return ($entry->getStatus() == 'approved') ? "danger" : "success";
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'edit',
|
||||||
'edit' => [
|
|
||||||
'href' => function (EntryModel $entry) {
|
|
||||||
return route('visiosoft.module.advs::edit_adv', ['id' => $entry->getId()]);
|
|
||||||
},
|
|
||||||
'text' => "<font class='hidden-xs-down'>" . trans('streams::button.edit') . "</font>"
|
|
||||||
],
|
|
||||||
'settings' => [
|
'settings' => [
|
||||||
'text' => false,
|
'text' => false,
|
||||||
'href' => false,
|
'href' => false,
|
||||||
|
|||||||
@ -1,13 +1,56 @@
|
|||||||
<?php namespace Visiosoft\AdvsModule;
|
<?php namespace Visiosoft\AdvsModule;
|
||||||
|
|
||||||
|
use Anomaly\FilesModule\Disk\Contract\DiskRepositoryInterface;
|
||||||
|
use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
|
||||||
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
|
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
|
||||||
|
|
||||||
class AdvsModuleSeeder extends Seeder
|
class AdvsModuleSeeder extends Seeder
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The disk repository.
|
||||||
|
*
|
||||||
|
* @var DiskRepositoryInterface
|
||||||
|
*/
|
||||||
|
protected $disks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The folder repository.
|
||||||
|
*
|
||||||
|
* @var FolderRepositoryInterface
|
||||||
|
*/
|
||||||
|
protected $folders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new FolderSeeder instance.
|
||||||
|
*
|
||||||
|
* @param DiskRepositoryInterface $disks
|
||||||
|
* @param FolderRepositoryInterface $folders
|
||||||
|
*/
|
||||||
|
public function __construct(DiskRepositoryInterface $disks, FolderRepositoryInterface $folders)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->disks = $disks;
|
||||||
|
$this->folders = $folders;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the seeder.
|
* Run the seeder.
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
//Create Store Icon Folder
|
||||||
|
if (!$this->folders->findBySlug('ads_excel')) {
|
||||||
|
$disk = $this->disks->findBySlug('local');
|
||||||
|
|
||||||
|
$this->folders->create([
|
||||||
|
'en' => [
|
||||||
|
'name' => 'Ads Excel',
|
||||||
|
'description' => 'A folder for Ads Excel.',
|
||||||
|
],
|
||||||
|
'slug' => 'ads_excel',
|
||||||
|
'disk' => $disk
|
||||||
|
]);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,10 +47,18 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
|||||||
],
|
],
|
||||||
'admin/advs-users/choose/{advId}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@choose',
|
'admin/advs-users/choose/{advId}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@choose',
|
||||||
'admin/class/actions/{id}/{type}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@actions',
|
'admin/class/actions/{id}/{type}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@actions',
|
||||||
'admin/advs/export' => [
|
|
||||||
'as' => 'advs::exportAdvs',
|
|
||||||
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@exportAdvs',
|
//Excel
|
||||||
],
|
'admin/advs/export' => [
|
||||||
|
'as' => 'advs::exportAdvs',
|
||||||
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@exportAdvs',
|
||||||
|
],
|
||||||
|
'admin/advs/import' => [
|
||||||
|
'as' => 'visiosoft.module.advs::import.advs',
|
||||||
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\ExcelController@import',
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
// advsController
|
// advsController
|
||||||
'advs/list' => [
|
'advs/list' => [
|
||||||
@ -187,25 +195,25 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
|||||||
// Others
|
// Others
|
||||||
'advs/ttr/{id}' => 'Visiosoft\PackagesModule\Http\Controller\packageFEController@advsStatusbyUser',
|
'advs/ttr/{id}' => 'Visiosoft\PackagesModule\Http\Controller\packageFEController@advsStatusbyUser',
|
||||||
|
|
||||||
//Configurations Admin Controller
|
//Configurations Admin Controller
|
||||||
'admin/advs/option_configuration/create' => [
|
'admin/advs/option_configuration/create' => [
|
||||||
'as' => 'visiosoft.module.advs::configrations.create',
|
'as' => 'visiosoft.module.advs::configrations.create',
|
||||||
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\OptionConfigurationController@create',
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\OptionConfigurationController@create',
|
||||||
],
|
],
|
||||||
'admin/advs/option_configuration' => [
|
'admin/advs/option_configuration' => [
|
||||||
'as' => 'visiosoft.module.advs::configrations.index',
|
'as' => 'visiosoft.module.advs::configrations.index',
|
||||||
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\OptionConfigurationController@index',
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\OptionConfigurationController@index',
|
||||||
],
|
],
|
||||||
|
|
||||||
//Configuration Controller
|
//Configuration Controller
|
||||||
'advs/option_configuration/create' => [
|
'advs/option_configuration/create' => [
|
||||||
'as' => 'visiosoft.module.advs::user.configrations.create',
|
'as' => 'visiosoft.module.advs::user.configrations.create',
|
||||||
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@create',
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@create',
|
||||||
],
|
],
|
||||||
'conf/addCart' => [
|
'conf/addCart' => [
|
||||||
'as' => 'configuration::add_cart',
|
'as' => 'configuration::add_cart',
|
||||||
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@confAddCart',
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@confAddCart',
|
||||||
],
|
],
|
||||||
|
|
||||||
// Admin ProductoptionsController
|
// Admin ProductoptionsController
|
||||||
'admin/advs/product_options' => 'Visiosoft\AdvsModule\Http\Controller\Admin\ProductoptionsController@index',
|
'admin/advs/product_options' => 'Visiosoft\AdvsModule\Http\Controller\Admin\ProductoptionsController@index',
|
||||||
@ -236,9 +244,9 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
|||||||
CategoryRepositoryInterface::class => CategoryRepository::class,
|
CategoryRepositoryInterface::class => CategoryRepository::class,
|
||||||
CountryRepositoryInterface::class => CountryRepository::class,
|
CountryRepositoryInterface::class => CountryRepository::class,
|
||||||
OptionRepositoryInterface::class => OptionRepository::class,
|
OptionRepositoryInterface::class => OptionRepository::class,
|
||||||
ProductoptionRepositoryInterface::class => ProductoptionRepository::class,
|
ProductoptionRepositoryInterface::class => ProductoptionRepository::class,
|
||||||
OptionConfigurationRepositoryInterface::class => OptionConfigurationRepository::class,
|
OptionConfigurationRepositoryInterface::class => OptionConfigurationRepository::class,
|
||||||
ProductoptionsValueRepositoryInterface::class => ProductoptionsValueRepository::class,
|
ProductoptionsValueRepositoryInterface::class => ProductoptionsValueRepository::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function boot(AddonCollection $addonCollection, FileModel $fileModel)
|
public function boot(AddonCollection $addonCollection, FileModel $fileModel)
|
||||||
@ -247,30 +255,35 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
|||||||
'general_settings' => [
|
'general_settings' => [
|
||||||
'title' => 'visiosoft.module.advs::button.general_settings',
|
'title' => 'visiosoft.module.advs::button.general_settings',
|
||||||
'href' => '/admin/settings/modules/visiosoft.module.advs',
|
'href' => '/admin/settings/modules/visiosoft.module.advs',
|
||||||
'page' => 'anomaly.module.settings'
|
'page' => 'anomaly.module.settings'
|
||||||
],
|
],
|
||||||
'theme_settings' => [
|
'theme_settings' => [
|
||||||
'title' => 'visiosoft.theme.defaultadmin::section.theme_settings.name',
|
'title' => 'visiosoft.theme.defaultadmin::section.theme_settings.name',
|
||||||
'href' => url('admin/settings/themes/' . setting_value('streams::standard_theme')),
|
'href' => url('admin/settings/themes/' . setting_value('streams::standard_theme')),
|
||||||
'page' => 'anomaly.module.settings'
|
'page' => 'anomaly.module.settings'
|
||||||
],
|
],
|
||||||
'assets_clear' => [
|
'assets_clear' => [
|
||||||
'title' => 'visiosoft.module.advs::section.assets_clear.name',
|
'title' => 'visiosoft.module.advs::section.assets_clear.name',
|
||||||
'href' => route('assets_clear'),
|
'href' => route('assets_clear'),
|
||||||
'page' => 'anomaly.module.settings'
|
'page' => 'anomaly.module.settings'
|
||||||
],
|
],
|
||||||
'export' => [
|
'export' => [
|
||||||
'title' => 'visiosoft.module.advs::button.export',
|
'title' => 'visiosoft.module.advs::button.export',
|
||||||
'href' => route('advs::exportAdvs'),
|
'href' => route('advs::exportAdvs'),
|
||||||
'page' => 'visiosoft.module.advs'
|
'page' => 'visiosoft.module.advs'
|
||||||
]
|
],
|
||||||
|
'import' => [
|
||||||
|
'title' => 'visiosoft.module.advs::button.import',
|
||||||
|
'href' => route('visiosoft.module.advs::import.advs'),
|
||||||
|
'page' => 'visiosoft.module.advs'
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($settings_url as $key => $value) {
|
foreach ($settings_url as $key => $value) {
|
||||||
$addonCollection->get($value['page'])->addSection($key, $value);
|
$addonCollection->get($value['page'])->addSection($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable file versioning
|
// Disable file versioning
|
||||||
$fileModel->disableVersioning();
|
$fileModel->disableVersioning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
<?php namespace Visiosoft\AdvsModule\Http\Controller\Admin;
|
||||||
|
|
||||||
|
use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
|
||||||
|
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||||
|
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Visiosoft\AdvsModule\Adv\AdvsImport;
|
||||||
|
|
||||||
|
class ExcelController extends AdminController
|
||||||
|
{
|
||||||
|
public function import(FormBuilder $builder, FileRepositoryInterface $fileRepository)
|
||||||
|
{
|
||||||
|
if (request()->action == "save" and $file = $fileRepository->find(request()->file)) {
|
||||||
|
if ($file->extension === 'xls' || $file->extension === 'xlsx') {
|
||||||
|
$pathToFolder = "/storage/streams/default/files-module/local/ads_excel/";
|
||||||
|
Excel::import(new AdvsImport(), base_path() . $pathToFolder . $file->name);
|
||||||
|
$this->messages->success(trans('streams::message.create_success', ['name' => trans('module::addon.title')]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Form Render
|
||||||
|
$builder->setFields([
|
||||||
|
'file' => [
|
||||||
|
"type" => "anomaly.field_type.file",
|
||||||
|
"config" => [
|
||||||
|
'folders' => ["ads_excel"],
|
||||||
|
'mode' => 'upload'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$builder->setActions([
|
||||||
|
'save'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->setOptions([
|
||||||
|
'redirect' => route('visiosoft.module.advs::admin_advs')
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $builder->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
266
app/Lang/Loader.php
Normal file
266
app/Lang/Loader.php
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
<?php namespace App\Lang;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Addon\Addon;
|
||||||
|
use Anomaly\Streams\Platform\Addon\AddonCollection;
|
||||||
|
use Anomaly\Streams\Platform\Application\Application;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Illuminate\Translation\FileLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Loader
|
||||||
|
*
|
||||||
|
* @link http://pyrocms.com/
|
||||||
|
* @author PyroCMS, Inc. <support@pyrocms.com>
|
||||||
|
* @author Ryan Thompson <ryan@pyrocms.com>
|
||||||
|
*/
|
||||||
|
class Loader extends FileLoader
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The runtime cache.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected static $disabled = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The streams path.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $streams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The addon collection instance.
|
||||||
|
*
|
||||||
|
* @var AddonCollection
|
||||||
|
*/
|
||||||
|
protected $addons;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application instance.
|
||||||
|
*
|
||||||
|
* @var Application
|
||||||
|
*/
|
||||||
|
protected $application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Loader instance.
|
||||||
|
*
|
||||||
|
* @param Filesystem $files
|
||||||
|
* @param string $path
|
||||||
|
*/
|
||||||
|
public function __construct(Filesystem $files, $path)
|
||||||
|
{
|
||||||
|
$this->streams = base_path('vendor/visiosoft/streams-platform/resources/lang');
|
||||||
|
|
||||||
|
$this->application = app(Application::class);
|
||||||
|
$this->addons = app(AddonCollection::class);
|
||||||
|
|
||||||
|
parent::__construct($files, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a locale from a given path.
|
||||||
|
*
|
||||||
|
* Keep streams overrides in place
|
||||||
|
* that are NOT namespaced cause
|
||||||
|
* we're overriding Laravel's
|
||||||
|
* base language files too.
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param string $locale
|
||||||
|
* @param string $group
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function loadPath($path, $locale, $group)
|
||||||
|
{
|
||||||
|
$lines = parent::loadPath($path, $locale, $group);
|
||||||
|
|
||||||
|
if ($path == $this->streams && $lines) {
|
||||||
|
$lines = $this->loadAddonOverrides($lines, $locale, $group);
|
||||||
|
$lines = $this->loadSystemOverrides($lines, $locale, $group);
|
||||||
|
$lines = $this->loadApplicationOverrides($lines, $locale, $group);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load namespaced overrides from
|
||||||
|
* system AND application paths.
|
||||||
|
*
|
||||||
|
* @param array $lines
|
||||||
|
* @param string $locale
|
||||||
|
* @param string $group
|
||||||
|
* @param string $namespace
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @deprecated since 1.6; Use manual loading or publishing.
|
||||||
|
*/
|
||||||
|
if (env('AUTOMATIC_ADDON_OVERRIDES', true)) {
|
||||||
|
$lines = $this->loadAddonOverrides($lines, $locale, $group, $namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
$lines = $this->loadSystemOverrides($lines, $locale, $group, $namespace);
|
||||||
|
$lines = $this->loadApplicationOverrides($lines, $locale, $group, $namespace);
|
||||||
|
|
||||||
|
return parent::loadNamespaceOverrides($lines, $locale, $group, $namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load system overrides.
|
||||||
|
*
|
||||||
|
* @param array $lines
|
||||||
|
* @param $locale
|
||||||
|
* @param $group
|
||||||
|
* @param $namespace
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function loadSystemOverrides(array $lines, $locale, $group, $namespace = null)
|
||||||
|
{
|
||||||
|
if (!$namespace || $namespace == 'streams') {
|
||||||
|
|
||||||
|
$file = base_path("resources/streams/lang/{$locale}/{$group}.php");
|
||||||
|
|
||||||
|
if (is_dir(base_path("resources/streams/lang")) && $this->files->exists($file)) {
|
||||||
|
$lines = array_replace_recursive($lines, $this->files->getRequire($file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str_is('*.*.*', $namespace)) {
|
||||||
|
|
||||||
|
list($vendor, $type, $slug) = explode('.', $namespace);
|
||||||
|
|
||||||
|
$file = base_path("resources/addons/{$vendor}/{$slug}-{$type}/lang/{$locale}/{$group}.php");
|
||||||
|
|
||||||
|
if (is_dir(base_path("resources/addons/{$vendor}/{$slug}-{$type}/lang")) && $this->files->exists($file)) {
|
||||||
|
$lines = array_replace_recursive($lines, $this->files->getRequire($file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load system overrides.
|
||||||
|
*
|
||||||
|
* @param array $lines
|
||||||
|
* @param $locale
|
||||||
|
* @param $group
|
||||||
|
* @param $namespace
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function loadApplicationOverrides(array $lines, $locale, $group, $namespace = null)
|
||||||
|
{
|
||||||
|
if (!$namespace || $namespace == 'streams') {
|
||||||
|
|
||||||
|
$file = $this->application->getResourcesPath("streams/lang/{$locale}/{$group}.php");
|
||||||
|
|
||||||
|
if (is_dir($this->application->getResourcesPath("streams/lang")) && $this->files->exists($file)) {
|
||||||
|
$lines = array_replace_recursive($lines, $this->files->getRequire($file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str_is('*.*.*', $namespace)) {
|
||||||
|
|
||||||
|
list($vendor, $type, $slug) = explode('.', $namespace);
|
||||||
|
|
||||||
|
$file = $this->application->getResourcesPath(
|
||||||
|
"addons/{$vendor}/{$slug}-{$type}/lang/{$locale}/{$group}.php"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
is_dir($this->application->getResourcesPath("addons/{$vendor}/{$slug}-{$type}/lang"))
|
||||||
|
&& $this->files->exists($file)
|
||||||
|
) {
|
||||||
|
$lines = array_replace_recursive($lines, $this->files->getRequire($file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (config()->has('override_text')) {
|
||||||
|
foreach (config()->get('override_text') as $override) {
|
||||||
|
$override = explode(':', $override);
|
||||||
|
|
||||||
|
$lines = $this->findArrayValue($override[0], $override[1], $lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceNewValue($find_value, $new_value, $arr)
|
||||||
|
{
|
||||||
|
if (is_array($arr)) {
|
||||||
|
foreach ($arr as $key => $item) {
|
||||||
|
$arr[$key] = $this->replaceNewValue($find_value, $new_value, $item);
|
||||||
|
}
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
if (strtolower($arr) == strtolower($find_value)) {
|
||||||
|
return $new_value;
|
||||||
|
}
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findArrayValue($find_value, $new_value, $arr)
|
||||||
|
{
|
||||||
|
foreach ($arr as $key => $item) {
|
||||||
|
$arr[$key] = $this->replaceNewValue($find_value, $new_value, $item);
|
||||||
|
}
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $lines
|
||||||
|
* @param $locale
|
||||||
|
* @param $group
|
||||||
|
* @param null $namespace
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function loadAddonOverrides(array $lines, $locale, $group, $namespace = null)
|
||||||
|
{
|
||||||
|
/** @var Addon $addon */
|
||||||
|
foreach ($this->addons->enabled() as $addon) {
|
||||||
|
|
||||||
|
$disabled = array_get(self::$disabled, $key = $addon->getNamespace('streams'), false);
|
||||||
|
|
||||||
|
if (!$disabled && !$this->files->isDirectory($addon->getPath('resources/streams'))) {
|
||||||
|
self::$disabled[$key] = $disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$disabled && (!$namespace || $namespace == 'streams')) {
|
||||||
|
|
||||||
|
$file = $addon->getPath("resources/streams/lang/{$locale}/{$group}.php");
|
||||||
|
|
||||||
|
if ($this->files->exists($file)) {
|
||||||
|
$lines = array_replace_recursive($lines, $this->files->getRequire($file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$disabled = array_get(self::$disabled, $key = $addon->getNamespace('addons'), false);
|
||||||
|
|
||||||
|
if (!$disabled && !$this->files->isDirectory($addon->getPath('resources/addons'))) {
|
||||||
|
self::$disabled[$key] = $disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$disabled && str_is('*.*.*', $namespace)) {
|
||||||
|
|
||||||
|
list($vendor, $type, $slug) = explode('.', $namespace);
|
||||||
|
|
||||||
|
$file = $addon->getPath(
|
||||||
|
"resources/addons/{$vendor}/{$slug}-{$type}/lang/{$locale}/{$group}.php"
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($this->files->exists($file)) {
|
||||||
|
$lines = array_replace_recursive($lines, $this->files->getRequire($file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
|
}
|
||||||
45
app/Listeners/Translations.php
Executable file
45
app/Listeners/Translations.php
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Event\Booted;
|
||||||
|
use App\Lang\Loader;
|
||||||
|
use Illuminate\Translation\Translator;
|
||||||
|
|
||||||
|
class Translations
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle(Booted $event)
|
||||||
|
{
|
||||||
|
app()->singleton(
|
||||||
|
'translation.loader',
|
||||||
|
function ($application) {
|
||||||
|
return new Loader($application['files'], $application['path.lang']);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
app()->singleton(
|
||||||
|
'translator',
|
||||||
|
function ($application) {
|
||||||
|
$loader = $application->make('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 = $application['config']['app.locale'];
|
||||||
|
|
||||||
|
$trans = new Translator($loader, $locale);
|
||||||
|
|
||||||
|
$trans->setFallback($application['config']['app.fallback_locale']);
|
||||||
|
|
||||||
|
return $trans;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (defined('LOCALE')) {
|
||||||
|
app()->setLocale(LOCALE);
|
||||||
|
config()->set('app.locale', LOCALE);
|
||||||
|
}
|
||||||
|
// Set our locale namespace.
|
||||||
|
app()->make('translator')->addNamespace('streams', realpath(__DIR__ . '/../../vendor/visiosoft/streams-platform/resources/lang'));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -13,7 +13,11 @@ return [
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'listeners' => [],
|
'listeners' => [
|
||||||
|
\Anomaly\Streams\Platform\Event\Booted::class => [
|
||||||
|
\App\Listeners\Translations::class
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user