]> _ Git - cubist_cms-back.git/commitdiff
wip #3753 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 9 Dec 2020 12:11:14 +0000 (13:11 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 9 Dec 2020 12:11:14 +0000 (13:11 +0100)
src/app/Magic/Controllers/CubistMagicController.php
src/app/Magic/Models/CubistMagicAbstractModel.php
src/resources/cubistmagic/Controller.stub

index 6684bf3581d4f720d76a3763bec5142255f225eb..9b8b98858b49cd0be5eb796cd8be30b85a43f93d 100644 (file)
@@ -78,7 +78,7 @@ class CubistMagicController extends CubistCrudController
 
 
         $this->crud->setRoute(backpack_url($this->_routeURL));
-        $this->crud->setEntityNameStrings($this->_singular, $this->_plural);
+        $this->crud->setEntityNameStrings(__($this->_singular), __($this->_plural));
 
 
         /*
index d616a7bb1b036a6a8983cc2b0d67a14ea964f245..ce564a2b081521b7935a51682c0de1952cf85f95 100644 (file)
@@ -372,15 +372,29 @@ class CubistMagicAbstractModel extends Model implements HasMedia
 
     protected function _replaceInCode($stub, $dest)
     {
+        $singular = $this->getOption('singular', $this->getOption('name'));
+        $plural = $this->getOption('plural', '');
+
+        $totranslate = [$singular, $plural];
+        $translate = '/*' . "\n";
+        foreach ($totranslate as $str) {
+            if (!$str) {
+                continue;
+            }
+            $translate .= "\t__('" . addcslashes($str, "'") . "')\n";
+        }
+        $translate .= "\t*/";
+
         $vars = ['CONTROLLERCLASS' => $this->getControllerClass(),
             'ROUTEURL' => $this->getOption('route', $this->getOption('name')),
-            'SINGULAR' => $this->getOption('singular', $this->getOption('name')),
-            'PLURAL' => $this->getOption('plural', ''),
+            'SINGULAR' => $singular,
+            'PLURAL' => $plural,
             'MODELNAMESPACE' => get_class($this),
             'EXTENDS' => '\\' . $this->_getBaseController(),
             'BULK' => $this->getOption('bulk', true) ? 'true' : 'false',
             'ONEINSTANCE' => $this->getOption('oneinstance', false) ? 'true' : 'false',
-            'USE' => $this->_getUse()];
+            'USE' => $this->_getUse(),
+            'TRANSLATE' => $translate];
 
         $res = file_get_contents($stub);
         foreach ($vars as $name => $value) {
index c28bb3bf37b099fc1448abf1bd74bf27fc95996d..45f57a7ff6d3914276a673e889a411cc164c279e 100644 (file)
@@ -6,6 +6,8 @@ class _CONTROLLERCLASS_ extends _EXTENDS_
 {
     _USE_
 
+    _TRANSLATE_
+
     protected $_modelNamespace = '_MODELNAMESPACE_';
     protected $_routeURL = '_ROUTEURL_';
     protected $_singular = '_SINGULAR_';