How can create multilingual Django site?
Is it a good idea to create template set for each language?
How should I use that sets of templates (if it's a good idea)?
Take a look at this question: How to localize Content of a Django application
I'd say try to maintain the same template for each language. However, if you must, or if you feel it is reasonable, you can certainly use a set of different templates for certain other languages. For instance, I know that Arabic is read from right to left, so perhaps a different template is worthwhile in that case.
Related
Learning asp.net mvc and I am building a small website that will be initially in 2 languages.
10 or more pages are static pages with bold bits etc...
What is the best approach for localising these pages?
Is there a way to do it without creating a page for language that would be a no in my book.
How do you handle localisation of static pages in asp.net mvc? In asp.net there was some sort of localise control.
Any suggestions?
The way to do this is using resource files. You create an resource file for your default language and then one for each other language your site should run in.
This article describes how to do it. For example if you want english (default) and french you could create two resource files (.resx files) Website.resx and Website.fr-FR.resx. The first file for your default language, which is english and the second file for french. Both files exists from a key-value pair.
EDIT: Another interresting article describing the same idea can be found here.
I think that the best approach is still creating two files for them,
cause they are not static pages forever, they may change in future,
Or you can generalize the solution and save the text in database
for those two languages and render the correct content base on the selected culture.
They can be saved in the sense that they are pages on newsroom,
whenever you add a news you enter the text for both cultures.
I am creating a service in which I want to allow end-users to edit HTML templates for web pages that allows for access to specific "variables" for inclusion in the template.
I know that liquid was designed for this very purpose, is secure (at least relatively), and is in heavy production use. However, I find the language to be fairly complex for end-users as compared to something like Mustache.
Mustache sounds great, but I am concerned about security... has it ever been used for end-user templates?
Basically I am looking for a templating engine I can use w/ Rails for end-users that is:
Secure - will not allow the execution of code by the user... at least not on the server. Users will be allowed to insert client-side javascript.
Powerful - allows end-users to create pretty much any web page they can imagine using the supplied "variables" and within the context of #1
Simple - the syntax is clear and easy for end-users to apply
Bonus points if there is support for rendering the template syntax in javascript and other languages.
Liquid meets 1 & 2, but not 3-4. Mustache meets 2-4, but I'm not sure about #1 and that is non-negotiable.
Greatly appreciate any insights, experiences, or comments.
Mustache is fantastic for interpolation and I can't imagine it ever exposing you to server-side vulnerabilities if you're using it for Javascript evaluation. It's the simplest, most powerful option. I don't know that non-programmers would understand it, but I'm sure it's simpler than Liquid.
Another option would be to use an existing simpler user markup set like BBcode or a rich-text editing library like TinyMCE. These are much reduced in functionality, but are easier to use for average people.
What would be a good way to handle URLs on a website that offers multiple languages, but has one primary language (in my case, English).
What should be the address of the home page in English? http://example.com/? http://example.com/en/? http://example.com/english/? Other?
What should be the address of the home page in another language, say, German? http://example.com/german/? http://example.com/de/? http://example.com/deutsch/?
Would the use of language-specific subdomains be appropriate? What would you do and why?
It kind of depends on the structure of your site:
If every language is considered a completely different site, use sub-domains for the language.
This is because different sub-domains is considered different sites by many technologies. Wikipedia does this (http://de.wikipedia.org/) to separate content for different languages entirely.
I wouldn't recommend you to choose this option unless your site is very big.
If every language has its own structure, but is still considered to be versions of the same site, use a top-level "directory" for languages.
For the sake of consistency, I would say that you should also have one for the default language (and omitting it would cause a redirect to the appropriate structure.) I would recommend you to use /en/, /de/, etc. since it's short and concise, and also the standard way of indicating languages.
This is probably your best bet.
If the structure of the site is identical no matter what language it is, and only content on the pages changes depending on the language, you could also consider putting the language modifier as a parameter: /home?lang=en
Google does this, for example: http://www.google.com/search?hl=de&q=foo (they also separate languages by TLD, though.)
Away from the question of how the international URLs should be styled (as that has been covered adequately already)...
One thing that I would personally do is make the site's 'main' domain (i.e. http://example.com) redirect the user appropriately depending on the Accept-Language HTTP header passed by the browser. This is what google.com does, for example.
If you do this, however, make sure that it's possible to switch to another language easily - and save the settings via some other mechanism to allow persistent override (cookies!).
What should be the address of the home page
Would the use of language-specific subdomains be appropriate?
How you like it, doesn't really matter. Design it to be intuitive to the users.
Language names encrypted in URLs won't matter for SEO because nobody will be searching for "en", "de". The names of the products you're offering however will matter very much, because people will be searching for products like "gifts" or "geschenke".
I think that the better stylish solution is to use the address in the format http://yourdomain.com as the home page URL, and identify the localized web pages with ISO 639-1 language codes
I'm just starting to learn Rails. I created an empty Rails app. And instead of writing a Controller, I want to put all of my Controller logic in my Views instead of in separate Controller classes.
To do this, should I use .erb files or .rhtml files and what's the difference?
First of all, they are virtually the same thing but you should use the new standard naming format of .html.erb
Second of all, stop what you are doing and reconsider everything!!!!!
The whole point of MVC is to separate logic from display and vice versa. Most of your logic should be in your models and the controller should just facilitate grabbing that logic and passing it to your views.
You should not do anything in your views other than display the data.
"A client has asked me to build and install a custom shelving system. I'm at the point where I need to nail it, but I'm not sure what to use to pound the nails in.
Should I use an old shoe or a glass bottle?
In your case I'd go for the glass bottle.
In the new rails 3.0 .rhtml files will be unsupported. .html.erb is the new standard.
I understand that you have a small app and standards don't really apply to you, but that is the whole point of MVC. The logic should go into the controller/model and the view is strictly for presentation.
The simple answer to your question is no. No you shouldn't put controller logic in the views. If you don't need controllers then you probably don't need rails. I know that's not the answer you want, but frankly you are wrong, pure and simple. If you want to learn the Rails framework, then what you have been told here is correct and to do it your way would simply then mean either unlearning what you just did or it would mean becoming a bad developer.
That's the way it is, the rest is now up to you.
Yes, you are correct in that the creators of rails never stated that you should not use rails for smaller apps, but they have stated over and over the importance of the controller.
I created an empty Rails app. And instead of writing a Controller, I want to put all of my Controller logic in my Views instead of in separate Controller classes.
Just out of curiosity, what type of logic are you considering putting into your views? If it is presentation logic then that is one thing but if it is business rules, loading data from a database, xml file, web service/rest based then you are violating the core principles of rails. Ever heard of ASP (Classic Active Server Pages)? Frameworks have evolved beyond that to overcome the shortcomings and pitfalls like ASP to allow you not to mix presentation and code. If you jam it all together, how will you unit test your code? Another key principle of rails that is why it is built into the framework itself unlike other web frameworks.
I want to learn how to use the "standard" Ruby framework
In your responses you keep mentioning you want to learn the standard Ruby framework? If this is the case why don't you use irb then? Rails is not part of the standard Ruby framework. In fact you will probably learn a lot more about Ruby using irb then you will Rails. Once you have familiarized yourself with Ruby then take on rails.
I agree with the others and if you are going to take the time to learn a framework, then learn it right and as the creator intended, otherwise you are missing the point and you will not see why rails is such a good web framework to begin with. What you are hoping to accomplish can be done in a number of web technologies: ASP, ASP.Net, PHP, JSP, Perl, but you choose to learn Ruby and rails therefore do not do it the same as you could in any of the other web technologies.
Adhering to MVC is the way to proceed to build an application.
If you are uncertain why Controller is needed then do the research. I have
faced maintaining code where the scrips are embedded in the presentation layer.
It is farcical to begin any engineering effort without a thorough understanding
of the correct, time tested methodology. It is like trying to build a house
using no foundation or blueprint.
Nothing, really. It’s just a change of philosophy between Rails 1 and Rails 2. Before Rails 2, you had file.rhtml, file.rxml and file.rjs. In Rails, that changed to file.content_type.template_engine. So with file.html.erb, the content type is html and the template engine is ERb. rxml is now xml.builder and rjs should now (mostly) be js.rjs
In the new rails 3.0 .rhtml files will be unsupported. .html.erb is the new standard.
How to implement the multilingual umbraco 3.0?
There are two different approaches to this.
The documentation on the Umbraco website describes how to do 1:1 multingual sites. This means that you have one site structure and different language tabs in a single document type for each translation od the content. This is then selected by using an on page selector on the website (a flag icon or the like).
Here's an example of a 1:1 site
This is the most efficient set up if you have lots of shared content i.e. the content and structure is exactly the same, the language is just different.
The second approach is to use separate page structures for each language, such as:
International Homepage
------> English Homepage
------------> English content page
------> French Homepage
------------> French content page
The advantage of this structure is that it is very easy to set up, but if you share lots of content it can be cumbersome to manage. It also has the advantage that you can lock the editing permissions down for country/language specific editors.
With the above structure you can also point individual URLs to the country pages.
Without knowing more about what exactly your requirements are it's hard to answer more fully as to which is the best approach. It may also be possible to create a hybrid solution.
Here are some links which may help:
http://forum.umbraco.org/yaf_postst2209_Multilingual-structure-in-umbraco.aspx
http://www.nibble.be/?p=32