private function createMyTranslations()
 {
     $form = $this->Form();
     $translations = array('en_GB' => array('paypalUsername' => 'API username', 'paypalPassword' => 'API password', 'paypalSignature' => 'API signature', 'paypalVersion' => 'API version', 'paypalSandbox' => 'Activate sandbox mode', 'paypalBrandName' => 'Alternative shop name on PayPal\'s site', 'paypalLogoImage' => 'Shop image for PayPal', 'paypalCartBorderColor' => 'Color of the basket on PayPal', 'paypalFrontendLogo' => 'Show payment logo on frontend', 'paypalBillingAgreement' => 'Billing agreement / Activate "Buy it now"', 'paypalTransferCart' => 'Transfer basket to PayPal', 'paypalExpressButton' => 'Show express-purchase button in basket', 'paypalExpressButtonLayer' => 'Show express-purchase button in modal box', 'paypalStatusId' => 'Payment state after completing the payment', 'paypalPendingStatusId' => 'Payment state after being authorized', 'paypalSendInvoiceId' => 'Transfer invoice id to paypal', 'paypalPrefixInvoiceId' => 'Add shop prefix to the invoice id'));
     $shopRepository = Shopware()->Models()->getRepository('\\Shopware\\Models\\Shop\\Locale');
     foreach ($translations as $locale => $snippets) {
         $localeModel = $shopRepository->findOneBy(array('locale' => $locale));
         foreach ($snippets as $element => $snippet) {
             if ($localeModel === null) {
                 continue;
             }
             $elementModel = $form->getElement($element);
             if ($elementModel === null) {
                 continue;
             }
             $translationModel = new \Shopware\Models\Config\ElementTranslation();
             $translationModel->setLabel($snippet);
             $translationModel->setLocale($localeModel);
             $elementModel->addTranslation($translationModel);
         }
     }
 }
 private function translateForm()
 {
     $translations = array('en_GB' => array('default' => array('label' => 'Fallback shop', 'description' => 'Forward to this shop if not found any shop languages matching browser language'), 'assignedShops' => array('label' => 'Related shops', 'description' => 'Forwards to these shops, if the browser language equals the shop language.'), 'fallbackLanguage' => array('label' => 'Fallback language for the modal', 'description' => 'This is the locale for the translation that will be used by default, if no matching translation was found for the user to be displayed in the infobox in the frontend.')));
     // In 4.2.2 we introduced a helper function for this, so we can skip the custom logic
     if ($this->assertMinimumVersion('4.2.2')) {
         $this->addFormTranslations($translations);
         return true;
     }
     // Translations
     $form = $this->Form();
     $shopRepository = Shopware()->Models()->getRepository('\\Shopware\\Models\\Shop\\Locale');
     //iterate the languages
     foreach ($translations as $locale => $snippets) {
         $localeModel = $shopRepository->findOneBy(array('locale' => $locale));
         //not found? continue with next language
         if ($localeModel === null) {
             continue;
         }
         if ($snippets['plugin_form']) {
             // Translation for form description
             foreach ($form->getTranslations() as $translation) {
                 if ($translation->getLocale()->getLocale() == $locale) {
                     $formTranslation = $translation;
                 }
             }
             // If none found create a new one
             if (!$formTranslation) {
                 $formTranslation = new \Shopware\Models\Config\FormTranslation();
                 $formTranslation->setLocale($localeModel);
                 //add the translation to the form
                 $form->addTranslation($formTranslation);
             }
             if ($snippets['plugin_form']['label']) {
                 $formTranslation->setLabel($snippets['plugin_form']['label']);
             }
             if ($snippets['plugin_form']['description']) {
                 $formTranslation->setDescription($snippets['plugin_form']['description']);
             }
             unset($snippets['plugin_form']);
         }
         //iterate all snippets of the current language
         foreach ($snippets as $element => $snippet) {
             $translationModel = null;
             //get the form element by name
             $elementModel = $form->getElement($element);
             //not found? continue with next snippet
             if ($elementModel === null) {
                 continue;
             }
             // Try to load existing translation
             foreach ($elementModel->getTranslations() as $translation) {
                 if ($translation->getLocale()->getLocale() == $locale) {
                     $translationModel = $translation;
                     break;
                 }
             }
             // If none found create a new one
             if (!$translationModel) {
                 $translationModel = new \Shopware\Models\Config\ElementTranslation();
                 $translationModel->setLocale($localeModel);
                 //add the translation to the form element
                 $elementModel->addTranslation($translationModel);
             }
             if ($snippet['label']) {
                 $translationModel->setLabel($snippet['label']);
             }
             if ($snippet['description']) {
                 $translationModel->setDescription($snippet['description']);
             }
         }
     }
 }
 /**
  * Creates Translation
  */
 public function createTranslations()
 {
     $form = $this->Form();
     $translations = array('en_GB' => array('categoryids' => 'Enabled in these categories (comma separated)'));
     $shopRepository = Shopware()->Models()->getRepository('\\Shopware\\Models\\Shop\\Locale');
     foreach ($translations as $locale => $snippets) {
         $localeModel = $shopRepository->findOneBy(array('locale' => $locale));
         foreach ($snippets as $element => $snippet) {
             if ($localeModel === null) {
                 continue;
             }
             $elementModel = $form->getElement($element);
             if ($elementModel === null) {
                 continue;
             }
             $translationModel = new \Shopware\Models\Config\ElementTranslation();
             $translationModel->setLabel($snippet);
             $translationModel->setLocale($localeModel);
             $elementModel->addTranslation($translationModel);
         }
     }
 }
