Skip to content

Commit

Permalink
Merge pull request #8 from leotiger/develop
Browse files Browse the repository at this point in the history
Index root level language variables in unclassified domain
  • Loading branch information
leotiger authored Aug 8, 2018
2 parents 889c1a9 + 11d08ee commit 56ac02c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# v1.0.4
## 08-08-2018

1. [](#bugfix)
* Fixed indexing problem for variables with no parent group identifier aka domain. These are no routed into domain *unclassified*
* Indexing as unclassified should fix as well wrong attributions and counts for the rest of the domains

# v1.0.3
## 08-08-2018

1. [](#new)
* Zip exported domain definitions into language pack zips
* Zip exported domain definitions into language packs
* Make domain language packs available in the Babel interface

# v1.0.2
Expand Down
2 changes: 1 addition & 1 deletion admin/templates/babel_domains.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
{% else %}
<td>0.00%</td>
{% endif %}
{% if current_domain in ['*', '*b'] or current_domain is empty %}
{% if current_domain in ['*', '*b', 'unclassified'] or current_domain is empty %}
<td>
</td>
{% else %}
Expand Down
4 changes: 1 addition & 3 deletions assets/admin/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@
$('.admin-block .export').on('click', function() {
var $domain = $(this).data('domain');
var $lang = $(this).data('lang');
//document.location = GravAdmin.config.base_url_relative + '/babel';
//table.destroy();
babelexport($domain, $lang);
});

Expand All @@ -172,7 +170,7 @@
var babelset = function(status, lang, domain, count) {
$('#babels_table').dataTable( {
dom: "Bfrtip",
autoWidth: true,
autoWidth: false,
columns: [
{ data: null, render: function ( data, type, row ) {
var $col = '<div class="babel_definition"><div class="babel_save' + (data.babelized == '1' ? ' button' : '') + '"><i class="fa fa-save"></i></div><input class="babel_doc_id" type="hidden" value="' + data.doc_id + '" />' +
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.3
version: 1.0.4
description: Translation services for GRAV
icon: language
author:
Expand Down
8 changes: 7 additions & 1 deletion classes/BabelConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ public function runBabelDefs(&$babeldefinitions, $babels, $level = 0, $levels =

foreach($babels as $key => $babel) {
if (!is_array($babel)) {
$id = implode('.', $levels) . '.' . $key;
if ($level == 0) {
$id = 'unclassified.' . $key;
} else {
$id = implode('.', $levels) . '.' . $key;
}
if (!in_array($id, $babeldefinitions)) {
$babeldefinitions[$id] = $id;
}
Expand All @@ -87,6 +91,7 @@ private function createBabelDef($definition, $code) {
$babelobj->route = $definition;
$babelobj->domain = explode('.', $definition)[0];
$babelobj->language = $code;
$definition = str_replace('unclassified.', '', $definition);
$translation = Grav::instance()['language']->translate($definition, [$code]);

if ($translation == $definition || !$translation) {
Expand All @@ -100,6 +105,7 @@ private function createBabelDef($definition, $code) {
$translations = [];
foreach($codes as $langdef) {
if ($langdef != $code) {
//$definition = str_replace('unclassified.', '', $definition);
$translation = Grav::instance()['language']->translate($definition, [$langdef]);
if ($translation != $definition && $translation) {
$rtl = Babel::isRtl($langdef) ? 'RTL' : 'LTR';
Expand Down
8 changes: 5 additions & 3 deletions classes/BabelSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ public function exportBabel($post) {

$translations = [];
foreach($export as $definition) {
$translations = array_merge_recursive($translations, $this->toYamlArray(explode('.', $definition['route']), $definition['translated']));
$route = str_replace('unclassified.', '', $definition['route']);
$translations = array_merge_recursive($translations, $this->toYamlArray(explode('.', $route), $definition['translated']));
}

$yamlfile = CompiledYamlFile::instance($pathToExport . DS . $lang . '.yaml');
Expand Down Expand Up @@ -643,8 +644,9 @@ public function mergeBabel() {
$export = $stmtDoc->fetchAll(PDO::FETCH_ASSOC);

$translations = [];
foreach($export as $definition) {
$translations = array_merge_recursive($translations, $this->toYamlArray(explode('.', $definition['route']), $definition['translated']));
foreach($export as $definition) {
$route = str_replace('unclassified.', '', $definition['route']);
$translations = array_merge_recursive($translations, $this->toYamlArray(explode('.', $route), $definition['translated']));
}
if (count($translations)) {
$yamlfile = CompiledYamlFile::instance($data_path . DS . $langdef . '.yaml');
Expand Down

0 comments on commit 56ac02c

Please sign in to comment.