Skip to content

Commit

Permalink
Merge pull request #10 from leotiger/develop
Browse files Browse the repository at this point in the history
Hide away complex system inflectors
  • Loading branch information
leotiger authored Aug 8, 2018
2 parents 56ac02c + 642619b commit bc58abe
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v1.1.0
## 08-08-2018

1. [](#new)
* Hide away complex system internals that include Regular Expressions to assure hassle-free usage of the plugin by less experienced site administrators
1. [](#bugfix)
* Plugin domains, once translated with Babel, did not show status information correctly. Fixed.

# v1.0.4
## 08-08-2018

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ You can export language packs based on domains, e.g. export translations sets re
definitions. Please take into account that you have to trigger the export for each language. Export functionality is only available when a language domain
is active but not for all domains and not for the *babelized* filter.

The plugin offers three special filters that represent virtual domains:

* all domains
* babelized (items edited with the Babel plugin)
* unclassified

The last filter loads a collection of variables ( that

## What's missing

* a common, shared language repository for GRAV
Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Babel
version: 1.0.4
version: 1.1.0
description: Translation services for GRAV
icon: language
author:
Expand Down
9 changes: 6 additions & 3 deletions classes/BabelConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,22 @@ public function query($query)
return new BabelResultObject($results);
}

public function runBabelDefs(&$babeldefinitions, $babels, $level = 0, $levels = []) {

public function runBabelDefs(&$babeldefinitions, $babels, $level = 0, $levels = []) {
$excludes = ["INFLECTOR_PLURALS", "INFLECTOR_SINGULAR"];
foreach($babels as $key => $babel) {
if (!is_array($babel)) {
if ($level == 0) {
$id = 'unclassified.' . $key;
} else {
$id = implode('.', $levels) . '.' . $key;
}
}
if (!in_array($id, $babeldefinitions)) {
$babeldefinitions[$id] = $id;
}
} elseif (is_array($babel)) {
if (in_array($key, $excludes)) {
continue;
}
$levels[$level] = $key;
$this->runBabelDefs($babeldefinitions, $babel, $level + 1, $levels);
}
Expand Down
8 changes: 4 additions & 4 deletions classes/BabelSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,14 @@ public function getValueFromInfoTable($value)
public function getBabelStats($languages, $domain = "")
{
$stats = [];
$babelized = 0;
//$babelized = 0;
if ($domain == '*b') {
$domain = false;
$babelized = 1;
}

foreach($languages as $language) {
$query = "SELECT COUNT(doc_id) FROM babellist WHERE babelized = $babelized and language = :language AND status = 0" . ($domain ? ' AND domain = :domain' : "");
$query = "SELECT COUNT(doc_id) FROM babellist WHERE " . (isset($babelized) ? 'babelized = 1 and ' : '') . "language = :language AND status = 0" . ($domain ? ' AND domain = :domain' : "");
$stmtDoc = $this->index->prepare($query);
$stmtDoc->bindValue(':language', $language);
if ($domain) {
Expand All @@ -452,7 +452,7 @@ public function getBabelStats($languages, $domain = "")
$stmtDoc->execute();
$untranslated = $stmtDoc->fetchAll(PDO::FETCH_COLUMN);

$query = "SELECT COUNT(doc_id) FROM babellist WHERE babelized = $babelized and language = :language AND status = 1" . ($domain ? ' AND domain = :domain' : "");
$query = "SELECT COUNT(doc_id) FROM babellist WHERE " . (isset($babelized) ? 'babelized = 1 and ' : '') . "language = :language AND status = 1" . ($domain ? ' AND domain = :domain' : "");
$stmtDoc = $this->index->prepare($query);
$stmtDoc->bindValue(':language', $language);
if ($domain) {
Expand All @@ -461,7 +461,7 @@ public function getBabelStats($languages, $domain = "")
$stmtDoc->execute();
$translated = $stmtDoc->fetchAll(PDO::FETCH_COLUMN);

$query = "SELECT COUNT(doc_id) FROM babellist WHERE babelized = $babelized and language = :language" . ($domain ? ' AND domain = :domain' : "");
$query = "SELECT COUNT(doc_id) FROM babellist WHERE " . (isset($babelized) ? 'babelized = 1 and ' : '') . "language = :language" . ($domain ? ' AND domain = :domain' : "");
$stmtDoc = $this->index->prepare($query);
$stmtDoc->bindValue(':language', $language);
if ($domain) {
Expand Down
2 changes: 2 additions & 0 deletions languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ en:
MERGE: Merge
EXPORT: Export
DOMAIN_PACKAGE: Exported Language Pack
HIDE_SYSTEM: Hide system
HIDE_SYSTEM_HELP: Exclude GRAV System variables. You should not disable this option without a deep knowledge of the GRAV system internals and programming skills.

0 comments on commit bc58abe

Please sign in to comment.