Exemple #4
0
 /**
  * Creates the Admin Translations for the plugin
  *
  * @throws Exception
  */
 private function _createConfigTranslations()
 {
     $mapping = array('option_lable_basic_settings' => array('label' => '4004'), 'option_general_reason_one' => array('label' => '1623', 'description' => '1624'), 'option_general_reason_two' => array('label' => '1625', 'description' => '1624'), 'option_general_create_transactions' => array('label' => '4001', 'description' => '4002'), 'option_general_logging' => array('label' => '1630', 'description' => '1631'), 'option_general_remove_failed_transactions' => array('label' => '1654', 'description' => '1655'), 'option_lable_settings_sofortbanking' => array('label' => '4005'), 'option_sofortbanking_frontend_display' => array('label' => '1613', 'description' => '1614', 'store' => array(array(1, '1615'), array(2, '1616'))), 'option_sofortbanking_key' => array('label' => '1606', 'description' => '1607'), 'option_sofortbanking_customer_protection' => array('label' => '1617', 'description' => '1618'), 'option_sofortbanking_recommended_payment' => array('label' => '1619', 'description' => '1620'), 'option_lable_settings_sofortbanking_states' => array('label' => '1632'), 'option_sofortbanking_state_temporary' => array('label' => '1633', 'description' => '1634', 'store' => array(array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_payment_confirmed' => array('label' => '1635', 'description' => '1636', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_payment_received' => array('label' => '1637', 'description' => '1638', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_payment_canceled' => array('label' => '1639', 'description' => '1640', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_investigation_needed' => array('label' => '1641', 'description' => '1642', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_refund_partial' => array('label' => '1643', 'description' => '1644', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_refund_full' => array('label' => '1645', 'description' => '1646', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_lable_settings_ideal' => array('label' => '4006'), 'option_ideal_frontend_display' => array('label' => '1613', 'description' => '1614', 'store' => array(array(1, '1615'), array(2, '1616'))), 'option_ideal_key' => array('label' => '1606', 'description' => '1607'), 'option_ideal_project_password' => array('label' => '2605', 'description' => '2605'), 'option_ideal_notification_password' => array('label' => '2607', 'description' => '2608'), 'option_ideal_recommended_payment' => array('label' => '1619', 'description' => '1620'), 'option_lable_settings_ideal_states' => array('label' => '2632'), 'option_ideal_state_temporary' => array('label' => '2633', 'description' => '2634', 'store' => array(array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_payment_pending' => array('label' => '2635', 'description' => '2636', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_payment_received' => array('label' => '2637', 'description' => '2638', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_payment_canceled' => array('label' => '2639', 'description' => '2640', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_storno' => array('label' => '2641', 'description' => '2642', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_refund_partial' => array('label' => '2643', 'description' => '2644', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_refund_full' => array('label' => '2645', 'description' => '2646', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))));
     //Build Translation array
     $translations = array();
     $translator = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Translator();
     //Build German Translations
     $translations['de_DE'] = array();
     $translator->setLanguage('de_DE');
     foreach ($mapping as $option => $values) {
         $translations['de_DE'][$option] = array();
         if (isset($values['label'])) {
             $translations['de_DE'][$option]['label'] = $translator->getSnippetByNumber($values['label']);
         }
         if (isset($values['text'])) {
             $translations['de_DE'][$option]['text'] = $translator->getSnippetByNumber($values['text']);
         }
         if (isset($values['description'])) {
             $translations['de_DE'][$option]['description'] = $translator->getSnippetByNumber($values['description']);
         }
         if (isset($values['store'])) {
             foreach ($values['store'] as $entries) {
                 if ($entries[1] !== "1653") {
                     $translations['de_DE'][$option]['store'][$entries[0]] = $entries[1];
                 } else {
                     $translations['de_DE'][$option]['store'][$entries[0]] = $translator->getSnippetByNumber($entries[1]);
                 }
             }
         }
     }
     //Build English Translations
     $translations['en_GB'] = array();
     $translator->setLanguage('en_GB');
     foreach ($mapping as $option => $values) {
         $translations['en_GB'][$option] = array();
         if (isset($values['label'])) {
             $translations['en_GB'][$option]['label'] = $translator->getSnippetByNumber($values['label']);
         }
         if (isset($values['text'])) {
             $translations['en_GB'][$option]['text'] = $translator->getSnippetByNumber($values['text']);
         }
         if (isset($values['description'])) {
             $translations['en_GB'][$option]['description'] = $translator->getSnippetByNumber($values['description']);
         }
         if (isset($values['store'])) {
             foreach ($values['store'] as $entries) {
                 if ($entries[1] !== "1653") {
                     $translations['en_GB'][$option]['store'][$entries[0]] = $entries[1];
                 } else {
                     $translations['en_GB'][$option]['store'][$entries[0]] = $translator->getSnippetByNumber($entries[1]);
                 }
             }
         }
     }
     $form = $this->_bootstrap->Form();
     $shopRepository = Shopware()->Models()->getRepository('\\Shopware\\Models\\Shop\\Locale');
     foreach ($translations as $locale => $snippets) {
         $localeModel = $shopRepository->findOneBy(array('locale' => $locale));
         foreach ($snippets as $element => $snippet) {
             if ($localeModel === null) {
                 continue;
             }
             $elementModel = $form->getElement($element);
             if ($elementModel === null) {
                 continue;
             }
             $translationModel = new \Shopware\Models\Config\ElementTranslation();
             if (isset($snippet['label'])) {
                 $translationModel->setLabel($snippet['label']);
             }
             if (isset($snippet['description'])) {
                 $translationModel->setDescription($snippet['description']);
             }
             /** @var $localeModel \Shopware\Models\Shop\Locale */
             $translationModel->setLocale($localeModel);
             $elementModel->addTranslation($translationModel);
         }
     }
 }
 /**
  * Creates the Translation for the Pluginconfiguration
  */
 private function _createPluginConfigTranslation()
 {
     try {
         $form = $this->Form();
         $translations = array('de_DE' => array('RatePayProfileIDDE' => 'Deutschland Profile-ID', 'RatePaySecurityCodeDE' => 'Deutschland Security Code', 'RatePayProfileIDAT' => 'Österreich Profile-ID', 'RatePaySecurityCodeAT' => 'Österreich Security Code', 'RatePaySandboxDE' => 'Testmodus aktivieren ( Test Gateway )', 'button0' => 'Zugangsdaten für Deutschland', 'button1' => 'Zugangsdaten für Österreich'), 'en_EN' => array('RatePayProfileIDDE' => 'Profile-ID for Germany', 'RatePaySecurityCodeDE' => 'Security Code for Germany', 'RatePayProfileIDAT' => 'Profile-ID for Austria', 'RatePaySecurityCodeAT' => 'Security Code for Austria', 'RatePaySandboxDE' => 'Sandbox ( Test Gateway )', 'button0' => 'Credentials for Germany', 'button1' => 'Credentials for Austria'));
         $shopRepository = Shopware()->Models()->getRepository('\\Shopware\\Models\\Shop\\Locale');
         foreach ($translations as $locale => $snippets) {
             $localeModel = $shopRepository->findOneBy(array('locale' => $locale));
             foreach ($snippets as $element => $snippet) {
                 if ($localeModel === null) {
                     continue;
                 }
                 $elementModel = $form->getElement($element);
                 if ($elementModel === null) {
                     continue;
                 }
                 $translationModel = new \Shopware\Models\Config\ElementTranslation();
                 $translationModel->setLabel($snippet);
                 $translationModel->setLocale($localeModel);
                 $elementModel->addTranslation($translationModel);
             }
         }
     } catch (Exception $exception) {
         $this->uninstall();
         throw new Exception("Can not create translation." . $exception->getMessage());
     }
 }
 /**
  * Sets translations for plugin text phrases.
  */
 protected function createTranslations()
 {
     $form = $this->Form();
     $translations = array('de_DE' => array('barzahlenSandbox' => 'Testmodus', 'barzahlenShopId' => 'Shop ID', 'barzahlenPaymentKey' => 'Zahlungsschlüssel', 'barzahlenNotificationKey' => 'Benachrichtigungsschlüssel', 'barzahlenDebug' => 'Erweitertes Logging'), 'en_GB' => array('barzahlenSandbox' => 'Sandbox', 'barzahlenShopId' => 'Shop ID', 'barzahlenPaymentKey' => 'Payment Key', 'barzahlenNotificationKey' => 'Notification Key', 'barzahlenDebug' => 'Extended Logging'));
     $shopRepository = Shopware()->Models()->getRepository('\\Shopware\\Models\\Shop\\Locale');
     foreach ($translations as $locale => $snippets) {
         $localeModel = $shopRepository->findOneBy(array('locale' => $locale));
         foreach ($snippets as $element => $snippet) {
             if ($localeModel === null) {
                 continue;
             }
             $elementModel = $form->getElement($element);
             if ($elementModel === null) {
                 continue;
             }
             $translationModel = new \Shopware\Models\Config\ElementTranslation();
             $translationModel->setLabel($snippet);
             $translationModel->setLocale($localeModel);
             $elementModel->addTranslation($translationModel);
         }
     }
 }
Exemple #7
0
 public function createMyTranslations()
 {
     $form = $this->Form();
     $translations = array(
         'en_GB' => array(
             'paypalUsername' => 'API username',
             'paypalPassword' => 'API password',
             'paypalSignature' => 'API signature',
             'paypalVersion' => 'API version',
             'paypalSandbox' => 'Activate sandbox mode',
             'paypalBrandName' => 'Alternative shop name on PayPal\'s site',
             'paypalLogoImage' => 'Shop image for PayPal',
             'paypalCartBorderColor' => 'Color of the basket on PayPal',
             'paypalFrontendLogo' => 'Show payment logo on frontend',
             'paypalFrontendLogoBlock' => 'Template block for the frontend logo',
             'paypalPaymentActionPending' => 'Only authorize payments (Auth-Capture)',
             'paypalBillingAgreement' => 'Billing agreement / Activate "Buy it now"',
             'paypalTransferCart' => 'Transfer basket to PayPal',
             'paypalAllowGuestCheckout' => 'Allow PayPal guest account',
             'paypalExpressButton' => 'Show express-purchase button in basket',
             'paypalExpressButtonLayer' => 'Show express-purchase button in modal box',
             'paypalAddressOverride' => 'Allow changing shipping address on paypal',
             'paypalStatusId' => 'Payment state after completing the payment',
             'paypalPendingStatusId' => 'Payment state after being authorized',
             'paypalStatusMail' => 'Send mail on payment state change'
         )
     );
     $shopRepository = Shopware()->Models()->getRepository('\Shopware\Models\Shop\Locale');
     foreach($translations as $locale => $snippets) {
         $localeModel = $shopRepository->findOneBy(array(
             'locale' => $locale
         ));
         foreach($snippets as $element => $snippet) {
             if($localeModel === null){
                 continue;
             }
             $elementModel = $form->getElement($element);
             if($elementModel === null) {
                 continue;
             }
             $translationModel = new \Shopware\Models\Config\ElementTranslation();
             $translationModel->setLabel($snippet);
             $translationModel->setLocale($localeModel);
             $elementModel->addTranslation($translationModel);
         }
     }
 }
 /**
  * translates the plugin configuration form with the given translations
  *
  * @param $translations
  */
 private function translateForm($translations)
 {
     // Translations
     $shopRepository = Shopware()->Models()->getRepository('\\Shopware\\Models\\Shop\\Locale');
     //iterate the languages
     foreach ($translations as $locale => $snippets) {
         $localeModel = $shopRepository->findOneBy(array('locale' => $locale));
         //not found? continue with next language
         if ($localeModel === null) {
             continue;
         }
         if ($snippets['plugin_form']) {
             // Translation for form description
             $formTranslation = null;
             /* @var \Shopware\Models\Config\FormTranslation $translation */
             foreach ($this->form->getTranslations() as $translation) {
                 if ($translation->getLocale()->getLocale() == $locale) {
                     $formTranslation = $translation;
                 }
             }
             // If none found create a new one
             if (!$formTranslation) {
                 $formTranslation = new \Shopware\Models\Config\FormTranslation();
                 $formTranslation->setLocale($localeModel);
                 //add the translation to the form
                 $this->form->addTranslation($formTranslation);
             }
             if ($snippets['plugin_form']['label']) {
                 $formTranslation->setLabel($snippets['plugin_form']['label']);
             }
             if ($snippets['plugin_form']['description']) {
                 $formTranslation->setDescription($snippets['plugin_form']['description']);
             }
             unset($snippets['plugin_form']);
         }
         //iterate all snippets of the current language
         foreach ($snippets as $element => $snippet) {
             $translationModel = null;
             //get the form element by name
             $elementModel = $this->form->getElement($element);
             //not found? continue with next snippet
             if ($elementModel === null) {
                 continue;
             }
             // Try to load existing translation
             foreach ($elementModel->getTranslations() as $translation) {
                 if ($translation->getLocale()->getLocale() == $locale) {
                     $translationModel = $translation;
                     break;
                 }
             }
             // If none found create a new one
             if (!$translationModel) {
                 $translationModel = new \Shopware\Models\Config\ElementTranslation();
                 $translationModel->setLocale($localeModel);
                 //add the translation to the form element
                 $elementModel->addTranslation($translationModel);
             }
             if ($snippet['label']) {
                 $translationModel->setLabel($snippet['label']);
             }
             if ($snippet['description']) {
                 $translationModel->setDescription($snippet['description']);
             }
         }
     }
 }