What is the best solution for static, multilingual pages in Symfony2?
I faced the same question not long before, and since I needed a quick fix I did the following:
Used the JMSTranslationBundle, and the WebUI in it,
every static page had its own key. ( Something like: {{'staticContent_about'|trans}} ),
Since these pages contained html, but I didn't want the translators to bother with that, I made up some custom tags, and created an extension to translate that.
Example:
lorem ipsum...
lorem ipsum...
lorem ipsum...
<more>read more<more>
That would be transformed thanks to the extension to the following:
lorem ipsum...
lorem ipsum...
lorem ipsum...
<a href="some-generated-path">read more<a>
Now this solution is pretty hacky, I don't like it, and I think there must be an elegant and simple way of doing this.
To summarise, what I'm looking for is:
A way to rapidly create static pages,
It should contain a markup that is simple, so the translators could handle it,
Sandboxing the static pages, so just the allowed tags could be used,
Handling of malformed html, if for example: the translator forgot an end tag.
Thanks in advance!
Related
I'm having trouble with Emmet in Atom. When I type "lorum80" in an html file, I expect Emmet to generate 80 words of Lorum Ipsum, per its documentation. But instead, it outputs "lorum80" as a tag
<lorum80></lorum80>
Any thoughts how to fix this?
To what I found there was nothing stating in Emmet that it generates lorum.
I could recommend using the package Lorem for generating this kind of text. Has plenty of options for different formats.
I've installed the Web Essential for VS 2012 and trying out ZenCoding in ASP.net webforms project specifically in .ascx. However, it did not produce any HTML code. For example, this "ul>li*5>lorem3" produced nothing but "ul>li*5>lorem3" on the generated .aspx
Is it possible to use Zen Coding with ASP.net webforms? I can't find any answers to this problem via Google.
It sounds like you have typed "ul>li*5>lorem3" in the .aspx and compiled, expecting the expression to transform into HTML on compile. Zen Coding (aka Emmet) expressions do not compile to HTML when the .aspx is compiled, you must expand the expression yourself by setting the caret at the end of it and pressing Tab.
It will give the following result:
<ul>
<li>Lorem ipsum dolor.</li>
<li>Sit amet, consectetur.</li>
<li>Adipiscing elit fusce.</li>
<li>Vel sapien elit.</li>
<li>In malesuada semper.</li>
</ul>
Emmet only works for regular HTML tags though, no support for ASP.NET controls as far as I can see.
More information (not Visual Studio-specific, but Emmet in general): http://coding.smashingmagazine.com/2013/03/26/goodbye-zen-coding-hello-emmet/
Since a few weeks I started playing with Symfony2.
It seems a very powerful framework, but there are some things I cannot still understand.
In documentation I see that i18n (i.e. Translations) is managed by the Translator service. If I correctly understood, the main way to have a website translated is to put the collection of messages I want to translate inside the different files messages.XX.yml (XX=en,fr,it,etc...), one for each language.
This could be perfect for short texts, which possibly do not include any HTML markup. But how do you deal with long text? For instance, how can I manage the translation of a Terms Of Service or an About page?
I guess I should include different templates for each locale I want to use. Am I right?
Thanks for your help!
You can have long texts in .yml translation file as well as html tags. Put your Terms Of Service text in messages.xx.yml file like this:
TermsOfServiceText: >
<p>Here goes my Terms of service code</p>
<p>It can be put in several lines and <strong>can include html tags!</strong></p>
<p>It can also include links</p>
<p>Just make sure that you put '>' sign after your translation keyword like in the first line of this example code
and start your message in next line with double space indentation</p>
Now, in your twig template call translation with this:
{{ 'TermsOfServiceText'|trans|raw }}
raw is used to skip escaping html tags.
I don't think that different templates could be as solution. But feel free to choose what you prefer. I'll go with https://github.com/stof/StofDoctrineExtensionsBundle in particular with the Translatable behaviour.
Websites like Wordpress and Tumblr allow designers to create themes that users can select. In general how would you architect a website to be flexible enough to allow custom themes for users?
Take a look on how Django does it. Django uses a Model-View-Controller-like approach in which you use views to populate a context, and then use that context to process a template. Note that Django has its own MVC terminology.
For example, if we say that our context reads as follows (in pseudo code),
author = 'mntnoe'
title = 'My Title'
content = '<p>This is my content</p>'
we could use the following template:
<h1>{{ title }}</h1>
<div class="author">Author: {{ author }}</div>
<div class="content">
{{ content }}
</div>
Now, you are free to replace the template (or collection of templates) with another one without affecting how the site works.
Seperate content from formatting by using proper html and css. That means using css files for the style rather than inline style inside the html.
You can make several css files (themes if you wish), and switch between them using javascript.
Let your serverside technology of choice simply generate easy to adjust, by css and images, html. A great site of examples is http://www.csszengarden.com/. It emits the same html every time but uses different css and images to style it. Take a look at the html they generate to get ideas.
I receive HTML pages from our creative team, and then use those to build aspx pages. One challenge I frequently face is getting the HTML I spit out to match theirs exactly. I almost always end up screwing up the nesting of <div>s between my page and the master pages.
Does anyone know of a tool that will help in this situation -- something that will compare 2 pages and output the structural differences? I can't use a standard diff tool, because IDs change from what I receive from creative, text replaces lorem ipsum, etc..
You can use HTMLTidy to convert the HTML to well-formed XML so you can use XML Diff, as Gulzar suggested.
tidy -asxml index.html
If out output XML compliant HTML. Or at least translate your HTML product into XML compliancy, you at least could then XSL your output to remove the content and id tags. Apply the same transformation to their html, and then compare.
I was thinking on lines of XML Diff since HTML can be represented as an XML Document.
The challenge with HTML is that it might not be always well formed. Found one more here showing how to use XMLDiff class.
A copy of my own answer from here.
What about DaisyDiff (Java and PHP vesions available).
Following features are really nice:
Works with badly formed HTML that can be found "in the wild".
The diffing is more specialized in HTML than XML tree differs. Changing part of a text node will not cause the entire node to be changed.
In addition to the default visual diff, HTML source can be diffed coherently.
Provides easy to understand descriptions of the changes.
The default GUI allows easy browsing of the modifications through keyboard shortcuts and links.
winmerge is a good visual diff program