Learning how to do internationalization

Events happening in the community are now at Drupal community events on www.drupal.org.
ceege111's picture

I need a sanity check. I have installed i8n and enabled it, and it is happy....but the functionality confuses me. The languages block is enabled and has English and Japanese. I have installed the Japanese .po file, and when one hits "Japanese" the Drupal system UI changes to Japanese but the node content does not. At the bottom of the page there is a "Japanese" button that changes to node content to the translated page. That does not change the menus. What I want is for the language block to change everything - the menus but more importantly, the content. Am I missing something or is it working like it's supposed to?

Any thoughts are welcome! Thanks.

Comments

Have you translated your

edward.peters@drupal.org-gdo's picture

Have you translated your content and menus? If you translate menu items in a translation set it should work ok, and if you translate content in a translation set (i.e. the nodes are held in relation to eachother) then when you switch language you should see the translated node. Otherwise you won't.

yes - I have translated it

ceege111's picture

The content seems to change separately from the UI (via a "japanese" link at the gottom of the page). I am using drupal 5.2 - is this different than 6 in functionality? The nodes seem to be "held in relation to each other" - they are linked specifically to the other language - but they don't toggle from the language block.

Thanks for your thoughts though. It might be behaving normally - I just haven't used it. I am looking for an example of a multilingual drupal site that toggles normally but haven't found one.

There are 2 switcher blocks.

alexiscott's picture

There are 2 switcher blocks. If you want it to switch the translated nodes as well you need to use the block that comes with the translation module. It is in the blocks list and is called translation or translations.
I think that could be the issue as it seems to catch everyone.

That did it, thanks!

ceege111's picture

Wow, thanks! I had the feeling I was missing something! Works great!

New question

ceege111's picture

So how would one re-style the language switcher block? What's actually generating it? What I want to do is put the flags in the nav bar, anyone tried this already or seen a how-to? If I could just call the language block from my page.tpl.php that might do it if I could set the css for that block...

Thanks!

Flags

pmichelazzo's picture

You can do that changing the icons option at Languages area (Home » Administer » Site configuration » Languages). Click on Configuration option and you can see two new options below. One of this is icons.

In my new website I put my icons in a different place of the template making a new area and promoting the bock on it.

Best

Paulino Michelazzo
http://www.michelazzo.com.br

Paulino Michelazzo
http://www.michelazzo.com.br

Yes, I'm Brazilian and we don't speak Spanish here (but I can speak too).

my version doesn't seem to have that option

ceege111's picture

Don't have an item "languages" - do have "Localization" though

If you want to call the

alexiscott's picture

If you want to call the function directly I believe the one you want is translation_get_links() - and it is in translation.module

Language filtering & untranslated nodes

ar-jan's picture

Hello everybody, I just joined the Internationalization group today, good readings. I've been trying out Drupal 6 for the last two months (and I like it, of course). My main reason for choosing Drupal is its strong multilingual capabilities.

I've been dealing with above problem for some time, and now I finally managed to get it working - on a local test setup (Ubuntu Desktop LAMP configuration with virtual hosts).
In my test setup, I have:
domain1.tld
domain2.tld
domain3.tld
all pointing to the same webroot containing the D6 installation. In my Drupal /sites directory I have the domain1.tld, domain2.tld and domain3.tld folders (multi-site setup). After going through Drupal's installation for domain1.tld, I copied its settings.php to the domain2 and domain3 folders and everything was working (one website, one database, the different domains are meant only to use "domain name only" as language negotiation. OK, so here are my questions:

1) In order to use "domain name only" as language negotiation, is it necessary, or preferable, to do a multi-site install, when the three domains are actually going to be the very same website? I ask, because I was not able to get language filtering to work for me without the multi-site setup (but that might also be due to me misconfiguring something). I don't know the workings of Drupal well enough to understand if there might be a difference between the handling of a url in a single site 'default' install, and the handling of the same url(s) in a multi-site install.

