Symfony change website's language - symfony

I am building a website using Symfony. I am wondering how can I change the language of my website by pressing a button.
Say I have two links in the footer (English and German) and when I click any of them, the whole website and all future views I access will remember my choice of language.
There are numerous websites who have this facility and I am wondering how can I achieve this goal.
Thank you!

Recommend checking out the jms/i18n-routing-bundle. You can use buttons or links to change the locale (language) and once changed the site will remain on that language. Just a bit of advice, use the "prefix" strategy when you set it up so that your site's urls will always be domain.com/language/.....
You'll have to learn how to use the translation bundle and setup translation files as well as having to learn how to setup Twig for translations, using the translation in your services and forms, but once you get the hang of it, it is really easy but time consuming.

Related

Starting out with Wordpress - Creating a text book application

I am basically a Java/Oracle guy. I was told that it is possible to build any simple Web app with Wordpress.
I successfully installed Wordpress on my machine and am trying to create a text book app. For this purpose, it is an employee database, with fields Name, Address, Department, Designation. I need to have the usual create/edit/search/delete functionality.
The problem with Wordpress is, I really don't know where to start, or how to customize pages.
Am I barking up the wrong tree? Is Wordpress more for blogging/news style websites than for traditional database applications? If not, how do I customize Wordpress to create the application described above?
Thanking you in advance.
Viability
Wordpress is a great system for many different applications, not just blogging/news style websites.
There are many articles out there that go in to great depth on this, but here is a good one right of: http://torquemag.io/app-dev/
Getting Started
As with any project, there clearly is more than one way to skin this cat, but right off, here are some basics I'd recommend you check out about customizing your Wordpress install:
How to create a child theme: http://codex.wordpress.org/Child_Themes
How to create a page template: http://codex.wordpress.org/Page_Templates
How to develop a plugin: http://codex.wordpress.org/Writing_a_Plugin
Plugins
In addition to this, i'd highly recommend a few plugins, which will help make things easy for you:
Advanced Custom Fields
•Makes it really easy to add Custom Fields, to allow you to store custom information, associated with a post, page, taxonomy, user etc. really easy to use, has great documentation and support, as well as a really nice UI. I'd also recommend paying the 25 bucks for the repeater field, which is really useful.
Custom Post Type UI
•Easy way to add custom post types to your wordpress instal, the default post types are: posts, links, pages. With this plugin you can add custom post types for things like say, employees.
Conclusion
In conclusion, I don't think you're barking up the wrong tree, I think that wordpress can be a simple elegant solution for a web application, and can easily be molded into almost anything you can come up with.
For developed such kinds of application you need to develop a wordpress plugins. You can handle any kinds of database operation there. You can add create/edit/search/delete functionality

Migating from CakePHP to Drupal, functionality question

