Skip to content

Commit

Permalink
Version 0.1.0, not so much functionality, but framework is done
Browse files Browse the repository at this point in the history
  • Loading branch information
MaWoScha committed Feb 6, 2015
0 parents commit 92bd701
Show file tree
Hide file tree
Showing 12 changed files with 465 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# German_LocaleFallback
Dieses Paket zur Unterstützung von Sprachpaketen wird von MaWoScha verwaltet.

This package for supporting LocalePack is managed by [MaWoScha](https://github.com/MaWoScha).

# Use
Add support for a fallback language.

Usecase: You have in the LocalePack_de_DE and LocalePack_de_CH, nearly everything is the same but
a few are not, so if you don't find a phrase in de_CH look it up in the fallback, de_DE.

Fügt die Unterstützung einer Ausweichsprache hinzu.

Anwendungsfall: Sie haben in den LocalePack_de_DE und LocalePack_de_CH, fast alles ist gleich, aber einige Einträge
sind es nicht; wenn Sie also einen Eintrag in de_CH nicht finden, schauen Sie in die Ausfallmöglichkeit de_DE.

# More info

* http://www.integer-net.de/magento-at-landerversion-mit-fallback-modus-fur-ubersetzungen/ (German)
* http://blog.siempro.co/?p=105&lang=en (English, German, Spanish)

# Version history

v0.1.0

No so much functionality yet, but a framework is done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* @category German
* @package German_LocaleFallback
* @authors MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @developer MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @version 0.1.0
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class German_LocaleFallback_Block_System_Config_Form_Fieldset_ExtensionsList
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
{
public function render(Varien_Data_Form_Element_Abstract $element)
{
$html = $this->_getHeaderHtml($element);
$modules = Mage::getConfig()->getNode('modules')->children();

foreach ($modules as $moduleName => $values) {
if (0 !== strpos($moduleName, 'German_')) {
continue;
}

if ($moduleName == 'German_LocaleFallback') {
continue;
}

if ($values->title) {
$moduleName = (string) $values->title;
}

$field = $element->addField($moduleName, 'label', array(
'label' => $moduleName,
'value' => (string) $values->version
));
$html .= $field->toHtml();
}

$html .= $this->_getFooterHtml($element);

return $html;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* @category German
* @package German_LocalePack
* @authors MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @developer MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @version 0.1.0
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class German_LocaleFallback_Block_System_Config_Form_Fieldset_Instructions
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
{
public function render(Varien_Data_Form_Element_Abstract $element)
{
$helper = Mage::helper("localefallback");
$html = $this->_getHeaderHtml($element);
$html .= "<p><strong>";
$html .= $helper->__("The <span style='color:red'>%s</span> language pack in version <span style='color:red'>%s</span> has been successfully installed.",
(string)Mage::app()->getConfig()->getNode('modules/German_LocalePackEn/lang'),
(string)Mage::app()->getConfig()->getNode('modules/German_LocalePackEn/version'));
$html .= "</strong></p>";

$html .= "<p>";
$html .= $helper->__("Magento has only one variable available for the locale (<a href='%s'>locale</a>). This extension now provides two settings:",
Mage::helper('adminhtml')->getUrl('adminhtml/system_config/edit', array('section'=>'general')));
$html .= "</p>";

$html .= "<ol style='list-style-position: outside; list-style-type: disc; margin-left:18px;'>";
$html .= "<li>".$helper->__('Locale Preferred')."</li>";
$html .= "<li>".$helper->__('Locale Fallback')."</li>";
$html .= '</ol>';

$html .= "<p>".$helper->__("Now it is possible to use a preferred language with a fallback language. Thus it can be set as the preferred language a partially available language, the fallback language then takes over the lack of rest.")."</p>";
$html .= "<p>".$helper->__("You want to sell and make use of the language of your target audience. Magento supports it – at least in theory. Practically, it is then but so that for most languages no language packs are available for Magento. Creating your own custom language pack fails again mostly at the expense: The language files of Magento contain several thousand entries.")."</p>";
$html .= "<p>".$helper->__("However, the complexity is significantly lower when only a limited selection of entries had to be translated and for the rest a fallback language could be defined. That would be also safe in case of updating the Magento software.")."</p>";
$html .= "<p>".$helper->__("The fallback language, which complements the missing entries of their own language pack, can be defined here. First, however, one's own language pack must be installed. The process can be reversed.")."</p>";
$html .= "<hr style='margin-top:20px;'>";

$html .= $helper->__("This package is simply adding tree Static Blocks to the <a href='%s'>E-Mail-Templates</a>:",
Mage::helper('adminhtml')->getUrl('adminhtml/system_email_template'));
$html .= '<ul style="list-style-position: outside; list-style-type: disc; margin-left:18px;">';
$html .= '<li>email_template_say_hello &nbsp; ('.$helper->__('Salutation').')</li>';
$html .= '<li>email_template_contact &nbsp; ('.$helper->__('Contact information').')</li>';
$html .= '<li>email_template_say_bye &nbsp; ('.$helper->__('Closing formula').')</li>';
$html .= '</ul>';
$html .= "<p>";
$html .= $helper->__("The static blocks can be managed by the <a href='%s'>CMS system</a> in the admin area.",
Mage::helper('adminhtml')->getUrl('adminhtml/cms_block'));
$html .= "</p>";
$html .= "<p style='text-align:right;'>";
$html .= $helper->__("powered by <a>Me</a>");
$html .= "</p>";
$html .= $this->_getFooterHtml($element);

return $html;
}
}
12 changes: 12 additions & 0 deletions app/code/community/German/LocaleFallback/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
/**
* @category German
* @package German_LocaleFallback
* @authors MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @developer MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @version 0.1.0
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class German_LocaleFallback_Helper_Data extends Mage_Core_Helper_Abstract {

}
20 changes: 20 additions & 0 deletions app/code/community/German/LocaleFallback/Model/Observer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* @category German
* @package German_LocaleFallback
* @authors MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @developer MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @version 0.1.0
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class German_LocaleFallback_Model_Observer {

/**
* Get URL of AdminPanel LocalePack section
*
* @return string
*/
public function getManageUrl() {
return Mage::helper("adminhtml")->getUrl('adminhtml/system_config/edit', array('section'=>'localefallback'));
}
}
80 changes: 80 additions & 0 deletions app/code/community/German/LocaleFallback/etc/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0"?>
<!--
/**
* @category German
* @package German_LocaleFallback
* @authors MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @developer MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @source http://www.magentocommerce.com/wiki/modules_reference/german/klassen
* @source http://www.alanstorm.com/magento_acl_authentication
*/
-->
<config>
<modules>
<German_LocaleFallback>
<version>0.1.0</version>
<title>Locale Fallback</title>
</German_LocaleFallback>
</modules>

<global>
<blocks>
<localefallback>
<class>German_LocaleFallback_Block</class>
</localefallback>
</blocks>
<helpers>
<localefallback>
<class>German_LocaleFallback_Helper</class>
</localefallback>
</helpers>
<models>
<localefallback>
<class>German_LocaleFallback_Model</class>
</localefallback>
</models>
</global>

<adminhtml>
<layout>
<updates>
<localefallback>
<file>localefallback.xml</file>
</localefallback>
</updates>
</layout>
<translate>
<modules>
<German_LocaleFallback>
<files>
<default>German_LocaleFallback.csv</default>
</files>
</German_LocaleFallback>
</modules>
</translate>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<system>
<children>
<config>
<children>
<localefallback translate="title" module="localefallback">
<title>Locale Fallback</title>
</localefallback>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</adminhtml>

</config>
61 changes: 61 additions & 0 deletions app/code/community/German/LocaleFallback/etc/system.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* @category German
* @package German_LocaleFallback
* @authors MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @developer MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @version 0.1.0
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @source http://www.magentocommerce.com/wiki/modules_reference/german/klassen
*/
-->
<config>
<tabs>
<localepacks translate="label" module="localefallback">
<label>Locale Packs</label>
<sort_order>150</sort_order>
</localepacks>
</tabs>

<sections>
<localefallback translate="label" module="localefallback">
<label>Information</label>
<tab>localepacks</tab>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<groups>
<instructions translate="label comment" module="localefallback">
<label>Instructions</label>
<frontend_type>text</frontend_type>
<frontend_model>localefallback/system_config_form_fieldset_instructions</frontend_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</instructions>
<contact translate="label comment" module="localefallback">
<label>Contact</label>
<frontend_type>text</frontend_type>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<comment><![CDATA[Please visit us on <a href='https://github.com/MaWoScha' target='_blank'>GitHub</a> for more language packs.<br /><br />You can contact us via <a href='http://blog.siempro.co' target='_blank'>our website</a> or at <a href='mailto:mawoscha@siempro.co' target='_blank'>mawoscha@siempro.co</a>, if you have any question.]]></comment>
</contact>
<extensions translate="label" module="localefallback">
<label>Installed Language Packs</label>
<frontend_type>text</frontend_type>
<frontend_model>localefallback/system_config_form_fieldset_extensionslist</frontend_model>
<sort_order>30</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<comment><![CDATA[You have installed the following:]]></comment>
</extensions>
</groups>
</localefallback>
</sections>
</config>
18 changes: 18 additions & 0 deletions app/etc/modules/German_LocaleFallback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!--
/**
* @category German
* @package German_LocalePack
* @authors MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @developer MaWoScha <mawoscha@siempro.co, http://www.siempro.co/>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->
<config>
<modules>
<German_LocaleFallback>
<active>true</active>
<codePool>community</codePool>
</German_LocaleFallback>
</modules>
</config>
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "magento-german/localefallback",
"license": "OSL-3.0",
"type": "magento-module",
"description": "Allows a fallback for locales (translations, emails etc.)",
"homepage": "https://github.com/MaWoScha/German_LocaleFallback",
"require": {
"magento-german/magento-composer-installer": "*"
}
}
6 changes: 6 additions & 0 deletions modman
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#BackendModule
app/code/community/German/LocaleFallback app/code/community/German/LocaleFallback
app/etc/modules/German_LocaleFallback.xml app/etc/modules/German_LocaleFallback.xml
app/locale/de_DE/German_LocaleFallback.csv app/locale/de_DE/German_LocaleFallback.csv
app/locale/en_US/German_LocaleFallback.csv app/locale/en_US/German_LocaleFallback.csv
app/locale/es_ES/German_LocaleFallback.csv app/locale/es_ES/German_LocaleFallback.csv
Loading

0 comments on commit 92bd701

Please sign in to comment.