Improved JCB to now be able to have other languanges then en-GB as its base/main/global language. This will allow you to build your components in a language of your choice.

This commit is contained in:
2018-04-20 01:36:21 +02:00
parent d1813147d3
commit 4b57e69edb
19 changed files with 109 additions and 73 deletions

View File

@ -85,18 +85,18 @@
filter="unset"
/>
<!-- Dynamic Fields. -->
<!-- Entranslation Field. Type: Textarea. (joomla) -->
<!-- Source Field. Type: Textarea. (joomla) -->
<field
type="textarea"
name="entranslation"
label="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_ENTRANSLATION_LABEL"
name="source"
label="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_SOURCE_LABEL"
rows="4"
cols="5"
description="JFIELD_TITLE_DESC"
message="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_ENTRANSLATION_MESSAGE"
message="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_SOURCE_MESSAGE"
class="text_area span12"
filter="STRING"
hint="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_ENTRANSLATION_HINT"
filter="safehtml"
hint="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_SOURCE_HINT"
readonly="true"
disabled="true"
/>

View File

@ -470,12 +470,19 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
$user = JFactory::getUser();
// remove header if it has headers
$id_key = $data['target_headers']['id'];
$english_key = $data['target_headers']['English'];
if (isset($data['target_headers']['Source']))
{
$source_key = $data['target_headers']['Source'];
}
else
{
$source_key = $data['target_headers']['English'];
}
// get the first array set
$firstSet = reset($data['array']);
// check if first array is a header array and remove if true
if($firstSet[$id_key] == 'id' || $firstSet[$english_key] == 'English')
if($firstSet[$id_key] == 'id' || $firstSet[$source_key] == 'Source' || $firstSet[$source_key] == 'English')
{
array_shift($data['array']);
}
@ -504,7 +511,7 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
->select($db->quoteName(array('version', 'translation')))
->from($db->quoteName('#__componentbuilder_'.$table))
->where($db->quoteName('id') . ' = '. $db->quote($row[$id_key]))
->where($db->quoteName('entranslation') . ' = '. $db->quote($row[$english_key]));
->where($db->quoteName('source') . ' = '. $db->quote($row[$source_key]));
// Reset the query using our newly populated query object.
$db->setQuery($query);
$db->execute();
@ -538,7 +545,7 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
foreach($row as $key => $cell)
{
// ignore column
if ('IGNORE' === $target[$key] || 'modified_by' === $target[$key] || 'modified' === $target[$key] || 'English' === $target[$key] )
if ('IGNORE' === $target[$key] || 'modified_by' === $target[$key] || 'modified' === $target[$key] || 'Source' === $target[$key] || 'English' === $target[$key] )
{
continue;
}

View File

@ -614,9 +614,9 @@ class ComponentbuilderModelLanguage_translation extends JModelAdmin
}
// Only for strings
if (ComponentbuilderHelper::checkString($this->table->entranslation) && !is_numeric($this->table->entranslation))
if (ComponentbuilderHelper::checkString($this->table->source) && !is_numeric($this->table->source))
{
$this->table->entranslation = $this->generateUniqe('entranslation',$this->table->entranslation);
$this->table->source = $this->generateUniqe('source',$this->table->source);
}
// insert all set values

View File

@ -44,7 +44,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.entranslation','entranslation'
'a.source','source'
);
}
@ -65,8 +65,8 @@ class ComponentbuilderModelLanguage_translations extends JModelList
{
$this->context .= '.' . $layout;
}
$entranslation = $this->getUserStateFromRequest($this->context . '.filter.entranslation', 'filter_entranslation');
$this->setState('filter.entranslation', $entranslation);
$source = $this->getUserStateFromRequest($this->context . '.filter.source', 'filter_source');
$this->setState('filter.source', $source);
$sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int');
$this->setState('filter.sorting', $sorting);
@ -153,11 +153,11 @@ class ComponentbuilderModelLanguage_translations extends JModelList
// load the languages to the string
if (ComponentbuilderHelper::checkArray($langBucket))
{
$item->entranslation = '<small><em>(' . implode(', ', $langBucket) . ')</em></small> ' . ComponentbuilderHelper::htmlEscape($item->entranslation, 'UTF-8', true, 150) . $componentCounter;
$item->source = '<small><em>(' . implode(', ', $langBucket) . ')</em></small> ' . ComponentbuilderHelper::htmlEscape($item->source, 'UTF-8', true, 150) . $componentCounter;
}
else
{
$item->entranslation = '<small><em>(' . JText::_('COM_COMPONENTBUILDER_NOTRANSLATION') . ')</em></small> ' . ComponentbuilderHelper::htmlEscape($item->entranslation, 'UTF-8', true, 150) . $componentCounter;
$item->source = '<small><em>(' . JText::_('COM_COMPONENTBUILDER_NOTRANSLATION') . ')</em></small> ' . ComponentbuilderHelper::htmlEscape($item->source, 'UTF-8', true, 150) . $componentCounter;
}
}
}
@ -187,7 +187,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
{
$item->{$lanTag} = '';
}
// now adapt the entranslation
// now adapt the source
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
{
$translations = json_decode($item->translation, true);
@ -268,7 +268,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
else
{
$search = $db->quote('%' . $db->escape($search) . '%');
$query->where('(a.entranslation LIKE '.$search.')');
$query->where('(a.source LIKE '.$search.')');
}
}
@ -386,11 +386,11 @@ class ComponentbuilderModelLanguage_translations extends JModelList
// load the languages to the string
if (ComponentbuilderHelper::checkArray($langBucket))
{
$item->entranslation = '<small><em>(' . implode(', ', $langBucket) . ')</em></small> ' . ComponentbuilderHelper::htmlEscape($item->entranslation, 'UTF-8', true, 150) . $componentCounter;
$item->source = '<small><em>(' . implode(', ', $langBucket) . ')</em></small> ' . ComponentbuilderHelper::htmlEscape($item->source, 'UTF-8', true, 150) . $componentCounter;
}
else
{
$item->entranslation = '<small><em>(' . JText::_('COM_COMPONENTBUILDER_NOTRANSLATION') . ')</em></small> ' . ComponentbuilderHelper::htmlEscape($item->entranslation, 'UTF-8', true, 150) . $componentCounter;
$item->source = '<small><em>(' . JText::_('COM_COMPONENTBUILDER_NOTRANSLATION') . ')</em></small> ' . ComponentbuilderHelper::htmlEscape($item->source, 'UTF-8', true, 150) . $componentCounter;
}
}
}
@ -420,7 +420,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
{
$item->{$lanTag} = '';
}
// now adapt the entranslation
// now adapt the source
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
{
$translations = json_decode($item->translation, true);
@ -458,7 +458,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
// start setup of headers
$headers = new stdClass();
$headers->id = 'id';
$headers->English = 'English';
$headers->Source = 'Source';
// add the languages
if (ComponentbuilderHelper::checkArray($languages))
{
@ -485,7 +485,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' . $this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.entranslation');
$id .= ':' . $this->getState('filter.source');
return parent::getStoreId($id);
}