(I've posted this on the drupal forum too btw)
I'm converting the company websites to use Drupal, or at least trying to check that its going to be the best way forward. I have a background in PHP development, and I'm currently using the CakePHP framwork. I've built this site (not my design) and I can see how to replicate most of the functionality using Drupal, most likely using the CCK module.
http://preview.tinyurl.com/yk6u8mt
As you can see from the homepage:
A user chooses a country.
The country is passed using an ajax call to a script that decides which phone is best based on 'in country' network coverage.
A div is shown recommending the visitor the best phone for that country.
I'm wondering how to go about this in Drupal, I'm definitely not after a step by step guide, I just want to know if this kind of thing is possible with Drupal, and what approach to use.
If someone can help that would be superb. Thanks.
Okay, so you've got a path you're defining in hook_menu, which is where your form is being presented - or else you've got it set up as a webform in a node, that could work too.
Either way, in your form you're going to be using AHAH - check out http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#ahah and http://drupal.org/node/348475 .
Basically, you're going to define another path in hook_menu that's of type MENU_CALLBACK, and which will receive the country as input, and then will return the div that you'll display on the screen.
One core example of AHAH that may be useful to you is where you're entering a password and it lets you know if the password is secure enough - check that out.
Edit: There's also some good examples at http://drupal.org/project/examples.
I would look into using CCK and views. you can set up filters for the views. If filters don't work, you have the ability to include php code. I have also successfully added jquery code in the header of a view through which I was then able to have my view filtered by what is typed in a text box.
Coming from CakePHP using Drupal is a pain in the a** - even more for developers.
It's application structure might be designed to ease extensibility but this only means you have a system to enable your own plugins and themes.
While modules are basically the M+C-part the themes are the V-part of an MVC-application. The problem is that this seperation is not very strict in Drupal - in fact you have to break it sometimes in order to make things work (e.g. you have to include a theme_mymodule_myfunction() into your module as default output which you then can override with your theme using mytheme_mymodule_myfunction() ) And don't even bother looking for classes ( see http://drupal.org/node/547518 ).
Also there is no real link from a module to a theme. On many occations this is a good thing as you can switch modules and themes seperatly without creating a problem. For application builders coming from CakePHP (or any other framework) you often feel a lack of "wholesomeness" - you create parts for a base software and have to live with it's drawbacks.
IMHO I wouldn't recommend this step. Drupal is fine if you have to manage a website and might add a few modules to add neccessary value (image gallery etc.) but I definetly don't recommend it as a base for a customized web-app.

How to build website with two speaking language (Arabic and English)?

I am beginner in web designing, I using CLASSIC ASP for web development.
My client need his website in two languages (Arabic and English).
What is the best way for develop website in multiple language?
I read some information from website's :-
Create website in two lanuages. for example (www.example.com/English/)and (www.example.com/Arabic/)
2.Use transilaters(Google,SpeakFish,etc..) for your default website.
Anyone can help me for this which is the suitable way for develop website in multiple languages?
Any reference or any links?
hoping your help
There are several methods:
your first method - create two different sites - has as advantage that the texts can be custom tailored for each language
create a single site, but display every text with a function that knows the current language and shows the text in one or the other - will be easier to update, but a little harder to change all translations
I would say don't use automatic translators - they do a lousy job. Better let a human do this.
Build a single website using a CMS that does multilanguage out of the box, or supports plugins for multilingual sites (F.A. Joomla + JoomFish).
Online translators always create a really terrible reading experience, so please get a (possibly trained) human translator to covert the texts for you.

Possible pitfalls on a multilingual Drupal site?

I'm about to embark on a journey to build a multilingual Drupal site, where I will most likely have to use Views, Panels and Taxonomy pretty heaily. I am a bit worried about the new-node-for-every-language approach, especially using Panels.
So far I've gotten it to work similarly to what I want by not having multilingual support for the Panels content-type, and fetching content that is from Current language and language neutral . This seem to work as expected, but I'm seeing some problems with it. There might be the occasion that I will have to have a language specific Panel (not published in English for example). If I need to have all my Panels multilingual, there seems to be alot of work to place the nodes for every column in every page in every language. I'm thinking I could possibly solve this by fetching the content with some kind of view with arguments, but this will most likely also lead to alot of work.
Is there some proper way of doing what I'm attempting to describe, or do I have alot of seemingly unnecessary work to expect?
I assume you have i18n module (http://drupal.org/project/i18n) and Views module installed. Then you can create a view for each language - one can choose language in "Filter" section of the view definition.
Once you have views, then you can link them to menus or blocks. The problem is you must have a separate version of block or menu for every language, with a proper view associated - Drupal is choosing proper language version itself according to the configuration (typically content type set in a browser). I haven't found any easier way of doing that.
Fortunately preparing multilingual content is not that hard thanks to the "transalte" functionality for nodes after enabling i18n module, so new node for every page is something one can live with.
BTW you are right that the way Drupal is doing i18n is not the best solution one can think of. I am having hard time with it sometimes.
Well there are some serious issues with views over translating taxonomy terms or vocabs names. This could be resolved with some extra modules or / and custom PHP code inside views fields. Usually 70% of modules does not support translation, then you need to patch them to support it. While others does have translation possibility, but it could be two possible ways: uses variables table to hold different translations UI dependent (need to switch to other language to find a string) or uses translation field tables to utilize "translation interface" from admin menu.
So far that's it :)
I wish you luck!

How to make a fully customizable hosted ASP.NET MVC application

This is related to my previous question regarding serving static html files but that doesn't seem to be a good solution,
I want to make a fully customizable ASP.NET MVC application as a hosted service. See allowing the user to customize the look/feel of their own page but it is still dynamic, meaning the data is hosted in the central database.
I looked at the "theme" or "skin" in ASP.NET but I don't think it is customizable enough. It seems only the developer can add new themes. I want to have something like the theme editor in WordPress so you can just change the look in anyway you want from a web-based interface.
I wonder how the theme files will be stored for the popular blogging platform? Are they stored in database or a file in filesystem? I prefer to store it in database, because if it is in filesystem it will have scalability problem. Each user will be tired to a particular web server and I have to determine how much disk space for each webserver.
I thought of doing something like the old MovableType, to generate static HTML when you add new post. This solution is problematic as well, because the flexibility depends on the complexity of the template engine.
Ideas? Suggestions?
Thanks!
"Fully customizable" is the most elusive of the white whales ;-)
I see your question is old, but none the less;
first I'd recommend defining some very clear,
and cohesive rules governing just what the "bottom-line" is,
or an inheritable template of sorts.
You get a pretty good impression of what might be useful during developing, I'd guess.
Next; just what and how is the customizing supposed to be presented and achieved?
The inherit ASP.NET custom custard, Web Parts, need quite some cajoling to behave in MVC views :
https://stackoverflow.com/questions/1106629/using-webparts-in-an-mvc-application
If you're leaning more towards customizable appearance (theme's n' skin's),
how about having a CSS file for each user, saves like a charm as VARCHAR(MAX), and can easily be inserted
in e.g. your Master Page's head.
The theme editor in WordPress simply allows you to edit Theme PHP files...
You can do it exactly like in wordpress but instead of editing PHP files your theme is composed of a set of aspx\ascx files without code-behinds...

Resources