Using database for Internationalization & Localization - cakephp

The CakePHP book has a section on Internationalization & Localization. Bascially what it says is Cake will generate a pot file and we have to create a .po for different language file from the pot file.
My problem is I want the user to be able to edit these localized text so instead of storing the localized text in the .po file I want to store them in the database.
So how can I store the localized text in the database?

There's a Behavior for that.
Personally I find the TranslateBehavior to be rather inflexible though, so I usually just go with a separate table connected to the main model via a belongsTo relationship which contains all the translations. I then pick the one to display in the View.

Related

Localize cakephp bake templates

I'm creating CakePHP 3 localized app and want to generate all backend part with bake for multiple languages. I'm already familiar with i18n shell and .po files, I have used cakephp/localized and it's ok. It have translations of cake core for many languages.
But one i can't get a glue is how to translate templates generated by bake? It's bunch of similar strings like
The group has been deleted
The user has been deleted
The item has been deleted
and so on. I want to translate all pattern "The {0} has been deleted" once but not for every single entity.
Am i missing something important?

Translating text direcly from DB using .po file

I've been having this problem for several days, after reseaching, I haven't found a solution.
I'm on a cakePHP 2.5.6 project, and I'm on the internationalization right now, everything seemed to work just fine, but I came across this issue:
In my DB I store several tags for my articles, the problem is that the name of the tag is given to me by a query directly from the DB, and printed using a foreach.
Here is my doubt, is there any way to translate those fields using my .po file?
I have thought some solutions but I'm trying to avoid them because I think they are just lame, such as create a new column in my tags table with the translated name in it.
CakePHP's pot files are generated for hard-coded strings in template files and elsewhere in your app. Basically anything like __('Hello'), it doesn't work if you use variables like __($var) as it needs to know the string to generate the translation files.
If the content is coming from the database you need to look at translating the database content within the database as you've suggested. Rather than create a new set of columns on your tags table you should look into using CakePHP's Translate behaviour. Cake's Translate behaviour should do what you are looking for without you needing to re-invent the wheel.

File Maker Scripting - Sending Different Attachment

Is there a way to send a mail with different PDF file to different contacts using file maker?
I am aware of sending batch emails with one attachment but I would like to send a personalize PDF for each contact which seems not so simple.
Also
Can I add PDF files to the table itself or would I have to use the path to the file?
Example:
Table 1
**Name** [James Brown] [James Blue]
**Email** [brown.j#gmail.com] [blue.j#gmail.com]
**PDFfileAttchamnet** [folder/PDF/JamesBrown.pdf] [folder/PDF/JamesBlue.pdf]
So an Email for James Brown would look like:
Dear James Brown, please see the attached file.
Attachment [JamesBrown.pdf] {actual file}
and
Dear James Blue, please see the attached file.
Attachment [JamesBlue.pdf] {actual file}
I think you can solve it by creating container field in you database and import the pdfs in it.
then you can use export Field Contents[] to export it and send it by email
Hope it useful
I would like to send a personalize PDF for each contact which seems
not so simple.
Find the records of contacts you want to include and loop among them, sending mail to each one individually (i.e. without selecting the 'Collect addresses across found set' option).
Can I add PDF files to the table itself or would I have to use the
path to the file?
You can do either, it's up to you. If the path to the file can be calculated (as in your example), you can calculate it right there in the Send Mail script step.
Note that you can also generate the PDF files during the process itself.
Do I understand correctly that you would actually like to personalize the PDF document(s)?
This is possible, maybe not very simple, but quite simple. The trick is to prepare the PDF as a form, and then fill the form fields to personalize.
PDF has a native forms data format (called FDF), which is described in ISO 32000 (as well as the older PDF specification documents provided by Adobe, as you can find in the Acrobat SDK, downloadable from the Adobe website).
FDF is a simple structured text file, which can easily be assembled using FileMaker (I have done that routinely for several catalog projects). The easiest way to get going is to open the form in Acrobat, fill in the fields, and then export the data as FDF. This gives you the pattern to "fill in the blanks".
So, you create the FDF files using Filemaker. With them you can fill the blank form and feed the saved document to the eMail system.
Which tool to use to fill the blank form depends on the volume you have to process. Acrobat is not very powerful (and you may end up in a bit of a legal gray zone, because Acrobat is not set up for being used as a service). There are applications which are made specifically for filling out forms on a server (such as FDFMerge by Appligent), or there are also several libraries which have the tools to fill out forms (iText or pdflib come to my mind). These applications also allow you to flatten the PDF, which means that there are no longer form fields, but their contents becomes part of the base.
The resulting file can now be either made to an eMail attachment, or you make it available on a server and send an eMail with the link to the file (which method you will use may depend on security and privacy regulations).

Plomino multilingual site

I've got Zope 2.13.15, Plone 4.2.0.1, LinguaPlone 4.1.3 and CMFPlomino 1.17.2
I need to make a multilingual website on Plone and am using Plomino. I see that I can translate plomino database, forms and views with LinguaPlone but not documents. I have seen the procedure on http://www.plomino.net/how-to/multilingual-applications (Multilingual applications - How to build a multilingual Plomino application) and more detailed on https://github.com/plomino/Plomino/issues/296. I'm not sure can I translate content of documents using this procedure because the mentioned tutorial states "If the text does not match any msgid from the i18n domain, it remains unchanged".
Does this mean that all the translations of the content of documents should be in the .po files or what. Can anybody clear this mechanism to me please and is this tutorial the right way to document content translation ?? At this moment I'm not sure if there is a document content translation solution for Plomino
What is the procedure to translate document content in Plomino? The tutorials are not clear to me.
At the moment there is no document content translation solution for Plomino.
The mentioned solution can be used to translate pre-defined contents (like labels in forms, computed values, etc.) but obviously it is not applicable to content freely entered by users in documents.
Nevertheless, Plomino is already used in multilingual contexts.
A basic solution is to:
create a field to store the document language,
provide a Document ID formula which will use this lang field value (so we can guess the id of any translated version from the current doc id),
implement the different actions you might need (like "Translate this doc", "Switch to language xx", etc.) as basic Plomino actions.

cakephp finding multiple images and displaying them (possibly outside webroot?)

I am currently trying to build a cakephp app that will list items from a database, and there is a field in the database named picture. This picture field contains a string which is the primary picture, so for example ABCD, and then in the images folder this is ABCD.jpg
However there is usually various extra pictures for this particular item, which may be named ABCD1 or ABCD_2 or some other such variating suffix. I had previously written some script in php which used a glob function and counted the files and outputted them.
I am seriously struggling to do this in cakephp, at the moment there is several thousand images stored in the webroot of the server in /images and I understand that cake will be looking in the webroot of the app like /app/webroot, so is it possible to view their original location? or must they be moved...
I have read a little about the file and folder classes but I am struggling to comprehend them, not sure if my brains failed me here or if this is actually a difficult concept..
my question is how would I find any files that begin with this prefix in the picture field after selecting by the id of the item, to then display all those that match for that particular item?
thanks for your help!
Not a real answer to your question but you should start making a database relationship with your pics.
Check out hasMany to make a relationship between your Article (or whatever it is) and the Picture models. Now you will not have to look for each filename, as you'll have it in your database.

Resources