Bí quyết 2 - đa ngôn ngữ trong Drupal 7

Bí quyết 2 - đa ngôn ngữ trong Drupal 7

Blog Site in Multiple Languages: Recipe 2

In our last blog post, we saw how to set up a simple website in a foreign language. Like our last recipe, this one is very easy too.  The main difference lies in the fact that we need to give users the possibility to choose their preferred language.  Content will not be translated to each language, but the user needs to be able to navigate the site in their preferred language, so that they can find what they’re looking for a blog post in a language they understand.

To achieve this, we follow the same steps we did in our last blog post, with a couple changes: First, instead of just adding one language, choose all the languages you will support.  Remember that since we installed and enabled the Localization Update module, it will automatically download the available site translations for your site’s interface.  Second, configure the “Detection and Selection” settings.

So let’s go ahead and do the second change we need. Go to /admin/config/regional/language and select the “Detection and Selection” tab.  Here, you will be presented with several language detection methods.  You will need to setup at least one.  The most common one is the URL detection method.  When you configure it, you can either choose “Path prefix” or “Domain.”  The first is the easiest one.  It simply uses predefined prefixes in your site’s URL to determine what language is being used; like http://example.com/es for Spanish or http://example.com/de for German.  The second requires some additional server modifications so that your site can respond to domains such as http://es.example.com for Spanish or http://de.example.com for German.  Let’s use “Path Prefix” for now.  Save configuration, and you are good to go.

Screen shot 2012-07-31 at 7.51.33 PM.png

Now that we have a way for the system to know when to present one language or the other, let’s give the user the possibility to pick one.  The Locale Module provides a block that you can enable, giving users the possibility to pick the language of their preference.  Go to /admin/structure/block and look for the “Language Switcher” block, place it in a region where users can easily find it; like the “Sidebar First” or the “Help” regions in a Bartik theme.  If you’ve been following me, you should see something like this:

Screen shot 2012-07-31 at 8.01.24 PM.png

You can see that the selected language is Spanish, and almost all of the user’s interface has been localized so that Spanish users can understand and navigate through your site.

This concludes this second recipe.  So far we’ve seen a couple of very basic scenarios for Multilingual websites.  As you can see, setting up Multilingual websites like these is a no-brainer.  These simple steps can open up the possibilities of your site by making it available to a broad variety of users with very little effort.  This process would otherwise be a laborious task to do without such wonderful Multilingual features that Drupal provides.

Our next blog post will deal with a far more complex Multilingual website.  You’ll learn how to handle the translation workflow of your content and other interesting topics such as content moderation and automated translation techniques.  I hope the recipes we’ve seen so far will help you in your own Multilingual projects.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Chia sẻ 6 loại console giúp việc debugging của bạn dễ dàng hơn

Chia sẻ 6 loại console giúp việc debugging của bạn dễ dàng hơn

Trong quá trình coding ắt hẳn chúng ta không ít lần cần đến sự hỗ trợ của console để debugging. Một trong những lệnh hữu ích nhất và phổ biết nhất mà bất kì một lập trình viên nào cũng biết đến

Hướng dẫn cách đóng góp Translations cho Drupal Projects

Hướng dẫn cách đóng góp Translations cho Drupal Projects

Learn how you can help with translation on Drupal.org from Drupalize.me's Amber Matz.

Google Music “lột xác” beta, tích hợp với Google+

Google Music “lột xác” beta, tích hợp với Google+

Google đã chính thức mở cửa dịch vụ âm nhạc mang tên Google Music của mình sau một thời gian thử nghiệm. Người dùng có thể lưu trữ nhạc miễn phí trên dịch vụ điện toán đám mây hay mua trực tiếp từ Android Market.

Công ty diệt chuột T&C

 

Diet con trung