Wagtail 2.12 translations problem with wagtail_localize and StreamField - localization

I am using wagtail built-in translations system with wagtail_localize.
For StreamFields with nested content, only external content is available for translation.
Look at this example:
class Carousel(blocks.StructBlock):
title = blocks.CharBlock(label='Titolo')
text = blocks.RichTextBlock(label='Testo')
items = blocks.ListBlock(blocks.StructBlock([
('tab_label', blocks.CharBlock(label='Testo visualizzato sulla tab')),
('title', blocks.CharBlock(label='Titolo')),
('text', blocks.RichTextBlock(label='Testo')),
('photo', ImageChooserBlock(label='Foto')),
('page', QuickPageLinkBlock(required=False)),
('color', NativeColorBlock(default="#085083", label = 'Colore per il titolo')),
]), label = 'Lista slide')
class Meta:
icon='snippet'
label = 'Carosello'
template = 'blocks/carousel.html'
Only title and text are available for translations, but not all the items.
I also need to translate items. How can i solve?
Moreover it seems that linked pages contained in snippets (in pages it works) cannot be translated, but I need to change the link to the correct language page.
Can someone help me?
Thanks,
Sabrina

I recommend using a StreamBlock instead of ListBlock for items.
The content of StreamBlock is translatable. I don't think ListBlocks can be translated yet (see here)
# Do not do this:
items = blocks.ListBlock(blocks.StructBlock(...))
# Do this instead:
items = blocks.StreamBlock([('item', blocks.StructBlock(...))])

Related

How to localize the Autodesk Forge Viewer DiffTool extension

We are using the Autodesk Forge Viewer DiffTool extension, but we need to change one of the texts:
Every tutorial shows how add localization to your own extension, but I couldn't find how to change a translation in an existing extension you are using.
Moreover, without knowing what the translation key is, I would have "guess" it, which isn't really great either.
So, how do I change the translation for this text?
There is no supported way to hook into the translation service of the Viewer to change the text. If the translation is wrong, please let us know, and we can fix that on our side.
If you want to change the text for some other reasons, then one thing you could do is wait for the initialization of the extension's UI and change the button's content using DOM APIs:
let extensionConfig = {}
extensionConfig['mimeType'] = 'application/vnd.autodesk.revit'
extensionConfig['primaryModels'] = [model1]
extensionConfig['diffModels'] = [model2]
extensionConfig['diffMode'] = 'overlay'
extensionConfig['versionA'] = '2'
extensionConfig['versionB'] = '1'
extensionConfig['onInitialized'] = () => {
let button = document.getElementById("diffFacetsRemovedButton");
let label = button.nextSibling;
label.innerHTML = label.innerHTML.replace("Odebrat", "Něco jiného");
}
viewer.loadExtension('Autodesk.DiffTool', extensionConfig);

Polymer-Dart 1.0.0-rc.x multiple instances of custom element causes conflict

I built a custom element which I've added three times on my website.
<custom-element id="t1"></custom-element>
<custom-element id="t2"></custom-element>
<custom-element id="t3"></custom-element>
For some reasons, when I click something in the second or third element, the action is performed on the first one. E.g. I add a new DIV inside my custom element on an onClick event but the DIV is not added to the parent element, it's added to another instance. What is going on? Is this because Polymer dosent use shadow DOMs any longer? At least for me it seems like it's not using shadow DOMs anymore. Or is this Polymer-Dart related?
If
_outerCircle = querySelector('#outer-circle');
_innerCircle = querySelector('#inner-circle');
_more = querySelector('#more');
_bulletPrefab = querySelector('#bullet-prefab');
and
_outerCircle = this.querySelector('#outer-circle');
_innerCircle = this.querySelector('#inner-circle');
_more = this.querySelector('#more');
_bulletPrefab = this.querySelector('#bullet-prefab');
produce different results the issue is caused by your imports.
If you import dart:html without a prefix document.querySelector() is executed instead of this.documentSelector().
I always import dart:html with a prefix to avoid this confusion.
With
import `dart:html` as dom;
dom.querySelector(...);
searches the document and
querySelector(...);
searches the children of the current element.
See What are the different ways to look up elements in Polymer 1.0 for more details.
I fixed the bug.
Here the code which didn't work:
_outerCircle = querySelector('#outer-circle');
_innerCircle = querySelector('#inner-circle');
_more = querySelector('#more');
_bulletPrefab = querySelector('#bullet-prefab');
and here the code which does:
_outerCircle = this.querySelector('#outer-circle');
_innerCircle = this.querySelector('#inner-circle');
_more = this.querySelector('#more');
_bulletPrefab = this.querySelector('#bullet-prefab');

How to add page numbers to the header of a word document using Delphi xe5

I would like to be able to add the page numbers in a word document to the header.
I have found some links that display the code in visual basic, but no matter what i try, i keep getting errors. It keeps telling me the either "sections" or "headers" or "footers" is not a supported automation object.
Any help would realy be great. Thank You.
Links:
http://blogs.technet.com/b/heyscriptingguy/archive/2006/05/10/how-can-i-add-centered-page-numbers-to-the-footer-of-a-word-document.aspx
http://msdn.microsoft.com/en-us/library/office/ff194253(v=office.14).aspx
I Tried addapting the link's code with no success:
wrdDoc.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).PageNumbers.Add
and if possible please how to allign the page number right.
Use [] instead of () for indexes
//Headers[wdHeaderFooterPrimary] = Headers[1]
//Add possible values:
//wdAlignPageNumberCenter = 1
//wdAlignPageNumberInside = 3
//wdAlignPageNumberLeft = 0
//wdAlignPageNumberOutside = 4
//wdAlignPageNumberRight =2
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(1); //example with center alignment
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(2); //example with right alignment

