7

I want to get the labels and descriptions of custom fields translated in Dutch, but no matter what I try they always remain in English (the language I use for creating them). I hope my steps below makes sense because I don't understand why it isn't working.

What I do is I create a field (with the site language set to English) in either a profile (using the Profile 2 module) or directly in the account.

Then I edit the field and use the translate button (provided by Field translation in i18n) to add a Dutch translation. But if I then switch the site language to Dutch, the field label and description are still in English.

If I edit the field again (with the site language still set to Dutch), the translate tab now shows the Dutch translation with status original and English as "niet vertaald" or not translated. If I edit the Dutch translation, I'm presented with the English version.

I can change that again to the Dutch text and it will show correctly (in Dutch). Nice, but when I switch the site back to English the field remains Dutch! When I edit the field, the translate tab shows the Dutch text in the English language, but the status for English is back to original.

I cannot make heads or tails of this. Am I completely missing something or is this perhaps a bug? I'm using Drupal 7.

  • What is the default language? Are you using Entity Translation as well or are you just using i18n modules? Have you cleared the cache after translating? Have you double-checked your language detection settings? /admin/config/regional/language/configure – Patrick Kenny Jan 19 '13 at 7:05
  • The default language is English and to test I switched the default language to Dutch and back (to avoid something going wrong with the language detection settings). I had entity translation enabled at some point, but it did not seem necessary as i18n provided the necessary translation tabs and fields. I did not clear the cache, could that be it? I can't check at the moment. – Whiskey Jan 19 '13 at 10:53
  • I would always try clearing the cache first; that fixes a lot of problems. – Patrick Kenny Jan 20 '13 at 2:52
  • Just did another test in my dev environment at home. Installed i18n and variable, enabled field translation and tried translating a field I created in the account settings. Same results, no matter how often I cleared the cache :( – Whiskey Jan 20 '13 at 20:29
  • 1
    Please, take a look at drupal.stackexchange.com/questions/36065/… – kalabro Jan 31 '13 at 9:57
6
+50

You shouldn't change the default language to Dutch to test it, since then it sets that your field names (and all other things in website) are in Dutch.

Instead I suggest to use 'Detection and Selection' options, and enable Browser or User, then test it in other Browser in Dutch, or with another User whose language is set to Dutch.

The better and more comfortable way would be using Language Switcher block, enabling URL or Session under Detection and Selection settings.

So that, the default language of website still stays English and the fields are translated if someone is using the website in Dutch.

  • Thank you for pointing this out. I never had thought that the default language setting also applied to the the origin of the strings in the site. And now the translation works as well with the translate tab button when editing a field in Manage fields. – Whiskey Feb 6 '13 at 22:00
11

Last days, I got the same issue to translate labels and descriptions of custom. here is what i did to solve it.

  • Enable i18n's i18_field "Field translation" submodule
  • Go to admin/config/regional/translate/i18n_string
  • Checked 'fields' (properly check all) and Click on "Refresh strings".
  • Go to admin/config/regional/translate/translate
  • Search desired string and translated it to other lang.
10

I print translated field labels this way (using i18n_field.module):

$instance = field_info_instance('node', $my_field_name, $my_node_type);
$my_translated_label = i18n_field_translate_property($instance, 'label');

Hope it helps.

  • 2
    This is an interesting solution. Where do you put this code? Why doesn't i18n_field do this out of the box? – JamesWilson Oct 21 '14 at 17:43
1

I think you could have kept Dutch as default language and set English as source language at admin/config/regional/i18n/strings.

1

the easiest way to do this, is by installing Localize field module.

it provides translations for the following thing:

  • title and description of all core fields, date fields and field
  • collections prefix, suffix and decimal separator
  • option labels of list types

you can use it even if you installed i18n_field (Field translation)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.