2) So language filtering works for 'listings' pages (or whatever you call that), such as the default front page /node. BUT: in my scenario (a tri-lingual website for an NGO), not necessarily every node will be translated. Let's suppose we have
domain1.tld/node/1 - Dutch node
domain2.tld/node/2 - English node
domain3.tld/node/3 - Spanish node
Where the 3 items are not each others translation. When I'm at domain1.tld/node , I get just the Dutch post, good. Using the language switcher brings me to domain2.tld/node and domain3.tld/node respectively, and those show the right content for those domains.
But when I am at domain1.tld/node/1 , and I change the language to English, I go to domain2.tld/node/1 which shows me the same Dutch node! Now I understand this is happening, If node/2 were a translation of node/1 Drupal would go to the right page when clicking on 'English' while at /node/1. But my problem is, domain2.tld/node/1 should not exist at all, since we can't / shouldn't have Dutch nodes existing on the strictly English domain.
--> Is this a known problem/bug, or should it be a feature request that Drupal/i18n can do something differently here? Or is there already a solution to this?
--> Now that I think of it, If I were to implement it this way, could that cost me in the Search Engines for duplicate content? Probably, and what could be a solution for that?
--> Could the Virtual Sites Module (http://drupal.org/project/virtual_site), which can also filter by domain, add any functionality in this scenario?

I'm curious, thanks in advance for the response!

Short reply

zoo33's picture

In order to use "domain name only" as language negotiation, is it necessary, or preferable, to do a multi-site install

I'd say no. I don't think that's the idea. If you're only serving these three sites with your Drupal installation, you might as well just use the default site directory an any domain will be served by that site.

But my problem is, domain2.tld/node/1 should not exist at all, since we can't / shouldn't have Dutch nodes existing on the strictly English domain.

Like you said, /node/1 will always be the same language no matter which domain you access it from. I don't think there is currently any way of hiding nodes of the "wrong" language if the user specifies the node ID like that. The i18n module would probably be the best candidate for such a feature. Until then, you could create your own tiny module which does only that.

/ Hannes Lilljequist – SthlmConnection

Maybe I'll place a feature

ar-jan's picture

Maybe I'll place a feature request for i18n to be able to show one a given domain only nodes in a specified language. However, it seems there are quite some problems with i18n and url's / duplicate content etc., so I'll do some more reading first.

Now if I want to create my 'own tiny module' for this purpose, where should I start? I'm familiar with editing a little php, but I'm not a coder and I don't know Drupal API etc. Can someone with little Drupal knowledge do this at all?

Desired functionality: when a user specifies a node of which the language is not the one associated with the current domain, redirect to that domain's frontpage. Probably I should also specify somewhere which domain is bound to which language. And would it be easiest to do this in the theme template?

Ideas like what kind of code to use would be very welcome, since I have no clue where to start.

Definitely place a feature

zoo33's picture

Definitely place a feature request!

If you would write your own module it would use hook_nodeapi() and on each load operation check that the node's language isn't wrong, and if it is, redirect the user with drupal_goto(). If you've never created a module or used the Drupal API it will take some reading, but it's not that difficult.

Probably I should also specify somewhere which domain is bound to which language. And would it be easiest to do this in the theme template?

No, you should assign languages to domains on the languages settings page.

/ Hannes Lilljequist – SthlmConnection

I placed the feature request

ar-jan's picture

I placed the feature request here. I hope someone will pick this up, if not, I should start learning php and Drupal API ;)

Reproducing site for different languages

athanasius's picture

I'm very new to Drupal. I was hired a little over a month ago by a company that is in the process of converting its site to Drupal (Drupal 5.7 -- linux, apache, mysql). I've done web development for over ten years, but have no prior experience with Drupal.

The English version of the site is near complete. Once that is live, we want to create versions in Japanese, Korean, and both Traditional and Simplified Chinese. We have all the content from the current hard-coded site: www.powerint.com.

My question is this: In order to create the four new versions of the site, would the best course be to create four instances of the English site and then use those instances as shells to dump the translated content into? If so, how is this done? If not, then what is the best way to go about it?

Also, we will need to create admin interfaces in each of the four languages. It's my understanding that this is done by installing the respective po files and then importing these into the locale module. Is this correct?

I've sifted through this and the translations group but haven't seen any good inductive threads on how to get stared. The handbooks are also a bit difficult as they don't really articulate the procedures for doing such things. (I need something like a cookbook type set of instructions.) Thanks.

I'm new to Drupal myself and

ar-jan's picture

I'm new to Drupal myself and not a developer, so take my advice for what it's worth :)

In order to create the four new versions of the site, would the best course be to create four instances of the English site and then use those instances as shells to dump the translated content into? If so, how is this done? If not, then what is the best way to go about it?

I would use Drupal's capability of translating nodes to different languages, rather than creating several instances of the English version. This way you maintain the relationship between translations of the same content. i18n module would be necessary to do that.

