Poedit does not automatically recognise the content of a table in a database.
What is the best way to get the content of a table recognized by poedit for its translation in zend. I would like it to be done automatically....do I have to create an xml file from the database ?
You should not translate database contents with poedit. You would do that inside the database. The short answer: what you want cannot be achieved, unfortunately.
You can translate "fixed" strings and if you want to get variables, constant or database values translated, you have to do that via literal string translations, in the case poedit has to scan them:
<?php
if($var === 'foo') {
echo $this->translate('foo');
} else {
echo $this->translate('bar');
}
It's easier if you have a 1:n relation with a Translation object. The view would then pull the translation from user generated content:
<?php
echo $foo->Translation['en-us']->bar;
An example of this last possibility is provided in the Gedmo doctrine extension: https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md
Related
I am using fatfree framework with the Cortex ORM plugin, and I am trying to simply query the db and display the resulting rows within my template, so I tried:
In my controller:
$users = new \models\User;
$users->load();
$f3->set('users',$users);
/*while(!$users->dry()){
echo '<br/>'.$users->id;
$users->next();
}*/
echo \Template::instance()->render('pages/User/list.htm','text/html');
And in my template:
<repeat group="{{#users}}" value="{{#v}}">
<div>{{#v.id}}</div>
</repeat>
But the template stays blank. In the controller however, if I uncomment the while block, then I do get the expected results, but how do I get it in my template?
Also if I remove the quotes and try group={{#users}}, I get instance of class cannot be converted to string error. So how do I loop through the results from within my template?
$users->load() maps to one db row at a time.
What you need is an array containing the mappers for every row, so use $users->find() instead:
$users = new \models\User;
$f3->set('users',$users->find());
Is it possible to ignore all whitespace using regex in MongoDB queries?
My Node.js program uses Cheerio to pull data from a number of websites, parses and then stores the data in MongoDB. My database has a People collection that keys on the string field Name.
Problem occurs where one website (site-A) shows the name HTML text as John&npsp;Smith, whereas another website (site-B) shows name as John Smith. My program has two scripts, one that scrapes site-A and another to scrape site-B; both of which use the following to scrape the Name data -
var $ = cheerio.load(htmlrow);
var personobj = { name: $('td.person a').text().trim() }
Each script then uses the following MongoDb command (using the native driver) to upsert the scraped data, keying on the Name field. However, this results in two records in the People collection -
db.collection('people').update(
{ Name: personobj.name },
{ $set: { LastScan: new Date() }},
{ upsert: true },
function(){} );
Now, I tried using the regex "extended" 'x' option to query in MongoDb, but it's not working. In fact, I tried testing the 'x' option via the find operator in Robomongo, and it returns zero records. I also note that when find testing in Robomongo, and I simply type Name: "John Smith", it only returns the site-B record, the one without the $nbsp; whitespace; even though when I view the detail of both records, the name strings appear identical. (I suppose difference is caused somewhere by all the encoding/decoding going on here to scrape, parse, store, retrieve... but I'm not sure where or why).
Is it possible to ignore all whitespace when querying MongoDb using regex?
Or, is it easier to handle this in my javascript parse line, to somehow replace and 'standardize' all possible whitespace characters? (Any recommended library to do so?)
I am doing migration from html to Drupal. Using migrate module.
Here in our custom migration script i need to match all .html files from all the folder except images folder.
pass this regex to $list_files = new MigrateListFiles([],[],$regex)
Below is format of html files
/magazines/sample.html
/test/index.html
/test/format_ss1.html
/test/folder/newstyle_1.html
/images/two.html
i need to get only first 2 html files i.e., we are exluding files which ends with '_[0-9]' and '_ss[0-9]' and .hmtl files in images folder.
i have successfully done by excluding 3 and 4 but i can't able to excule .html files in images folder.
$regex = '/[a-zA-Z0-9\-][^_ss\d][^_\d]+\.html/'; //this will do for 3 and 4 files
but i need to exlude images folder..
i have tried like
$regex = '/[^images\/][a-zA-Z0-9\-][^_ss\d][^_\d]+\.html/'; // not working
Where In PHP script it will work
$regex = '~^(?!/images/)[a-zA-Z0-9/-]+(?!_ss\d|\d)\.html$~' //works in php script
can some one help me out this..
Try
/((?!images)[0-9a-zA-Z])+/[^_]*[^\d]+\.html
Matches:
/magazines/sample.html
/test/index.html
/test/folder/newstyle.html
/test/format_ss.html
Does not match:
/test/format_ss1.html
/test/folder/newstyle_1.html
/images/two.html
/images/1.html
/test/folder/newstyle1.html
/test/folder/newstyle_12.html
is this acceptable?
It's a Drupal/Migrate specific issue - the regex is only a regex for the filename (not the directory) as eventually it gets passed to https://api.drupal.org/api/drupal/includes%21file.inc/function/file_scan_directory/7
file_scan_directory($dir, $mask, $options = array(), $depth = 0)
$mask: The preg_match() regular expression of the files to find.
I think the only way to exclude certain directories is to throw a false in the prepareRow() function if the row has a path you don't require.
function prepareRow($row)
The prepareRow() method is called by the source class next() method, after loading the data row. The argument $row is a stdClass object containing the raw data as provided by the source. There are two primary reasons to implement prepareRow():
To modify the data row before it passes through any further methods and handlers: for example, fetching related data, splitting out source fields, combining or creating new source fields based on some logic.
To conditionally skip a row (by returning FALSE).
https://www.drupal.org/node/1132582
In TYPO3 6.x, what is an easy way to quickly create custom content elements?
A typical example (Maybe for a collection of testimonials):
In the backend (with adequate labels):
An image
An input field
A textarea
When rendering:
Image resized to xy
input wrapped in h2
textarea passed through parseFunc and wrapped in more markup
Ideally, these would be available in the page module as cType, but at least in the list module.
And use fluid templates.
My questions:
From another CMS I am used to content item templates being applied to the BE and the FE at the same time (you write the template for what it should do, and then there's a backend item just for that type of content element) - but that's not how fluid works - or can it be done?
Is there an extension that would handle such custom content elements (other than Templavoila)?
Or do I have to create a custom extbase/fluid extension for each such field type?
And, by the way: is there a recommendable tutorial for the new extbase kickstarter? I got scared away by all that domain modelling stuff.
That scaring domain modeling stuff is probably best option for you :)
Create an extension with FE plugin which holds and displays data as you want, so you can place it as a "Insert plugin". It's possible to add this plugin as a custom CType and I will find a sample for you, but little bit later.
Note, you don't need to create additional models as you can store required data ie. in FlexForm.
From FE plugin to CType
Let's consider that you have an extension with key hello which contains News controller with list and single actions in it.
In your ext_tables.php you have registered a FE plugin:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin($_EXTKEY, 'News', 'Scared Hello News');
When it's working fine you can add it to the list of content types (available in TCA) just by adding fifth param to the configurePlugin method in your ext_localconf.php:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'TYPO3.' . $_EXTKEY,
'News',
array('News' => 'list, show'),
array('News' => ''),
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT // <- this one
);
Next part (basing on this site) is adding your plugin to the New Content Element Wizard as noticed in TYPO3 Wiki since TYPO3 ver. 6.0.0 changed a little, so easiest way is adding something like this into your ext_tables.php:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:hello/Configuration/TypoScript/pageTsConfig.ts">');
and in /typo3conf/ext/hello/Configuration/TypoScript/pageTsConfig.ts file write add this:
mod.wizards.newContentElement.wizardItems.plugins.elements.tx_hello_news {
icon = gfx/c_wiz/regular_text.gif
title = Scared Hello News
description = Displays Scared News
tt_content_defValues.CType = hello_news
}
# Below the same for TemplaVoila
templavoila.wizards.newContentElement.wizardItems.plugins.elements.tx_hello_news {
icon = gfx/c_wiz/regular_text.gif
title = Scared Hello News
description = Displays Scared News
tt_content_defValues.CType = hello_news
}
Note that proper key tx_hello_news should be combination of lowercased tx_, $_EXTKEY and plugin name - used in registerPlugin method.
You can stop here if you are bored ;)
Bring tt_content's fields back into your CType
Above steps will cause that no typical fields will be available in the TCA for your element, so you need to copy something or create own. To see how it works just see some sample, in the backend in left menu choose ADMIN TOOLS > Configuration > TCA > tt_content > types
There you'll find all types in the system, choose the most required and copy its [showitem] node into your own. Again in ext_tables.php add this PHP array:
$TCA['tt_content']['types']['hello_news']['showitem'] = $TCA['tt_content']['types']['textpic']['showitem'];
Again: hello_news is combination of lowercased $_EXTKEY and FE plugin name...
Of course if it's required you can compose quite own set of fields, one by one by custom string:
$TCA['tt_content']['types']['hello_news']['showitem'] = '--palette--;LLL:EXT:cms/locallang_ttc.xml:palette.general;general, --palette--;LLL:EXT:cms/locallang_ttc.xml:palette.header;header';
Access the fields in Extbase Controller:
Fortunately is easiest part as you can just access it as an Array:
$currentTtContent = $this->configurationManager->getContentObject()->data;
$header = $currentTtContent['header'];
debug($currentTtContent);
debug($header);
I think http://typo3.org/extensions/repository/view/dce will do exactly what I was looking for
Tried to implement partial text search with postgresql and django,used the following query
Entry.objects.filter(headline__contains="search text")
This returns records having exact match,ie suppose checking for a match against the record "welcome to the new world" with query __contains="welcome world" , returns zero records
How can i implement this partial text search with postgresql-8.4 and django?
If you want this exact partial search you can use the startswitch field lookup method: Entry.objects.filter(headline__startswith="search text"). See more info at https://docs.djangoproject.com/en/dev/ref/models/querysets/#startswith.
This method creates a LIKE query ("SELECT ... WHERE headline LIKE 'search text%'") so if you're looking for a fulltext alternative you can check out PostgreSQL's built in Tsearch2 extension or other options such as Xapian, Solr, Sphinx, etc.
Each of the former engines mentioned have Django apps that makes them easier to integrate: Djapian for Xapian integration or Haystack for multiple integrations in one app.