Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

german translation for widget #1

Merged
merged 1 commit into from

2 participants

@ivoba

and general possibility to translate the widget

@fonsekaean fonsekaean merged commit 971ce7c into fonsekaean:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 9, 2012
  1. @ivoba
This page is out of date. Refresh to see the latest.
Showing with 97 additions and 69 deletions.
  1. +75 −69 code/SubscribeWidget.php
  2. +22 −0 lang/de_DE.php
View
144 code/SubscribeWidget.php
@@ -1,80 +1,86 @@
<?php
-class SubscribeWidget extends Widget{
+class SubscribeWidget extends Widget {
- static $title = "Newsletter Signup";
- static $cmsTitle = "Newsletter Signup";
- static $description = "Let your users to subscribe to the mailchimp newletter.";
-
- public static $db = array(
- 'ListID' => 'Varchar(20)'
- );
-
- public function getCMSFields(){
- $config = DataObject::get_one("SiteConfig");
- $api = new MCAPI($config->MailchimpAPI);
- $lists = $api->lists();
- $listsForDropDown = array(
- "0" => "Select a list"
- );
- if($lists){
- foreach($lists as $list){
- $listsForDropDown[$list['id']] = $list['name'];
- }
- }
- return new FieldSet(new DropdownField('ListID', 'List', $listsForDropDown));
- }
+ public function Title() {
+ return _t('SubscribeWidget.TITLE', 'Newsletter Signup');
+ }
- /*function SubscribeForm(){
+ public function CMSTitle() {
+ return _t('SubscribeWidget.CMSTITLE', 'Newsletter Signup');
+ }
- }*/
-
+ public function Description() {
+ return _t('SubscribeWidget.DESCRIPTION', 'Let your users to subscribe to the mailchimp newletter.');
+ }
+
+ public static $db = array(
+ 'ListID' => 'Varchar(20)'
+ );
+
+ public function getCMSFields() {
+ $config = DataObject::get_one("SiteConfig");
+ $api = new MCAPI($config->MailchimpAPI);
+ $lists = $api->lists();
+ $listsForDropDown = array(
+ "0" => _t('SubscribeWidget.LISTLABEL', 'Select a list')
+ );
+ if ($lists) {
+ foreach ($lists as $list) {
+ $listsForDropDown[$list['id']] = $list['name'];
+ }
+ }
+ return new FieldSet(new DropdownField('ListID', _t('SubscribeWidget.LISTLABEL', 'Select a list'), $listsForDropDown));
+ }
+
+ /* function SubscribeForm(){
+
+ } */
}
class SubscribeWidget_Controller extends Widget_Controller {
+ function SubscribeForm() {
+ $config = DataObject::get_one("SiteConfig");
+ if ($this->ListID) {
+ $listField = new HiddenField('List', 'List', $this->ListID);
+ } else {
+ $api = new MCAPI($config->MailchimpAPI);
+ $lists = $api->lists();
+ $listsForDropDown = array(
+ "0" => _t('SubscribeWidget.LISTLABEL', 'Select a list')
+ );
+ if ($lists) {
+ foreach ($lists as $list) {
+ $listsForDropDown[$list['id']] = $list['name'];
+ }
+ }
+ $listField = new DropdownField('List', 'List', $listsForDropDown);
+ }
+
+ return new Form(
+ $this,
+ 'SubscribeForm',
+ new FieldSet(
+ new TextField('Name', _t('SubscribeWidget.NAMELABEL', 'Name')),
+ new EmailField('Email', _t('SubscribeWidget.EMAILLABEL', 'Email')),
+ $listField
+ ),
+ new FieldSet(
+ new FormAction('doAction', _t('SubscribeWidget.BUTTONVALUE', 'Subscribe'))
+ ),
+ new RequiredFields(
+ 'Name', 'Email', 'List'
+ )
+ );
+ }
+
+ function doAction($data, $form) {
+ $config = DataObject::get_one("SiteConfig");
+ $api = new MCAPI($config->MailchimpAPI);
+ $merge_vars = array('FNAME' => $data['Name'], 'LNAME' => '', 'INTERESTS' => '');
+ $retval = $api->listSubscribe($data['List'], $data["Email"], $merge_vars);
+ Director::redirectBack();
+ }
- function SubscribeForm() {
- $config = DataObject::get_one("SiteConfig");
- if($this->ListID){
- $listField = new HiddenField('List', 'List', $this->ListID);
- }
- else{
- $api = new MCAPI($config->MailchimpAPI);
- $lists = $api->lists();
- $listsForDropDown = array(
- "0" => "Select a list"
- );
- if($lists){
- foreach($lists as $list){
- $listsForDropDown[$list['id']] = $list['name'];
- }
- }
- $listField = new DropdownField('List', 'List', $listsForDropDown);
- }
-
- return new Form(
- $this,
- 'SubscribeForm',
- new FieldSet(
- new TextField('Name'),
- new EmailField('Email'),
- $listField
- ),
- new FieldSet(
- new FormAction('doAction', 'Subscribe')
- ),
- new RequiredFields(
- 'Name', 'Email', 'List'
- )
- );
- }
-
- function doAction($data, $form) {
- $config = DataObject::get_one("SiteConfig");
- $api = new MCAPI($config->MailchimpAPI);
- $merge_vars = array('FNAME'=>$data['Name'], 'LNAME'=>'','INTERESTS'=>'');
- $retval = $api->listSubscribe( $data['List'], $data["Email"], $merge_vars );
- Director::redirectBack();
- }
}
View
22 lang/de_DE.php
@@ -0,0 +1,22 @@
+<?php
+// -------------------------------------------------------------------
+// German translation for the Mailchimp module
+// -------------------------------------------------------------------
+
+i18n::include_locale_file('mailchimp', 'en_US');
+
+global $lang;
+
+if(array_key_exists('de_DE', $lang) && is_array($lang['de_DE'])) {
+ $lang['de_DE'] = array_merge($lang['en_US'], $lang['de_DE']);
+} else {
+ $lang['de_DE'] = $lang['en_US'];
+}
+
+$lang['de_DE']['SubscribeWidget']['TITLE'] = 'Newsletter Anmelden';
+$lang['de_DE']['SubscribeWidget']['CMSTITLE'] = 'Newsletter Anmelden';
+$lang['de_DE']['SubscribeWidget']['DESCRIPTION'] = 'Besucher können sich für den Mailchimp Newsletter anmelden.';
+$lang['de_DE']['SubscribeWidget']['LISTLABEL'] = 'Liste auswählen';
+$lang['de_DE']['SubscribeWidget']['NAMELABEL'] = 'Name';
+$lang['de_DE']['SubscribeWidget']['EMAILLABEL'] = 'E-Mail';
+$lang['de_DE']['SubscribeWidget']['BUTTONVALUE'] = 'Absenden';
Something went wrong with that request. Please try again.