Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
MINOR: merged ticket #2075. ENHANCHMENT: added il8n support to google…
Browse files Browse the repository at this point in the history
…adwords. MINOR: fixed typo to get it to load in 2.3. Needs alot more testing though. Not stable on 2.3
  • Loading branch information
Will Rossiter committed May 25, 2009
1 parent 1f84b3b commit 2a0201d
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 47 deletions.
10 changes: 5 additions & 5 deletions code/Adwords.php
Expand Up @@ -4,7 +4,7 @@
* This code controls communication between actions & the back end
* And provides the main forms.
*/
class Adwords_Controller extends controller {
class Adwords_Controller extends Controller {
/**
* Provide URL Links, Required internally as a viewable item
*/
Expand Down Expand Up @@ -164,8 +164,8 @@ public function State() {
* mode to be changed.
*/
public function ModeForm() {
$viewing = (isset($_REQUEST['all']))?"Viewing All Ads":"Viewing Ads For This Page";
$button = (isset($_REQUEST['all']))?"View Ads for this page":"View all ads";
$viewing = (isset($_REQUEST['all']))?_t('Adwords.ALLADS','Viewing All Ads'):_t('Adwords.ADSFORTHISPAGE','Viewing Ads For This Page');
$button = (isset($_REQUEST['all']))?_t('Adwords.VIEWADSFORTHISPAGE','View Ads for this page'):_t('Adwords.VIEWALLADS','View all ads');
$state = (!isset($_REQUEST['all']))?"all":"";
return new Form($this,"ModeForm",
new FieldSet(
Expand All @@ -184,7 +184,7 @@ public function NavigationForm() {

$ads = $this->Ads();
if(!count($ads)) {
return new Form($this,"NavigationForm",new FieldSet(new LiteralField("NoAds","There are no ads in this view.")),new FieldSet());
return new Form($this,"NavigationForm",new FieldSet(new LiteralField("NoAds",_t('Adwords.NOADSINVIEW','There are no ads in this view.'))),new FieldSet());
}

foreach($ads as $ad) {
Expand Down Expand Up @@ -402,7 +402,7 @@ function ProcessLogin($data, $form) {
}

function LogoutForm() {
return new Form($this,"LogoutForm",new FieldSet(new FormAction_withoutLabel("logout","Sign out")),new FieldSet());
return new Form($this,"LogoutForm",new FieldSet(new FormAction_withoutLabel("logout",_t('Adwords.LOGOUT','Sign out'))),new FieldSet());
}
function logout() {
//Remove entries from the accounts table, then re-direct back to index().
Expand Down
6 changes: 4 additions & 2 deletions code/CreationInterface.php
Expand Up @@ -7,12 +7,14 @@
*/
class CreationInterface {
public static function Process($data,$caller) {
$t1 = _t('CreationInterface.LOADING','Loading...');
$topstuff = <<<EOF
</head>
<div style='z-index:500; position:fixed; top:0; bottom:0; left:0; right:0; background:white; padding-top:50%; padding-right:50%;' id='loading'>
Loading...
{$t1}
</div>
EOF;
$t2 = _t('CreationInterface.RETURNTOMAIN','Return To Main View');
$extrastuff = <<<EOF
<script type='text/javascript'>
document.getElementById("navigation").style.display="none";
Expand All @@ -25,7 +27,7 @@ public static function Process($data,$caller) {
document.getElementById("loading").style.display="none";
// Provide a Consistant interface throughout
var snippit = '<div style="float:right;" class="useropts"><strong>{$caller->Account()->Email}</strong> | {$caller->LogoutForm()->forTemplate()}</div>';
var snippit2 = '<a style="color:black; padding:2px;" href="{$caller->Link()}">Return To Main View</a>';
var snippit2 = '<a style="color:black; padding:2px;" href="{$caller->Link()}">{$t2}</a>';
document.body.innerHTML = snippit + document.body.innerHTML + snippit2;
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions code/fields/AdField.php
Expand Up @@ -56,7 +56,7 @@ function changeStatus()
$this->state,
new HiddenField("CampaignID","",$this->ad->GoogleCampaign),
new HiddenField("AdID","",$this->ad->GoogleID),
new FormAction_WithoutLabel("PauseUnpause",(stristr($this->Status(),"Active")?"Pause":"Unpause"))
new FormAction_WithoutLabel("PauseUnpause",(stristr($this->Status(),"Active")?_t('AdField.PAUSE','Pause'):_t('AdField.UNPAUSE','Unpause')))
),
new FieldSet()
);
Expand All @@ -73,7 +73,7 @@ function BidField()
new HiddenField("CampaignID","",$this->ad->GoogleCampaign),
new HiddenField("AdID","",$this->ad->GoogleID),
new CurrencyField("BidText",null,$this->ad->Bid),
new FormAction_WithoutLabel("SaveChange","Save")
new FormAction_WithoutLabel("SaveChange",_t('AdField.SAVECHANGE','Save'))
),
new FieldSet()
);
Expand Down
70 changes: 36 additions & 34 deletions code/fields/LoginField.php
Expand Up @@ -8,7 +8,7 @@ class LoginField extends FormField {
protected $passwd;
protected $action;
protected $error;

protected $table;

public function __construct($name,$action,$error=null, $value=null,$form=null) {
if($value!=null)
Expand Down Expand Up @@ -41,46 +41,18 @@ public function __construct($name,$action,$error=null, $value=null,$form=null) {
});","LoginExtension");

parent::__construct($name,"",$value,$form);
}

public function Field() {
$field = new FieldGroup($this->name);

$field->push(new LiteralField($this->name.'[Styling1]',$this->table['Top']));
$field->push(new TextField($this->name.'[Username]',"",$this->username,18));
$field->push(new LiteralField($this->name.'[Styling2]',$this->table['M1']));
$field->push(new PasswordField($this->name.'[Passwd]',"",$this->passwd,18));
$field->push(new LiteralField($this->name.'[Styling3]',$this->table['M2']));
if(!is_null($this->error))
{
$field->push(new LiteralField($this->name.'[Error]',$this->error));
}
$field->push(new LiteralField($this->name.'[Styling4]',$this->table['M3']));
$field->push(new FormAction_WithoutLabel($this->action, "Sign in"));
$field->push(new LiteralField($this->name.'[Styling5]',$this->table['Bottom']));

return $field;
}

public function setValue($value)
{
if(is_array($value))
{
$this->value=serialize($value);
}
}

protected $table = array(
$table = array(
'Top'=>
"<table border=\"0\" cellpadding=\"5\" cellspacing=\"3\">
<tbody><tr>
<td style=\"text-align: center;\" bgcolor=\"#e8eefa\" nowrap=\"nowrap\" valign=\"top\">
<table align=\"center\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\">
<tbody><tr>
<td colspan=\"2\" align=\"center\">
<span style=\"\">Sign in with your</span>
<span style=\"\">". _t('LoginField.SIGNINWITH','Sign in with your') . "</span>
<table><tbody><tr><td valign=\"top\"><img src=\"googleadwords/images/google_transparent.gif\" alt=\"Google\"></td>
<td valign=\"middle\"><span style=\"font-size: medium; font-family: sans-serif;\"><b>Account</b></span>
<td valign=\"middle\"><span style=\"font-size: medium; font-family: sans-serif;\"><b>" . _t('LoginField.ACCOUNT','Account') . "</b></span>
</td></tr></tbody></table>
</td>
</tr>
Expand All @@ -91,7 +63,7 @@ public function setValue($value)
<tr>
<td nowrap=\"nowrap\">
<div align=\"right\">
Email:
" . _t('LoginField.EMAIL','Email:') . "
</div>
</td>
<td>", 'M1'=>'
Expand All @@ -103,7 +75,7 @@ public function setValue($value)
</tr>
<tr>
<td align="right">
Password:
' . _t('LoginField.PASSWORD','Password:') .'
</td><td>',

'M2'=>'</td></tr>
Expand All @@ -121,6 +93,36 @@ public function setValue($value)
</td>
</tr>
</tbody></table>');
}

public function Field() {
$field = new FieldGroup($this->name);

$field->push(new LiteralField($this->name.'[Styling1]',$this->table['Top']));
$field->push(new TextField($this->name.'[Username]',"",$this->username,18));
$field->push(new LiteralField($this->name.'[Styling2]',$this->table['M1']));
$field->push(new PasswordField($this->name.'[Passwd]',"",$this->passwd,18));
$field->push(new LiteralField($this->name.'[Styling3]',$this->table['M2']));
if(!is_null($this->error))
{
$field->push(new LiteralField($this->name.'[Error]',$this->error));
}
$field->push(new LiteralField($this->name.'[Styling4]',$this->table['M3']));
$field->push(new FormAction_WithoutLabel($this->action, _t('LoginField.SIGNIN','Sign in')));
$field->push(new LiteralField($this->name.'[Styling5]',$this->table['Bottom']));

return $field;
}

public function setValue($value)
{
if(is_array($value))
{
$this->value=serialize($value);
}
}



}

Expand Down
44 changes: 44 additions & 0 deletions lang/de_DE.php
@@ -0,0 +1,44 @@
<?php

global $lang;

$lang['de_DE']['Adwords']['ALLADS'] = 'Alle Anzeigen';
$lang['de_DE']['Adwords']['ADSFORTHISPAGE'] = 'Anzeigen für diese Seite';
$lang['de_DE']['Adwords']['VIEWADSFORTHISPAGE'] = 'Zeige Anzeigen für diese Seite';
$lang['de_DE']['Adwords']['VIEWALLADS'] = 'Zeige alle Anzeigen';
$lang['de_DE']['Adwords']['NOADSINVIEW'] = 'Es gibt keine Anzeigen in dieser Ansicht.';
$lang['de_DE']['Adwords']['LOGOUT'] = 'Abmelden';
$lang['de_DE']['CreationInterface']['LOADING'] = 'Lade...';
$lang['de_DE']['CreationInterface']['RETURNTOMAIN'] = 'Zur Hauptansicht zurückkehren';
$lang['de_DE']['AdField']['PAUSE'] = 'Pausieren';
$lang['de_DE']['AdField']['UNPAUSE'] = 'Fortsetzen';
$lang['de_DE']['AdField']['SAVECHANGE'] = 'Speichern';
$lang['de_DE']['LoginField']['SIGNINWITH'] = 'Melde dich mit deinem';
$lang['de_DE']['LoginField']['ACCOUNT'] = 'Konto an';
$lang['de_DE']['LoginField']['EMAIL'] = 'Email:';
$lang['de_DE']['LoginField']['PASSWORD'] = 'Passwort:';
$lang['de_DE']['LoginField']['SIGNIN'] = 'Einloggen';
$lang['de_DE']['Captcha_Error.ss']['FAILEDLOGINATTEMPTS'] = 'Aufgrund der Zahl an fehlgeschlagenen Login-Versuchen, verlangt Google, dass du dich bei ihnen einloggst, bevor du dieses Hilfsmittel benutzen kannst.';
$lang['de_DE']['Captcha_Error.ss']['VISITGOOGLE'] = 'Besuche bitte <a href="https://www.google.com/accounts/DisplayUnlockCaptcha" target="_blank">https://www.google.com/accounts/DisplayUnlockCaptcha</a> um dein Konto zu verifizieren.';
$lang['de_DE']['Captcha_Error.ss']['LOGINTOSSADWORDS'] = 'Logge dich dann wieder in der SilverStripe Adwords-Schnittstelle ein, nach dem du erfolgreich dein Konto bei Google verifiziert hast.';
$lang['de_DE']['Ad_View.ss']['ADDNEWAD'] = 'Eine neue Anzeige zu dieser Seite hinzufügen.';
$lang['de_DE']['KeywordField.ss']['KEYWORDS'] = 'Schlüsselwörter';
$lang['de_DE']['KeywordField.ss']['EDIT'] = 'Bearbeiten';
$lang['de_DE']['KeywordField.ss']['SAVE'] = 'Speichern';
$lang['de_DE']['KeywordField.ss']['DELETE'] = 'Löschen';
$lang['de_DE']['KeywordField.ss']['KEYWORD'] = 'Schlüsselwort';
$lang['de_DE']['KeywordField.ss']['BID'] = 'Angebot';
$lang['de_DE']['KeywordField.ss']['URL'] = 'URL';
$lang['de_DE']['KeywordField.ss']['CLICKS'] = 'Klicks';
$lang['de_DE']['KeywordField.ss']['IMPRESSIONS'] = 'Eindrücke';
$lang['de_DE']['KeywordField.ss']['CTR'] = 'CTR';
$lang['de_DE']['KeywordField.ss']['POSITION'] = 'Position';
$lang['de_DE']['KeywordField.ss']['SCORE'] = 'Auswertung';
$lang['de_DE']['KeywordField.ss']['ADD'] = 'Hinzufügen:';
$lang['de_DE']['KeywordField.ss']['OPTIONALFIELDS'] = 'Beachte: Die Angebot- und URL-Felder sind optional, sie werden auf die vorgegebenen Werte der Anzeige zurückgesetzt, wenn sie nicht gesetzt werden.';
$lang['de_DE']['Navigation.ss']['STATUS'] = 'Status';
$lang['de_DE']['Navigation.ss']['DEFAULTBID'] = 'Vorgegebenes Angebot';
$lang['de_DE']['Navigation.ss']['IMPRESSIONS'] = 'Eindrücke';
$lang['de_DE']['Navigation.ss']['CTR'] = 'CTR';

?>
44 changes: 44 additions & 0 deletions lang/en_US.php
@@ -0,0 +1,44 @@
<?php

global $lang;

$lang['en_US']['Adwords']['ALLADS'] = 'Viewing All Ads';
$lang['en_US']['Adwords']['ADSFORTHISPAGE'] = 'Viewing Ads For This Page';
$lang['en_US']['Adwords']['VIEWADSFORTHISPAGE'] = 'View Ads for this page';
$lang['en_US']['Adwords']['VIEWALLADS'] = 'View all ads';
$lang['en_US']['Adwords']['NOADSINVIEW'] = 'There are no ads in this view.';
$lang['en_US']['Adwords']['LOGOUT'] = 'Sign out';
$lang['en_US']['CreationInterface']['LOADING'] = 'Loading...';
$lang['en_US']['CreationInterface']['RETURNTOMAIN'] = 'Return To Main View';
$lang['en_US']['AdField']['PAUSE'] = 'Pause';
$lang['en_US']['AdField']['UNPAUSE'] = 'Unpause';
$lang['en_US']['AdField']['SAVECHANGE'] = 'Save';
$lang['en_US']['LoginField']['SIGNINWITH'] = 'Sign in with your';
$lang['en_US']['LoginField']['ACCOUNT'] = 'Account';
$lang['en_US']['LoginField']['EMAIL'] = 'Email:';
$lang['en_US']['LoginField']['PASSWORD'] = 'Password:';
$lang['en_US']['LoginField']['SIGNIN'] = 'Sign in';
$lang['en_US']['Captcha_Error.ss']['FAILEDLOGINATTEMPTS'] = 'Due to the number of failed login attempts, Google requires that you login with them before you can use this resource.';
$lang['en_US']['Captcha_Error.ss']['VISITGOOGLE'] = 'Please visit <a href="https://www.google.com/accounts/DisplayUnlockCaptcha" target="_blank">https://www.google.com/accounts/DisplayUnlockCaptcha</a> to verify your account.';
$lang['en_US']['Captcha_Error.ss']['LOGINTOSSADWORDS'] = 'Then login to the SilverStripe Adwords interface again after you have successfully verified your account with Google.';
$lang['en_US']['Ad_View.ss']['ADDNEWAD'] = 'Add a new ad to this page.';
$lang['en_US']['KeywordField.ss']['KEYWORDS'] = 'Keywords';
$lang['en_US']['KeywordField.ss']['EDIT'] = 'Edit';
$lang['en_US']['KeywordField.ss']['SAVE'] = 'Save';
$lang['en_US']['KeywordField.ss']['DELETE'] = 'Delete';
$lang['en_US']['KeywordField.ss']['KEYWORD'] = 'Keyword';
$lang['en_US']['KeywordField.ss']['BID'] = 'Bid';
$lang['en_US']['KeywordField.ss']['URL'] = 'URL';
$lang['en_US']['KeywordField.ss']['CLICKS'] = 'Clicks';
$lang['en_US']['KeywordField.ss']['IMPRESSIONS'] = 'Impressions';
$lang['en_US']['KeywordField.ss']['CTR'] = 'CTR';
$lang['en_US']['KeywordField.ss']['POSITION'] = 'Position';
$lang['en_US']['KeywordField.ss']['SCORE'] = 'Score';
$lang['en_US']['KeywordField.ss']['ADD'] = 'Add:';
$lang['en_US']['KeywordField.ss']['OPTIONALFIELDS'] = 'Note: The Bid and URL fields are optional, they will take revert to the defaults of the Ad if they are not set.';
$lang['en_US']['Navigation.ss']['STATUS'] = 'Status';
$lang['en_US']['Navigation.ss']['DEFAULTBID'] = 'Default Bid';
$lang['en_US']['Navigation.ss']['IMPRESSIONS'] = 'Impressions';
$lang['en_US']['Navigation.ss']['CTR'] = 'CTR';

?>
2 changes: 1 addition & 1 deletion templates/Adwords.ss
Expand Up @@ -26,7 +26,7 @@ fieldset {
$LoginForm
<% end_if %>
<% else %>
You don't have permission to access this resource.
<% _t('NOPERMISSION','You don\'t have permission to access this resource.') %>
<% end_if %>
</body>
</html>
6 changes: 3 additions & 3 deletions templates/Captcha_Error.ss
Expand Up @@ -3,11 +3,11 @@
<table border="0" cellspacing="4" cellpadding="5">
<tr>
<td style="text-align: center;" bgcolor="#e8eefa" nowrap="nowrap" valign="top">
Due to the number of failed login attempts, Google requires that you login with them before you can use this resource.
<% _t('FAILEDLOGINATTEMPTS','Due to the number of failed login attempts, Google requires that you login with them before you can use this resource.') %>
<br /><br />
Please visit <a href="https://www.google.com/accounts/DisplayUnlockCaptcha" target="_blank">https://www.google.com/accounts/DisplayUnlockCaptcha</a> to verify your account.
<% _t('VISITGOOGLE','Please visit <a href="https://www.google.com/accounts/DisplayUnlockCaptcha" target="_blank">https://www.google.com/accounts/DisplayUnlockCaptcha</a> to verify your account.') %>
<br /><br />
Then login to the SilverStripe Adwords interface again after you have successfully verified your account with Google.
<% _t('LOGINTOSSADWORDS','Then login to the SilverStripe Adwords interface again after you have successfully verified your account with Google.') %>
</td>
</tr>
</table>
Expand Down

0 comments on commit 2a0201d

Please sign in to comment.