Plone: extracting i18n strings from dexterity xml models - plone

I'm working with dexterity xml models and am looking for a way to extract i18n strings from my models. It doesn't look like i18ndude or infrae.i18nextract do this. As a result all the translations strings in my xml models don't show in the generated .pot files.
Some of the models have more than 30 fields, so manual extraction is becoming tedious.

i18ndude do extract i18n messages from model files without any issues; check you're including your domain and marking the strings to be extracted.
see our i18n script and check compare, as an example, collective.cover's model with yours:
<?xml version="1.0" ?>
<model xmlns="http://namespaces.plone.org/supermodel/schema"
xmlns:form="http://namespaces.plone.org/supermodel/form"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="collective.cover">
<schema>
<field name="template_layout" type="zope.schema.Choice" form:widget="collective.cover.widgets.selectpreview.SelectFieldWidget"
form:omitted="z3c.form.interfaces.IEditForm:true">
<description i18n:translate=""
>Choose one of the predefined layouts</description>
<title i18n:translate="">Layout</title>
<vocabulary>collective.cover.AvailableLayouts</vocabulary>
<default>Empty layout</default>
</field>
<field name="cover_layout" type="zope.schema.Text"
form:omitted="z3c.form.interfaces.IForm:true
z3c.form.interfaces.IAddForm:true
z3c.form.interfaces.IEditForm:true">
<description i18n:translate=""
>The layout to be used to render groups and tiles</description>
<title i18n:translate="">Cover Layout</title>
</field>
</schema>
</model>

Related

How to set a default for a zope.schema.list of a dexterity content type?

This is the definition of a dexterity content type in Plone:
<schema>
<field name="categories" type="zope.schema.List">
<description>Each line one category</description>
<required>True</required>
<title>Categories</title>
<default>[u'General', ]</default>
<value_type type="zope.schema.TextLine"></value_type>
<missing_value>()</missing_value>
</field>
</schema>
How does the default value has to be declared? I would expect that a list has to be provided in this way above. But this is not working. Any suggestions?
You are not supposed to provide a manually serialized list, just create a list of XML elements. Use the following format:
<default>
<element>General</element>
<element>Specific</element>
</default>
Hint: the easiest way to find the right format is to use the Dexterity inline schema editor, so you can set your default value in the UI, and then you just need to switch to "Edit XML Field model" to get the resulting XML source.

Web Deploy parameterization of an XML config file where settings are embedded in CDATA elements