How to force BE users to paste as plain text in TYPO3 6.x?

CMS users tend to paste anything into CMS text editors. To prevent website destruction - and as log as there's no non-wysiwyg editor (like markitup) for TYPO3, I would like to as least have some good old "force plain text paste" in place.
TYPO3's RTE has a button "pastetoggle, pastebehaviour, pasteastext". But I haven't managed to configure it so it's always active.
Also, there's an extension ad_rtepasteplain, but it produced no result in TYPO3 6.1.
Is there a usable way to implement paste-as-plain-text for TYPO3 6.x?
[EDIT]
I found (for user TSConfig)
setup.default.rteCleanPasteBehaviour
setup.override.rteCleanPasteBehaviour
as well as (for page TSConfig)
buttons.pastetoggle.setActiveOnRteOpen
buttons.pastetoggle.hidden
... none of which I got running yet. If that's the way to go: is there a working tutorial?
Got it. This is my current setup
RTE.default {
enableWordClean = 1
removeTrailingBR = 1
removeComments = 1
removeTags = center, font, o:p, sdfield, u
removeTagsAndContents = link, meta, script, style, title
hidePStyleItems = h5,h6,pre,address,div
// buttons
showButtons = chMode, formatblock, insertcharacter, removeformat, unorderedlist, orderedlist, outdent, indent, link, copy, cut, paste, showhelp, about,line, bold,pastetoggle, pastebehaviour, pasteastext
buttons.pastetoggle.setActiveOnRteOpen = 1
buttons.pastetoggle.hidden = 1
}
as well as setup.override.rteCleanPasteBehaviour=pasteStructure or plainText in user TSConfig

How do I disable Transformations in TYPO3 RTE Editor?

I created a custom extension for TYPO3 CMS.
It basically does some database queries to get text from database.
As I have seen, TYPO3 editor, transforms data before storing it in database so for example a link <a href="....." >Link</a> is stored as <link href>My Link Text</link> and so on for many tags like this.
when I query data from DB, I get it as it is stored in DB (<link href>My Link Text</link>)
so links are not displayed as they shoud. They display as normal text..
As far as I know there are two ways to go:
disable RTE transformations (how to do that?)
use lib.parseFunc_RTE (which i have no Idea how to configure it properly)
any idea?
thanks.
I guess you're not using Extbase and Fluid? Just as a reference, if you are using Extbase and Fluid for your extension you can render text from the RTE using Fluid:
<f:format.html>{bodytext}</f:format.html>
This uses lib.parseFunc_RTE to render the RTE text as HTML. You can also tell it to use a different TypoScript object for the rendering:
<f:format.html parseFuncTSPath="lib.my_parseFunc">{bodytext}</f:format.html>
Useful documentation:
parseFunc
Fluid format.html
I came across the same problem, but using EXTBASE the function "pi_RTEcssText" ist not available anymore. Well maybe it is, but I didn't know how to include it.
Anyway, here's my solution using EXTBASE:
$this->cObj = $this->configurationManager->getContentObject();
$bodytext = $this->cObj->parseFunc($bodyTextFromDb, $GLOBALS['TSFE']->tmpl->setup['lib.']['parseFunc_RTE.']);
This way I get the RTE formatted text.
I have managed to do it by configuring the included typoscript:
# Creates persistent ParseFunc setup for non-HTML content. This is recommended to use (as a reference!)
lib.parseFunc {
makelinks = 1
makelinks.http.keep = {$styles.content.links.keep}
makelinks.http.extTarget < lib.parseTarget
makelinks.http.extTarget =
makelinks.http.extTarget.override = {$styles.content.links.extTarget}
makelinks.mailto.keep = path
tags {
link = TEXT
link {
current = 1
typolink.parameter.data = parameters : allParams
typolink.extTarget < lib.parseTarget
typolink.extTarget =
typolink.extTarget.override = {$styles.content.links.extTarget}
typolink.target < lib.parseTarget
typolink.target =
typolink.target.override = {$styles.content.links.target}
parseFunc.constants =1
}
}
allowTags = {$styles.content.links.allowTags}
And denied tag link:
denyTags = link
sword = <span class="csc-sword">|</span>
constants = 1
nonTypoTagStdWrap.HTMLparser = 1
nonTypoTagStdWrap.HTMLparser {
keepNonMatchedTags = 1
htmlSpecialChars = 2
}
}
Well, just so if anyone else runs into this problem,
I found one way to resolve it by using pi_RTEcssText() function inside my extension file:
$outputText=$this->pi_RTEcssText( $value['bodytext'] );
where $value['bodytext'] is the string I get from the database-query in my extension.
This function seems to process data and return the full HTML (links, paragraphs and other tags inculded).
Note:
If you haven't already, it requires to include this file:
require_once(PATH_tslib.'class.tslib_pibase.php');
on the top of your extension file.
That's it basically.

Resources