From 27b8a7db00ca5271fbd781420827a33dbce79bc7 Mon Sep 17 00:00:00 2001 From: ot2sen Date: Thu, 14 Feb 2013 20:53:03 +0100 Subject: [PATCH 01/12] Removing non standard elements Have had more report of users that could not install and got a Unable to write entry. Noticed today that the two elements packager and packagerurl were non-standard, and after removing files installed as should. --- .../components/com_ctransifex/assets/install.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/administrator/components/com_ctransifex/assets/install.xml b/source/administrator/components/com_ctransifex/assets/install.xml index 6fef9d1..df0c837 100644 --- a/source/administrator/components/com_ctransifex/assets/install.xml +++ b/source/administrator/components/com_ctransifex/assets/install.xml @@ -8,8 +8,6 @@ @@AUTHOR_URL@@ @@COPYRIGHT@@ GNU General Public License version 2 or later; see LICENSE.txt - CTransifex - https://compojoom.com @@ -18,4 +16,4 @@ @@ADMIN_FILENAMES@@ @@FRONTEND_FILENAMES@@ - \ No newline at end of file + From 199463e581a43120c89a002277cb679b2c56eedb Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 09:04:50 +0100 Subject: [PATCH 02/12] Preparing db for new calculation of percentage completed The values translated_entities and untranslated_entities are available in the incoming data, and can be used for a calculation of percentage completed that take into account the weight of the individual resources. As it is now, a 1 string resource and a 6500 strings resource have the same weight, and this doesnt give the correct value in front overview. --- .../components/com_ctransifex/sql/install.mysql.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/administrator/components/com_ctransifex/sql/install.mysql.sql b/source/administrator/components/com_ctransifex/sql/install.mysql.sql index de70021..9fd94ef 100644 --- a/source/administrator/components/com_ctransifex/sql/install.mysql.sql +++ b/source/administrator/components/com_ctransifex/sql/install.mysql.sql @@ -4,6 +4,8 @@ CREATE TABLE IF NOT EXISTS `#__ctransifex_languages` ( `resource_id` int(11) NOT NULL, `lang_name` varchar(255) NOT NULL, `completed` int(11) NOT NULL, + `untranslated_entities` int(11) NOT NULL, + `translated_entities` int(11) NOT NULL, `raw_data` longtext NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; From 3b280664cff64314e7795d6410373d1bb6328f88 Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 09:18:44 +0100 Subject: [PATCH 03/12] Added altered tables to script for preparing new calculation --- .../components/com_ctransifex/script.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/administrator/components/com_ctransifex/script.php b/source/administrator/components/com_ctransifex/script.php index 7c13047..fe83fdc 100644 --- a/source/administrator/components/com_ctransifex/script.php +++ b/source/administrator/components/com_ctransifex/script.php @@ -64,6 +64,16 @@ public static function updateTo1_0() { 'ALTER TABLE `#__ctransifex_languages` ADD `raw_data` LONGTEXT NOT NULL;'); $db->execute(); + + $db->setQuery( + 'ALTER TABLE `#__ctransifex_languages` + ADD `untranslated_entities` int(11) NOT NULL AFTER `completed`;'); + $db->execute(); + + $db->setQuery( + 'ALTER TABLE `#__ctransifex_languages` + ADD `translated_entities` int(11) NOT NULL AFTER `untranslated_entities`;'); + $db->execute(); } } @@ -403,4 +413,4 @@ public function install($parent) } -} \ No newline at end of file +} From 1d726edda3583675f99e966e9925b01f46304c88 Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 09:25:54 +0100 Subject: [PATCH 04/12] Added untranslated_entities and translated_entities More preparation for calculation of percentage using untranslated_entities and translated_entities --- .../components/com_ctransifex/models/language.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/administrator/components/com_ctransifex/models/language.php b/source/administrator/components/com_ctransifex/models/language.php index 47c436a..8d7dced 100644 --- a/source/administrator/components/com_ctransifex/models/language.php +++ b/source/administrator/components/com_ctransifex/models/language.php @@ -43,7 +43,9 @@ public function add($languages = array()) . $db->q($this->resourceId) . ',' . $db->q($langCode) . ',' . $db->q($language->completed) . ',' - . $db->q(json_encode($language)); + . $db->q($language->untranslated_entities) . ',' + . $db->q($language->translated_entities) . ',' + . $db->q(json_encode($language)); } } @@ -54,7 +56,9 @@ public function add($languages = array()) $db->qn('resource_id'), $db->qn('lang_name'), $db->qn('completed'), - $db->qn('raw_data') + $db->qn('untranslated_entities'), + $db->qn('translated_entities'), + $db->qn('raw_data') ) )->values($values); @@ -85,7 +89,9 @@ public function getResourcesForLang($jlang) $db->qn('r.resource_name'), $db->qn('l.lang_name'), $db->qn('l.completed'), - $db->qn('l.raw_data') + $db->qn('l.untranslated_entities'), + $db->qn('l.translated_entities'), + $db->qn('l.raw_data') ) ) ->from('#__ctransifex_languages AS l') @@ -96,4 +102,4 @@ public function getResourcesForLang($jlang) $db->setQuery($query); return $db->loadObjectList(); } -} \ No newline at end of file +} From da1ef7762d0729c68011aea048ea7429da6cf351 Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 09:34:14 +0100 Subject: [PATCH 05/12] Changed calculation of completed Using the new values translated_entities and untranslated_entities to have a calculation that take into account that resources have different weight. Now the percentage will show completed of basis of all strings in a project. --- .../components/com_ctransifex/models/package.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/administrator/components/com_ctransifex/models/package.php b/source/administrator/components/com_ctransifex/models/package.php index 70d78ab..b10e9ac 100644 --- a/source/administrator/components/com_ctransifex/models/package.php +++ b/source/administrator/components/com_ctransifex/models/package.php @@ -31,17 +31,20 @@ public function add($resources, $language) $db = JFactory::getDbo(); $query = $db->getQuery(true); - $completed = 0; + $translated = 0; + $untranslated = 0; $allResources = $this->countResources(); foreach($resources as $resource) { - $completed += $resource->completed; + $translated += $resource->translated_entities; + $untranslated += $resource->untranslated_entities; + $completed = (($translated / ($translated + $untranslated)) * 100); } $values = $db->q($this->projectId) . ',' . $db->q($language) . - ',' . $db->q((int)$completed/$allResources) . + ',' . $db->q((int)$completed) . ',' . $db->q(JFactory::getDate()->toSql()); $query->insert('#__ctransifex_zips') @@ -68,4 +71,4 @@ public function countResources() { return $db->loadObject()->count; } -} \ No newline at end of file +} From 2d241d96de00cb2b6413f8da06d66f4f678ecf7f Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 09:40:18 +0100 Subject: [PATCH 06/12] Added minimum_perc to projects Preparing db to allow to set a minimum percentage of which packages to show in frontend --- .../components/com_ctransifex/sql/install.mysql.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/source/administrator/components/com_ctransifex/sql/install.mysql.sql b/source/administrator/components/com_ctransifex/sql/install.mysql.sql index 9fd94ef..1f8622c 100644 --- a/source/administrator/components/com_ctransifex/sql/install.mysql.sql +++ b/source/administrator/components/com_ctransifex/sql/install.mysql.sql @@ -16,6 +16,7 @@ CREATE TABLE IF NOT EXISTS `#__ctransifex_projects` ( `transifex_slug` varchar(255) NOT NULL, `description` text NOT NULL, `alias` varchar(255) NOT NULL, + `minimum_perc` int(11) NOT NULL, `state` tinyint(4) NOT NULL, `created_by` int(11) NOT NULL, `created_by_alias` varchar(255) NOT NULL, From 25fb79597740f78dfbfc78649957eef8c1b270d1 Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 09:44:33 +0100 Subject: [PATCH 07/12] Added alter table for minumum_perc Added minimum_perc in projects to the update script --- source/administrator/components/com_ctransifex/script.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/administrator/components/com_ctransifex/script.php b/source/administrator/components/com_ctransifex/script.php index fe83fdc..b2ff677 100644 --- a/source/administrator/components/com_ctransifex/script.php +++ b/source/administrator/components/com_ctransifex/script.php @@ -59,6 +59,11 @@ public static function updateTo1_0() { 'ALTER TABLE `#__ctransifex_projects` ADD `params` LONGTEXT NOT NULL;'); $db->execute(); + + $db->setQuery( + 'ALTER TABLE `#__ctransifex_projects` + ADD `minimum_perc` int(11) NOT NULL AFTER `alias`;'); + $db->execute(); $db->setQuery( 'ALTER TABLE `#__ctransifex_languages` From 8f8e323fed9696cdde3660b944507bc6179276b1 Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 09:48:27 +0100 Subject: [PATCH 08/12] Added field minimum percentage Adding this field to allow limit by percentage completed which packages are shown in frontend. This allow you to not have all the 0% empty packages shown, by setting the value you prefer. --- .../components/com_ctransifex/models/forms/project.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/administrator/components/com_ctransifex/models/forms/project.xml b/source/administrator/components/com_ctransifex/models/forms/project.xml index fa46bbc..83ed7e7 100644 --- a/source/administrator/components/com_ctransifex/models/forms/project.xml +++ b/source/administrator/components/com_ctransifex/models/forms/project.xml @@ -21,6 +21,10 @@ + + Date: Sun, 10 Mar 2013 09:53:24 +0100 Subject: [PATCH 09/12] Added minimum_perc to the view This adds a field where you can enter a minimum percentage for limiting what is shown in frontend view. --- .../com_ctransifex/views/project/tmpl/default.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/administrator/components/com_ctransifex/views/project/tmpl/default.php b/source/administrator/components/com_ctransifex/views/project/tmpl/default.php index 9a5a3b2..6a7a157 100644 --- a/source/administrator/components/com_ctransifex/views/project/tmpl/default.php +++ b/source/administrator/components/com_ctransifex/views/project/tmpl/default.php @@ -60,6 +60,14 @@ form->getInput('alias'); ?> +
+
+ form->getLabel('minimum_perc'); ?> +
+
+ form->getInput('minimum_perc'); ?> +
+
form->getLabel('extension_name'); ?> @@ -105,4 +113,4 @@ - \ No newline at end of file + From 2cbf83488956aa8311643051d5939c5e97634b66 Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 09:55:54 +0100 Subject: [PATCH 10/12] Added two strings for minimum percentage Added string and label string for the new minimum percentage setting --- source/administrator/language/en-GB/en-GB.com_ctransifex.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/administrator/language/en-GB/en-GB.com_ctransifex.ini b/source/administrator/language/en-GB/en-GB.com_ctransifex.ini index 00d9fa3..f94eeab 100644 --- a/source/administrator/language/en-GB/en-GB.com_ctransifex.ini +++ b/source/administrator/language/en-GB/en-GB.com_ctransifex.ini @@ -39,3 +39,5 @@ COM_CTRANSIFEX_NO_GLOBAL_WEBHOOKS_KEY ="You haven't edited the extension config COM_CTRANSIFEX_TRANSIFEX_WEBHOOKS="Webhooks url" COM_CTRANSIFEX_CONTRIBUTE_LINK="Contribute link" COM_CTRANSIFEX_CONTRIBUTE_LINK_DESC="Show a contribute now link for languages that are not 100% translated" +COM_CTRANSIFEX_MINIMUM_PERC="Minimum percentage" +COM_CTRANSIFEX_MINIMUM_PERC_DESC="Here you can enter a value for minimum percentage. This value will influence which languages are shown in frontend. Only languages that have a completed percentage equal to or higher than the set value will be shown" From b0aacb95db0f78c44361671a4d15b663a627d5b8 Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 10:07:25 +0100 Subject: [PATCH 11/12] Added condition to allow limit by minimum percentage By default ctransifex list all the incoming packages, also the 0% ones, and by allowing to set a minimum percentage you can decide which packages you wish to show in frontend view. The value can be set individually for each project. --- .../components/com_ctransifex/models/package.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/administrator/components/com_ctransifex/models/package.php b/source/administrator/components/com_ctransifex/models/package.php index b10e9ac..f884048 100644 --- a/source/administrator/components/com_ctransifex/models/package.php +++ b/source/administrator/components/com_ctransifex/models/package.php @@ -41,6 +41,15 @@ public function add($resources, $language) $untranslated += $resource->untranslated_entities; $completed = (($translated / ($translated + $untranslated)) * 100); } + + // make front listing and saving of zip values depend on the value minimum_perc + $query ->select('minimum_perc') + ->from('#__ctransifex_projects') + ->where('id='.$db->quote($this->projectId)); + $db->setQuery($query); + $result = $db->loadObject(); + $minperc = $result->minimum_perc; + if ($completed >= $minperc){ $values = $db->q($this->projectId) . ',' . $db->q($language) . @@ -59,6 +68,7 @@ public function add($resources, $language) $db->setQuery($query); $db->execute(); + } } public function countResources() { From 0d3c6daf3e7a5f0daac68ddc295523dd77650b5c Mon Sep 17 00:00:00 2001 From: ot2sen Date: Sun, 10 Mar 2013 16:43:05 +0100 Subject: [PATCH 12/12] Small check if files Noticed that script stopped when a project only had one type of extension files, for example only admin files and no site files. A simple check for $files seems to solve that so packages are built also when only having one type. --- .../components/com_ctransifex/helpers/package.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/administrator/components/com_ctransifex/helpers/package.php b/source/administrator/components/com_ctransifex/helpers/package.php index 98a4d27..9e856c3 100644 --- a/source/administrator/components/com_ctransifex/helpers/package.php +++ b/source/administrator/components/com_ctransifex/helpers/package.php @@ -155,9 +155,11 @@ private static function getFiles($folder) { $files = JFolder::files($folder); $xml = array(); + if($files){ foreach($files as $file) { $xml[] = ''.$file.''; + } } return implode("\n", $xml); } -} \ No newline at end of file +}