Skip to content

Commit

Permalink
Integration framework with JSON-encoded files, beta
Browse files Browse the repository at this point in the history
  • Loading branch information
johnclause committed May 16, 2015
1 parent 8c80436 commit fa87157
Show file tree
Hide file tree
Showing 101 changed files with 2,187 additions and 1,369 deletions.
505 changes: 384 additions & 121 deletions admin/js/common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion admin/js/common.min.js

Large diffs are not rendered by default.

21 changes: 0 additions & 21 deletions admin/js/edit-custom-page.js

This file was deleted.

1 change: 0 additions & 1 deletion admin/js/edit-custom-page.min.js

This file was deleted.

16 changes: 8 additions & 8 deletions admin/js/edit-nav-menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ qTranslateConfig.js={
var form=document.getElementById('update-nav-menu');
if(!form) return false;

addMenuItemHooks=function(li,form)
addMenuItemHooks=function(li)
{
qtx.addContentHooksByClass('edit-menu-item-title',form,li);
qtx.addContentHooksByClass('edit-menu-item-attr-title',form,li);
qtx.addContentHooksByClass('[edit-menu-item-description',form,li);//must use '[:]' separator style
qtx.addContentHooksByClass('edit-menu-item-title',li);
qtx.addContentHooksByClass('edit-menu-item-attr-title',li);
qtx.addContentHooksByClass('[edit-menu-item-description',li);//must use '[:]' separator style

qtx.addDisplayHooksByClass('menu-item-title',li);
qtx.addDisplayHooksByClass('item-title',li);
qtx.addDisplayHooksByTagInClass('link-to-original','A',li);
}

function addMenuPageHooks(qtx,form)
function addMenuPageHooks(qtx)
{
var items=document.getElementsByClassName('menu-item');
for(var i=0; i<items.length; ++i)
{
var li=items[i];
addMenuItemHooks(li,form);
addMenuItemHooks(li);
}
var sst = document.getElementById('side-sortables');
if(sst) qtx.addDisplayHooksByClass('menu-item-title',sst);
}
addMenuPageHooks(qtx,form);
addMenuPageHooks(qtx);

if(wpNavMenu){
var wp_addMenuItemToBottom = wpNavMenu.addMenuItemToBottom;
Expand All @@ -41,7 +41,7 @@ qTranslateConfig.js={
var id = 'menu-item-'+matches[1];
var li = document.getElementById(id);
if(li)
addMenuItemHooks(li,form);
addMenuItemHooks(li);
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion admin/js/edit-nav-menus.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions admin/js/edit-options-general.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
Loaded for /wp-admin/options-general.php
/* loaded in
/wp-admin/options-general.php
*/
qTranslateConfig.js={
addContentHooks: function(qtx)
{
var forms=document.getElementsByTagName('FORM');
if(!forms.length) return false;
var form=forms[0];
//var forms=document.getElementsByTagName('FORM');
//if(!forms.length) return false;
//var form=forms[0];

qtx.addContentHookById('blogname',form,'[');
qtx.addContentHookById('blogdescription',form,'[');
qtx.addContentHookById('blogname','[');
qtx.addContentHookById('blogdescription','[');

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion admin/js/edit-options-general.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions admin/js/edit-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ qTranslateConfig.js={
var form=document.getElementById('post');
if(!form) return false;

qtx.addContentHookByIdC('title',form);
qtx.addContentHookByIdC('excerpt',form);
qtx.addContentHookByIdC('title');
qtx.addContentHookByIdC('excerpt');

var wpEditorAreas=form.getElementsByClassName('wp-editor-area');
for(var i=0; i<wpEditorAreas.length; ++i){
var wpEditorArea=wpEditorAreas[i];
qtx.addContentHookC(wpEditorArea,form);
qtx.addContentHookC(wpEditorArea);
}

qtx.addContentHookByIdC('attachment_caption',form);
qtx.addContentHookByIdB('attachment_alt',form);
qtx.addContentHookByIdC('attachment_caption');
qtx.addContentHookByIdB('attachment_alt');

qtx.addCustomContentHooks(form);
qtx.addCustomContentHooks();

qtx.addDisplayHooksByClass('gallery_caption',form);

Expand Down Expand Up @@ -94,7 +94,7 @@ qTranslateConfig.js={
}
this.setSlugLanguage(qtx.getActiveLanguage());

qtx.addContentHooksTinyMCE();
//qtx.addContentHooksTinyMCE();// always called in the framework

/**
* @since 3.2.4 Multiple sets of Language Switching Buttons
Expand Down
2 changes: 1 addition & 1 deletion admin/js/edit-post.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions admin/js/edit-tag-exec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* executed for
/wp-admin/edit-tags.php?action=edit
*/
jQuery(document).ready(
function(){
var qtx = qTranslateConfig.js.get_qtx();

var form = document.getElementById('edittag');
if(!form) return false;

var h=qtx.addContentHookByIdB('name');
if(!h) return false;

qtranxj_ce('input', {name: 'qtrans_term_field_name', type: 'hidden', className: 'hidden', value: h.name }, form, true);

//var default_name=h.contents[qTranslateConfig.default_language];
var default_name=h.fields[qTranslateConfig.default_language].value;
qtranxj_ce('input', {name: 'qtrans_term_field_default_name', type: 'hidden', className: 'hidden', value: default_name }, form, true);
});
1 change: 1 addition & 0 deletions admin/js/edit-tag-exec.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions admin/js/edit-tag.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* loaded in
/wp-admin/edit-tag.php?action=edit
/wp-admin/edit-tags.php?action=edit
*/
qTranslateConfig.js={
addContentHooks: function(qtx)
{
var prefix, form = document.getElementById('edittag');
if(!form) return false;

var h=qtx.addContentHookByIdB('name',form);
var h=qtx.addContentHookByIdB('name');
if(!h) return false;

qtranxj_ce('input', {name: 'qtrans_term_field_name', type: 'hidden', className: 'hidden', value: h.name }, form, true);
Expand All @@ -16,7 +16,7 @@ qTranslateConfig.js={
var default_name=h.fields[qTranslateConfig.default_language].value;
qtranxj_ce('input', {name: 'qtrans_term_field_default_name', type: 'hidden', className: 'hidden', value: default_name }, form, true);

qtx.addContentHookByIdC('description',form);
qtx.addContentHookByIdC('description');

qtx.addDisplayHookById('parent');

Expand Down
2 changes: 1 addition & 1 deletion admin/js/edit-tag.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions admin/js/edit-tags-exec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* executed for
/wp-admin/edit-tags.php (without action=edit)
*/
jQuery(document).ready(
function(){
var qtx = qTranslateConfig.js.get_qtx();

var form = document.getElementById('addtag');//AjaxForm
if(!form) return;

var h=qtx.addContentHookByIdB('tag-name');
if(!h) return;

qtranxj_ce('input', {name: 'qtrans_term_field_name', type: 'hidden', className: 'hidden', value: h.name }, form, true);

//var default_name = h.contents[qTranslateConfig.default_language];
var default_name = h.fields[qTranslateConfig.default_language].value;
qtranxj_ce('input', {name: 'qtrans_term_field_default_name', type: 'hidden', className: 'hidden', value: default_name }, form, true);

//var theList=document.getElementById('the-list');

//remove "Quick Edit" links for now
jQuery('#the-list > tr > td.name span.inline').css('display','none');

//make page to reload page on submit of a new taxonomy
var submit_button = document.getElementById('submit');
if(submit_button){
submit_button.addEventListener('click',function(){
setTimeout(function(){window.location.reload();},800);
//addDisplayHookRows(theList);//does not work, because the updates on theList has not yet propagated
});
}

});
1 change: 1 addition & 0 deletions admin/js/edit-tags-exec.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions admin/js/edit-tags.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* loaded in
/wp-admin/edit-tag.php
/wp-admin/edit-tags.php
*/
qTranslateConfig.js={
addContentHooks: function(qtx)
{
var form = document.getElementById('addtag');//AjaxForm
if(!form) return false;

var h=qtx.addContentHookByIdB('tag-name',form);
var h=qtx.addContentHookByIdB('tag-name');
if(!h) return false;

qtx.addContentHookByIdC('tag-description',form);
qtx.addContentHookByIdC('tag-description');

qtranxj_ce('input', {name: 'qtrans_term_field_name', type: 'hidden', className: 'hidden', value: h.name }, form, true);

Expand Down
2 changes: 1 addition & 1 deletion admin/js/edit-tags.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions admin/js/nav-menus-exec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* executed for
/wp-admin/nav-menus.php
*/
jQuery(document).ready(
function(){
var qtx = qTranslateConfig.js.get_qtx();

var addMenuItemHooks=function(li)
{
qtx.addContentHooksByClass('edit-menu-item-title',li);
qtx.addContentHooksByClass('edit-menu-item-attr-title',li);
qtx.addContentHooksByClass('[edit-menu-item-description',li);//must use '[:]' separator style

qtx.addDisplayHooksByClass('menu-item-title',li);
//qtx.addDisplayHooksByClass('item-title',li);
qtx.addDisplayHooksByTagInClass('link-to-original','A',li);
}

var onAddMenuItem = function(menuMarkup){
var rx = /id="menu-item-(\d+)"/gi;
while((matches = rx.exec(menuMarkup))){
var id = 'menu-item-'+matches[1];
var li = document.getElementById(id);
if(li) addMenuItemHooks(li);
}
}

if(wpNavMenu){
var wp_addMenuItemToBottom = wpNavMenu.addMenuItemToBottom;
if( typeof wp_addMenuItemToBottom == 'function'){
wpNavMenu.addMenuItemToBottom = function( menuMarkup, req ) {
wp_addMenuItemToBottom( menuMarkup, req );
onAddMenuItem(menuMarkup);
};
}
if( typeof wp_addMenuItemToTop == 'function'){
wpNavMenu.addMenuItemToTop = function( menuMarkup ) {
wp_addMenuItemToTop( menuMarkup );
onAddMenuItem(menuMarkup);
};
}
}

var onLanguageSwitchAfter = function(lang){
if(wpNavMenu){
if( typeof wpNavMenu.refreshKeyboardAccessibility == 'function'){
wpNavMenu.refreshKeyboardAccessibility();
}
if( typeof wpNavMenu.refreshAdvancedAccessibility == 'function'){
wpNavMenu.refreshAdvancedAccessibility();
}
}
}
onLanguageSwitchAfter();

qtx.addLanguageSwitchAfterListener(onLanguageSwitchAfter);
});
Loading

5 comments on commit fa87157

@pedro-mendonca
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnclause
You've changed the section titles in all languages from "General Settings" to "General", "Advanced Settings" to "Advanced" and "Custom Integration" to "Integration". This is fine.
But as you changed this in all languages, the translations should be reviewed also. No one will probably notice the original english strings is differente unless they inspect commits.
I think you should always mark this changed strings as fuzzy so that translators know they have to pay atention to it, or else it goes down under all the strings that appear to be translated a long time ago.
I'm going to simplify the pt_PT correspondent strings, but it's a good idea to go back to all languages and mark those as fuzzy.

@pedro-mendonca
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just made the PL #163 to correct this in pt_PT

@johnclause
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was not sure about the best way. If I mark it fuzzy, then they are not written into .mo, but having previous translation is better than nothing. I guess, I can adjust .po with 'fuzzy' now, after .mo is already updated?

@pedro-mendonca
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I mark it fuzzy, then they are not written into .mo, but having previous translation is better than nothing.

I disagree, it's not nothing, it's a pretty well noticable string to be translated right away. Having a previous incorrect translation means that it won't be marked to be translated. I would prefer a string not translated than a bad translated one.

I guess, I can adjust .po with 'fuzzy' now, after .mo is already updated?

Yes, for the benefit of every translator that didn't notice that change, you should mark those changed strings as fuzzy. It's not different than when you have new strings to translate, it usually take a few commits to translators fill it all.

@johnclause
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant .mo must still have old translation until new .mo is generated, which is now achieved. I updated .po files with 'fuzzy' line on last push.

Please sign in to comment.