During MSDEPLOY.EXE deployment, I am trying to squirt a parameter into an XML configuration file but the configuration values are stored in CDATA elements. Here are the contents of the file, called paths.xml:
<?xml version="1.0" encoding="UTF-8"?>
<course>
<questionnaires><![CDATA[https://www.site.com/somepage.asp]]></questionnaires>
</course>
I need to transform that URL into something different, but I can't figure out the correct XPATH and syntax for my parameters.xml file, here is what I've got now:
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<parameter name="QuestPath" description="Questionnaires path" defaultValue="<questionnaires><![CDATA[https://www.foo.com/somepage.asp]]></questionnaires>" tags="">
<parameterEntry kind="XmlFile" scope="paths.xml$" match="/course/questionnaires" />
</parameter>
</parameters>
I had very little luck referencing the CDATA element to replace it, so you can see I'm now trying to replace the entire questionnaire element including its CDATA contents. I had to do some escaping of the embedded angle-brackets so parameters.xml wasn't rejected due to invalid XML format.
Now, the resultant paths.xml ends up like:
<?xml version="1.0" encoding="UTF-8"?>
<course>
<questionnaires>https://www.foo.com/somepage.asp</questionnaires>
</course>
So, something has resolved the CDATA element down to its contents only, and CDATA no longer appears in paths.xml which I assume will cause the program that reads it to fail. Help!
Okay - I found a much simpler solution. In conjunction with the developer involved in housing this config XML file on our server, we changed it so the elements just contain the raw URLs, completely dispensing with the CDATA structures.
After testing that the consuming application still appeared to work fine, we agreed they were not needed and therefore I was able to do normal XmlFile replacements on nodes referenced like:
...match="/course/questionnaires/text()"

What should I use as the XLIFF original file in Symfony 2?

In Symfony 2's documentation regarding translations all of the XLIFF examples appear to use file.ext as the original file attribute. From XLIFF 1.2's documentation:
Original file - The original attribute specifies the name of the original file from which the contents of a element has
been extracted.
In Symfony 2's case I don't belief we're actually extracting any contents for translation, but the original attribute is required. The usage of file.ext is never explained in Symfony 2's documentation, whether it is simply a place holder and ignored, or whether it needs to point to an actual file. My best guess is that it is ignored by Symfony 2, but I haven't had a chance to do any tests or dig around in the code.
Second question: Would it be appropriate to specify a default set of translations, e.g. messages.default.yml and use this as the original file from which the XLIFF translations are derived?
XLIFF seems a little bit like overkill when it comes to translations for use with web applications...
Although original attribute of <file> is required in Xliff 1.2 spec and schema, you can ignore it and have a dummy string as its value so that your file passes schema validation.
One of the common uses of this property is when the strings from multiple documents (.properties files, gettext files, etc.) are extracted and reformatted as Xliff trans-units so that the strings from each individual file are placed under a respective individual <file> tag. original attribute can be used to keep the original filenames in an Xliff file with multiple <file> tags:
<?xml version="1.0" encoding="utf-8" ?>
<xliff version="1.1" xml:lang='en'>
<file source-language='en' target-language='de' datatype="plaintext" original="Sample.po">
...
<body>
<trans-unit id="1" restype="button" resname="IDC_TITLE">
<source>Title</source>
</trans-unit>
<trans-unit id="2" restype="label" resname="IDC_STATIC">
<source>&Path:</source>
</trans-unit>
...
</file>
<file source-language='en' target-language='de' datatype="plaintext" original="Sample.properties">
<trans-unit id="1" restype="label" resname="IDC_LABEL">
...
</body>
</file>
</xliff>
I agree that using Xliff for localizing small web applications can often be a bit of an overkill, but this format is arguably the only industry standard file format for localization data interchange at the moment. This makes it very popular with large scale localization implementation either simple source/target-structured files or heavily customized and tailored ones like those used in Translation Management Systems like SDL Idiom Worldserver.
Additionally, there is compatibility between Xliff and other standard file formats of OAXAL family.

Share Localization

I was able to localize my Alfresco Model (plus constraints lists) by following these rules :
http://wiki.alfresco.com/wiki/Data_Dictionary_Guide#Model_Localization
But I would like to know if there is something similar for Share?
Do we only have to use the "label-id" attributes without worrying of any convention?
Is it better to use :
label.companyName=Company name
or something like
sop_sopModel.field.sop_companyName.title=Company Name
or anything else ?
I didn't see any recommandation on the wiki.
Here is an example of label-ids I don't know how to format.
This is a part of my share-config-custom.xml file.
I know this is not really important but I would like to do things properly.
<config evaluator="aspect" condition="sop:company">
<forms>
<form>
<field-visibility>
<show id="sop:companyName" />
<show id="sop:companyAddress" />
</field-visibility>
<appearance>
<set id="sopPanel" appearance="bordered-panel" label-id="???" />
<field id="sop:companyName" label-id="???" set="sopPanel" />
<field id="sop:companyAddress" label-id="???" set="sopPanel" />
</appearance>
</form>
</forms>
</config>
You don't normally need to use the label-id attribute. If your model definition has a message bundle associated with it then the correct labels for your current locale will come through from the repository automatically.

insert new item in sharepoint list from flex

i m trying to insert new item on sharepoint list from flex using sharepoint-as3-connector (http://code.google.com/p/sharepoint-as3-connector). but i m getting following error.
Response XML:<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<UpdateListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<UpdateListItemsResult>
<Results>
<Result ID="1,UpdateList.NEW">
<ErrorCode>0x8102000a</ErrorCode>
<ErrorText>Invalid URL Parameter
The URL provided contains an invalid Command or Value. Please check the URL again.
below is the header made in soap URL.
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>
TestList
</listName>
<updates>
<Batch OnError="Continue">
<Method ID="1" Cmd="UpdateList.NEW">
<Field Name="ows_LinkTitle">
222222
</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
please help!
The error message is spot on: you are specifying an invalid command in the Cmd attribute of the Method element.
Per the MSDN article for the Method element, valid values for Cmd are:
Delete
New
Update
I have no experience with the "sharepoint-as3-connector", and I suppose it's there to make your life easier. But it's probably worth reviewing the MSDN documentation for the Lists web service (and specifically the UpdateListItems method) so you know what SharePoint is expecting. SharePoint is a delicate flower that cannot be handled harshly; you must know exactly what it wants to keep it happy.
A good walkthrough on MSDN: How to: Update List Items.

Resources