Also, we will need to create admin interfaces in each of the four languages. It's my understanding that this is done by installing the respective po files and then importing
these into the locale module. Is this correct?

Locale module needs to be enabled, yes. When Drupal has been installed in English, you need to copy all folders/files from the translation package(s) to the installation as well. When you add a new language, Drupal will look for these files and import all translations it finds. If you were to add the language first in the admin settings it would not look for these files afterwards.

In general, i've found that searching drupal.org and google site:drupal.org can get you most of the answers you need, it just takes a lot of reading ;)

Cheers, Arjan

Thanks for your comment,

athanasius's picture

Thanks for your comment, Arjan.

Combing through the drupal.org site, I've found this page:

http://drupal.org/node/133977

While helpful, it really covers more of the functions of the i18n module rather than the process of actually building out the content. I'm really needing some general guidance on how to go about setting up and building out multi-language content using Drupal. Here are some of the issues I'm having...

According to the above tutorial, my basic configuration is set as it should be. The initial install and set up of Drupal for our site was done by a consultant. We sepcified we eventually wanted the site done in four languages, so the hooks were created on set-up. In fact everything seems ok until I get to "enabling multi-lingual content." After checking a few different content types, I found that some are enabled and some are not. I assume that all need to be enabled in order to support multi-lingual content.

I also noticed on the content types where multi-lingual content is enabled, a pulldown appears allowing the selection of one of the language settings. As an experiment, I changed the setting on one of these pages. After submitting the change, the page disappeared from the site menu. And when I changed it back to English, the page reappeared.

I'm wondering how this is supposed to work and what is the best way to go about reproducing pages in our four chosen languages. In other words, it seems I can only select one language or the other for each node. How then do I reproduce the four different versions of the page? It's at this point I begin to get lost. On the Common Questions, Tasks, and Solutions page...

http://drupal.org/node/70194

...there's reference to creating the home page and menus in different languages, but there's nothing said about reproducing the whole taxonomy and file structure as a second (or third, or fourth...) copy of the site in preparation for translation. Does this mean that the entire site needs to be built out by hand with every node being recreated?

The multilingual categories page...

http://drupal.org/node/133999

...seems to indicate that you can create parallel terms for your existing taxonomy. But it doesn't say anything about how the links are managed or how the page content itself is entered and maintained.

Ultimately, where I want to get is having the site work like the ARCO Latino site shown on the sample site page:

http://drupal.org/node/134010

e.g.,

http://www.arcolatino.org/

By selecting any of the languages, you're taken to a subdirectory where the entire site is reproduced in that language:

http://www.arcolatino.org/ca
http://www.arcolatino.org/fr
http://www.arcolatino.org/it

etc.

...and all the subordinate areas of the site follow the a similar structure:

http://www.arcolatino.org/ca/projectes
http://www.arcolatino.org/fr/projets
http://www.arcolatino.org/it/progetti

So this is where I want to get. Apparently it can be done. But the guidance on how to get there seems very disjointed.

Thanks again,

Athanasius

multilingual site with i18n module

ar-jan's picture

What was this basic set up the consultant did for your site? Did it involve changing any code, or only installing the right modules and configuration of the modules? i.e. when you say 'hooks', do you mean Drupal's hook API was implemented? (in that case I wouldn't have a clue, since i'm not a developer). Maybe this consultant is still available for advice?
Some questions on your current setup:
- are the four languages already defined at admin/settings/language ? I suppose so since you mention you tried changing the language on a node. If you haven't localized your Drupal installation yet (i.e. have the interface, menus, translated), it would be best to do that before you start inputting content, because then all translation files are imported from your directories (as i said in my comment above). Note that this will probably mean that when you click 'translate' to add content, or visit the site in another language, the menu will show in that language as well (my Chinese for example is about 0%) ;). Also if you remove a language, all content in that language is defaulted back to 'no language'. So you don't want to remove and re-enable a language if you have hundres of nodes in that language already.

After checking a few different content types, I found that some are enabled and some are not. I assume that all need to be enabled in order to support multi-lingual content.

Yes, you need to enable 'multilingual content with translation' for each content type that you want to be available in multiple languages. Unless this consultant had in mind to create four subsites, each in a different language. But that would not make much sense to me, if you want to manage the content as translations of each other.

