CC-1960: Internationalize Airtime / Support translations

-added language option in preferences
This commit is contained in:
denise 2012-11-21 12:44:50 -05:00
parent c344282e4d
commit 25ddd083bc
5 changed files with 45 additions and 1 deletions

View file

@ -17,8 +17,9 @@ class LocaleController extends Zend_Controller_Action
header("Content-type: text/javascript");
$baseUrl = Application_Common_OsPath::getBaseDir();
$locale = Application_Model_Preference::GetLocale();
echo "var datatables_dict =" .
file_get_contents($_SERVER['DOCUMENT_ROOT'].$baseUrl.'/js/datatables/i18n/en_CA.txt');
file_get_contents($_SERVER['DOCUMENT_ROOT'].$baseUrl.'/js/datatables/i18n/'.$locale.'.txt');
}
public function generalTranslationTableAction()

View file

@ -44,6 +44,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view);
Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]);
Application_Model_Preference::SetAllow3rdPartyApi($values["thirdPartyApi"]);
Application_Model_Preference::SetLocale($values["locale"]);
Application_Model_Preference::SetTimezone($values["timezone"]);
Application_Model_Preference::SetWeekStartDay($values["weekStartDay"]);

View file

@ -51,6 +51,13 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$third_party_api->setDecorators(array('ViewHelper'));
$this->addElement($third_party_api);
$locale = new Zend_Form_Element_Select("locale");
$locale->setLabel(_("locale"));
$locale->setMultiOptions($this->getLocales());
$locale->setValue(Application_Model_Preference::GetLocale());
$locale->setDecorators(array('ViewHelper'));
$this->addElement($locale);
/* Form Element for setting the Timezone */
$timezone = new Zend_Form_Element_Select("timezone");
$timezone->setLabel(_("Timezone"));
@ -109,4 +116,13 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
return $days;
}
private function getLocales()
{
$locales = array(
'en_CA' => 'English'
);
return $locales;
}
}

View file

@ -429,6 +429,16 @@ class Application_Model_Preference
return self::getValue("timezone");
}
public static function SetLocale($locale)
{
self::setValue("locale", $locale);
}
public static function GetLocale()
{
return self::getValue("locale");
}
public static function SetStationLogo($imagePath)
{
if (!empty($imagePath)) {

View file

@ -50,6 +50,22 @@
</ul>
<?php endif; ?>
</dd>
<dt id="locale-label" class="block-display">
<label class="required" for="locale"><?php echo $this->element->getElement('locale')->getLabel() ?>:
</label>
</dt>
<dd id="locale-element" class="block-display">
<?php echo $this->element->getElement('locale') ?>
<?php if($this->element->getElement('locale')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('locale')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="timezone-label" class="block-display">
<label class="required" for="timezone"><?php echo $this->element->getElement('timezone')->getLabel() ?>
<span class="info-text-small">(Required)</span> :