By michaelcrm on
For example, when we add to a content type a custom select-list-field "Gender" which consists of two values to choose from: "Male" and "Female". How can we make these two values translatable when entering the translation page of any node created based on that content type?
Same question to check-box-field.
Thanks in advance!
Comments
Internationalization module
I haven't tried it myself, but I think the i18n module will get you where you want. With i18n, you can provide content (and even taxonomy) in different languages.
They say some/a lot of these features will be part of core in Drupal 6 (which is already available for beta testing).
Good luck!
//Johan Falk, Sweden
Hello Johan, Thank you for
Hello Johan,
Thank you for your post. I am still struggling to find out the differences among "i18n", "internationalization" and "localization", but I knew the way to translate the vocabularies, I even found out how to translate the field name, the "Gender" in my case, through individual strings translation, but I just couldn't find the VALUES.
If I can't translate the values in an user-friendly way, it also will help if anyone can tell me where the system store those values.
Thanks again.
Michael
...
In order for a string to get translated it must be enveloped by the t() function in the PHP code. We have to do this ourselves.
Currently, your 'Allowed values' list probably looks like:
First you'd better chage it to:
To the left of the pipe is what's stored in the DB. To the right is what's shown to the User. Without this distinction between the value stored in the DB and the string shown to the user there's no sense in translating.
The next step is to generate this 'Allowed value' list via PHP code instead. The box for PHP code is just beneath the normal box. Use code similar to:
Thanks, mooffie!
Your solution helped a lot today!
Regards, Devr
How to translate the values in CCK custom (select/checkbox) fiel
I need to place the custom checkbox. The default value is 1 and 0 but, need to make it as yes and no. Can anyone help me in changing the return value to 'yes' and 'no'. I need to know where to change i.e which file to open.
this is what it is showing up
needed the format
can anyone help with this please.
resolved
I have resolved the problem
Leave solution !
When you find answers to your questions, you should leave it in the forum to help others. Thanks
thank you from me too
thank you from me too moofie.
Works!
Thank you so very much!
--Update:
To change the TITLES of the fields just search for them as strings and change them there... notice that when using English and another language it only worked (for me) setting all titles in english and having them translated - not the other way around...
--Update:
This works perfect with select list.
It doesn't however work for text fields... even after adding the field to the variables to settings.php... body & title work but other cck text fields don't...
What about decimal fields? I'd like to change the pre & post added text to be language dependent as well but can't find them as strings to translate.
Any ideas? ;)
...
I suggest you upgrade your CCK. I had a quick look and the Text module does wrap the title in t(), so apparently you shouldn't have a problem here.
CCK currently doesn't wrap it in t(). Consider filing a bug.
ordering alphabetically
Thanks moofie for you code
it just works fine for me. I'm using it for many different select lists and one of them is a country list. I'm wondering how I could I have this country listed alphabetically according to the language selected ?? Is it possible to have the label sorted ??
pictogram
...
Yes, it's possible. My code currently looks like:
change it to:
HOWEVER, asort() sorts the strings byte by byte. This may not be suitable for the language(s) you use. Two ways to solve this:
setlocale('LC_COLLATE', 'de_DE.utf8')somewhere and addSORT_LOCALE_STRINGas a second paramter to asort(). (Note that I used LC_COLLATE, not LC_ALL, because we don't want to affect the way numbers are printed --or else the search module will fail because it uses floating point numbers.)Translation of strings seems
Translation of strings seems to be a buggy thing for me - sometimes it works, sometimes not...
If it does not, there is a quick-n-dirty solution
Translation of TextArea type string
This solution helped me to translate all my fileds with Select lists. What about fields with Textarea. I'm using one Textarea type field with Number of values = 2. The first one is in english version and second in russian. What code should be used instead of:
Strings not appearing
Hello,
I'm using Drupal 5.7 with CCK 1.9 and i18n 2.4 and I tried your solution, but there is a slight problem. The new strings I defined in the return array of my select list do not appear when I search through the localization-string search interface. I thought it could be an indexing problem so I croned the site, but nothing happened. Is there something else I should do before translating these terms?
Thank you.
Does not work
I'm using Drupal 6.10. Strings not found in Translate Interface
=============================
Allowed value list:
=============================
main event|Main Event
shofar|Shofar
radical youth|Radical Youth
single youth adults|Single Youth Adults
=============================
PHP code:
=============================
return array(
'main event' => t('Main Event'),
'shofar' => t('Shofar')
'radical youth' => t('Radical Youth')
'single youth adults' => t('Single Youth Adults')
);
...
You have a syntax error here. You forgot the commas. It should be:
(The last comma seems unneeded. Indeed, but it isn't a sytax error.)
(You don't need this anymore once you're using the PHP block.)
Thank you!
Clear solution, mooffie, thank you!
For those, who can not find the created strings in the Translation menu: just load the page with the created field at least once under admin. Then you can go search for translatable strings and voilà!
What we know shapes who we are.
=)
Man, thx so much, you just saved my life I was about to hardcore page.tpl with jQuery and man I didn't wantedto do that, thx so much !!! :D
Checked checkbox
How can i make a checkbox "checked" by default ? I tried adding default value to 1 and other this like that but it doesn't seem to work.
I must be doing something wrong...
Thanks in advance.
EDIT: Sorry for the dumb question, i didn't see this: "For a 'Single on/off checkbox' widget, define the 'off' value first, then the 'on' value in the Allowed values section. Note that the checkbox will be labeled with the label of the 'on' value."
Solved it now :)
The mentioned solutions didn't work for me on D6
I used
Works on drupal 6, using "global $language"
the following code works for me:
(paste it inside "Allowed values fieldgroup - Php code")
This method tnraslate only
This method translate only values in CCK fields on EDIT PAGE? Right?
Because it's working on edit page, but doesn't translate it on content nodes.
Right? or I miss something...
If that's right, how to have the translated values on content nodes?
Taxonomy system
Why not simply use the taxonomy system? For example, create a vocabulary called "Gender" with the terms "Male" and "Female". If you make the vocabulary and terms translatable (through core/i18n/locale), you don't need to worry about PHP coding.
thanks for the tip about taxonomy
Here I am developing a site in English, waiting to make it multilingual after all the CCK fields are set up like we need, but I didn't even realize there was a translation issue on defaults or allowed values. You are right, taxonomy is the way to go. The only drawback I see is not being able to put the taxonomy fields where you want within other field groupings.
Try out Content Taxonomy
The Content Taxonomy module is swell -- it lets you manage taxonomy terms just like CCK fields.
It's the way taxonomy will be managed in Drupal 7 as well, so you're not wasting time on dead-end.
I'm not completely sure that it's a good idea to just replace CCK text fields with taxonomy terms, but if you're going to do it Content Taxonomy will be your friend.
Cheers!
//Johan Falk, http://nodeone.se
Use the i18ncck module
The Internationalization module has a submodule specifically for CCK fields. Go to your modules list and under Multilanguage, enable CCK translation. Now your cck fields are translatable.
Can't do allowed values
Yes, but it doesn't help with translation if you're defining a set of allowed values.