You mention you changed the language via the pull-down. The pull-down menu when creating a node will show all enabled (or defined) languages, this is expected. When you change language content disappears from the menu. Probably, the menu's language is defined as English, and therefore only English content shows in that menu. You need to create a menu for each language. See also this discussion http://drupal.org/node/230868. If you use both Primary Links and Secondary Links, this means you will create 8 menus, and for each you define the language.

Next, yes, you can only set one language per node. Drupal handles multilingual content by relating nodes to each other. So when you create a translation of node/1 it will be node/2. The idea is that you translate through the front-end. In your case, with multilingual content with translation enabled for the content type, you visit the node and click translate. When you translate you select to which language you want to translate, then you translate the content (title, text, etc.), and choose in which menu you want the translation to appear. So This needs to be the menu in the right language, or the node won't appear in the menu.

With Multilingual taxonomy enabled (at admin/build/modules, an i18n submodule), you can do the same for taxonomy. Set your vocabulary to multilingual with translation. Create your term in 4 languages, e.g. apple, manzana, apfel, etc., and then, while at /admin/content/taxonomy, there is a tab 'translation' where you can define which terms are translations of each other. There is also the option to fully 'localize' a vocab, instead of using 'translation', but to me that seemed more complex, I think it involves translating strings somewhere in the admin interface. Since fully localizing a menu does not work (see the above mentioned issue), I chose to go with translating the taxonomy.

The ARCO Latino site uses the language switcher block to switch the sites language: content and menus appear in chosen language. When you enable the multilingual block at admin/build/block, it is important to choose the right one: one block will only switch the interface language, the other shows content and menus in the chosen language. I'm not sure which block is called what, on my D6 site I only see one and that one does its job, but apparently there are 2 'language switcher' blocks. For this to work you also need to set admin/settings/i18n to 'Only current language and no language' (or some other choice, but not 'all content').

The language prefixes in the url, like on arcolatino.org, can be defined at /admin/settings/language/edit, you can choose any prefix but it is defaulted to the language code which should be fine. Also set admin/settings/language/configure to 'path prefix only' (or with language fallback) so content is shown in the right language based on the url.
The paths following the language prefix you see on arcolatino, e.g. /en/projects are configured using Path module (in core) where you can define path aliases. The default path for /en/projects would be something like /node/41, this is re-written. Either manually when submitting the node, or automatically using PathAuto, based on some filter like node title. http://drupal.org/project/pathauto.

Hope this helps.

Thanks again for the

athanasius's picture

Thanks again for the response. I understand pieces of what you say. I think there may be some differences from Drupal 5 to 6 that might be the source of some of my confusion.

What was this basic set up the consultant did for your site? Did it involve changing any code, or only installing the right modules and configuration of the modules? i.e. when you say 'hooks', do you mean Drupal's hook API was implemented? (in that case I wouldn't have a clue, since i'm not a developer).

"Hooks" was probably a poor choice of words as it carries a specific meaning. What I wanted to convey was that the site was built with the idea that we would eventually be translating it into different languages. Therefore, the module settings were made to lay the groundwork for translation to be implemented when we were ready to do so. I'm fairly certain that no custom coding was done.

Here's a brief rundown on the settings:

I. For the Multilanguage - i18n module:

Internationalization is checked and the checkbox is grayed out. The setting specifics read:

Depends on: Locale (enabled)
Required by: i18n - blocks (disabled), i18n - content types (disabled), i18n - menu (disabled), i18n - profile (disabled), Strings (disabled), Synchronization (disabled), i18n - taxonomy (disabled), i18n - views (disabled), Translation (enabled), Translatable Text (disabled)

Blocks, menu, profile, taxonomy, and views are respectively unchecked.

Translation is checked with these specifics:

Depends on: Internationalization (enabled)
Required by: Synchronization (disabled), i18n - taxonomy (disabled)

II. There's also a Multilanguage i18n experimental module. The checkboxes (118n content types, strings synchronization, translatable types) are all unchecked.

III. I'm not sure what you mean by admin/settings/languages but when I got to administer/site configuration/multilingual system and select manage languages, I see the four languages defined. They are: English, Chinese simplified, Japanese and Korean. All are enabled and English is selected as the default.

If you haven't localized your Drupal installation yet (i.e. have the interface, menus, translated), it would be best to do that before you start inputting content, because then all translation files are imported from your directories (as i said in my comment above).

IV. We haven't localized the Drupal admin interface yet. I'm curious how this impacts the rendering of the site in different languages. My understanding was that it simple creates alternative languages for using the content management system (CMS). I don't understand how it affects the public facing website. I did find a good tutorial on installing the "po files" to add languages to the CMS...

http://www.lullabot.com/videocast/installing-drupal-translation

Is this what you're referring to when you says "localizing your Drupal installation," or am I totally off?

You need to create a menu for each language. See also this discussion http://drupal.org/node/230868. If you use both Primary Links and Secondary Links, this means you will create 8 menus, and for each you define the language.

V. What you wrote concerning menu creation is confusing. I also went to the discussion you mentioned and that was confusing as well (lots of talk about the variances in different versions of drupal). You say, "You need to create a menu for each language." and "If you use both Primary Links and Secondary Links, this means you will create 8 menus, and for each you define the language." I'm having trouble envision what this is suppose to look like on the administer/site building/menus screen.

Using you example, for English only, I would see something like:

Fruit (heading)

Menu item (sub categories)

Apples
Oranges

Would a translated version have two headings (Fruit and Frutas)

or would there be one head and then the various translations of all the subheads underneath (apples, manzanas, and so on)?

What would help me conceptualize this is to see a screenshot of a properly set up menu admin screen for a multilingual website.

Next, yes, you can only set one language per node. Drupal handles multilingual content by relating nodes to each other. So when you create a translation of node/1 it will be node/2. The idea is that you translate through the front-end. In your case, with multilingual content with translation enabled for the content type, you visit the node and click translate. When you translate you select to which language you want to translate, then you translate the content (title, text, etc.), and choose in which menu you want the translation to appear. So This needs to be the menu in the right language, or the node won't appear in the menu.

VI. You write: "...you visit the node and click translate. When you translate you select to which language you want to translate, then you translate the content (title, text, etc.), and choose in which menu you want the translation to appear."

I looked at one of the nodes for a content type where multilingual content has been enabled. I don't really see anything that give me the option as to whether I want to translate. What I do see is a pulldown menu for language selection and another pulldown for "translation workflow" with the options of:

Source content (to be translated)
Translation in progress
Translated content
Source updated (to updated translation)

Is this what you mean? By selecting one of these, does another node get produced (one earmarked for translation)? On doing so, am I then give the opportunity to assign the translated (or to-be translated) node to another menu item? If so, how are these options presented?

With Multilingual taxonomy enabled (at admin/build/modules, an i18n submodule), you can do the same for taxonomy. Set your vocabulary to multilingual with translation.

VII. I think I understand the taxonomy part of what you wrote. Presently, multilingual taxonomy is not enabled. Hopefully, when I get it enabled I'll be able to implement what you described.

VIII. RE: Switcher block ...again, this is not enabled.

The language prefixes in the url, like on arcolatino.org, can be defined at /admin/settings/language/edit, you can choose any prefix but it is defaulted to the language code which should be fine.

IX. Again, I'm not seeing an admin/settings/language section. (Perhaps this is a change in naming from v5 to v6.) In administer/site configuration/multilingual system I don't see anywhere to map a language to a url prefix.

You are probably right,

ar-jan's picture

You are probably right, there may be some differences between D5 and 6. I never used 5 so I'm not sure, but I think the differences should be limited. Maybe someone who uses D5 could help out as well.
I think you should start playing around with every option that is related to content translation/i18n, so maybe setup a test installation for that purpose. Also, you will need to enable most sub-modules of i18n, I think all except i18n profile. Otherwise i18n's multilingual features just aren't there. For example with 'translatable text' you probably get the 'translate' option (but it's a bit different in D6). I don't have time for any specifics now, and also I don't know the exact configuration options in D5.
With /admin/settings/language I meant the path of the administration settings for languages, but this could indeed be different in D5. The part where you see which languages are installed should have an edit link for each language, at least I suppose there is. Good luck.

sanjaygupta1011's picture

Hi,

I am new to drupal and trying to translate a drupal site into chinese. I have installed all the necessary modules like i18n and also imported chiness language files (.PO files) and it shows almost 100% in the language interface section. I ahve also placed language switcher on the top of the site. Now I clicked on the edit tab of the page and then saved it. After that I could see the translate tab. Once I click on the translate tab, it shows create new page interface with the contents appear in the english version. I clicked on the save button. But the contents seems to be in english only. I have also edited content type to support multiple languages. Please help....

Thanks,
Sanjay Gupta
sanjaygupta1011@gmail.com

Sanjay Gupta
sanjaygupta1011@gmail.com
+919953533466

Internationalization

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: