Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] Translation of drop down list in user fields

10 years 10 months ago #238826 by siwayjoomla
Replied by siwayjoomla on topic Translation of drop down list in user fields
Hi Kyle,
I have found the point here.

Usualy lists are translated directly by CB because they are shown as lists.
Function : selectList from comprofiler.class.php

Translation of items done by :
$html .= getLangDefinition( $t );

But in our case, we do not display the title as a list, as we want to use it in the mail.
So when auto-action renders the email boby, when he renders the fields, he uses directly the :
_evaluateCbFields function from plugin.foundation.php
that does not do the translation of fields.

In my case, problem is solved by changing in _evaluateCbFields:
return $val;
by :
return getLangDefinition($val);

(I do not recommand any core hack here, I am just explaining my point)

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 10 months ago #238849 by krileon
Replied by krileon on topic Translation of drop down list in user fields
You don't need to touch _evalueCbFields. The translation is done in replaceUserVars by the following.

Code:
if ( $translateLanguage ) { $msg = getLangDefinition( $msg ); }

Field values themselves are translated on a field by field basis. When you use [FIELD_NAME] it will never and it should never translate as it's pulling the value straight from user object or pulling the PHP value. This is intentional. You need to use [cb:userfield field="FIELD_NAME" /] usage to get the translated and parsed value of a field. The select type field is still giving you troubles then be sure to pass it reason="profile:translated" to force it to translate the PHP value for the select field.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

10 years 10 months ago #238850 by siwayjoomla
Replied by siwayjoomla on topic Translation of drop down list in user fields
Thank you very much, yes it solves my problem and I'm really happy to remove this hack form my code.

One last double question in order that I stop borrowing you :

On previous post you told me :
'_MY_EMAIL_BODY' => 'All my HTML Here, but notice I am new language string usage and NOT a define....'

When adding a language string by using :
CBTxt::addStrings( array('_MY_EMAIL_BODY' => 'All my HTML Here, but notice I am new language string usage and NOT a define....'));
My email is sent with : _MY_EMAIL_BODY

When I use a DEFINE, it works.
So it means I'm doing something wrong somwhere. But I cannot find out why.
I know that I did something wrong at the beginning and I need to change that, as I modified the default_language instead of using an english language pack.
I'll rectify it right now.

So How should I do so that I can use a language string and not a define ?

And the second question is really more generical but is direclty linked :
I really searched for a detailed explanation of when to use what king of translations / fields usage (define, language strings, and now the one you sent to me with [cb:userfield field="cb_titre" /]).
But I could not find out one.
Could you please tell me where I could find that ?

Thanks for the support,
Regards,
Nicolas

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 10 months ago #238854 by krileon
Replied by krileon on topic Translation of drop down list in user fields

So How should I do so that I can use a language string and not a define ?

That's how it's supposed to be done, but it only bothers to translate through CBTxt if there isn't a define for it. So don't use both at the same time. CBTxt and define usage can not do inline translation so ensure it's the only value set. I'm not sure, but this may not work correctly in current release, but it's available in next release for CB 2.0. So for now you may need to use a define.

And the second question is really more generical but is direclty linked :
I really searched for a detailed explanation of when to use what king of translations / fields usage (define, language strings, and now the one you sent to me with [cb:userfield field="cb_titre" /]).
But I could not find out one.
Could you please tell me where I could find that ?

I'm not sure what you're trying to do, but I assumed you were adding a substitution to your email and the substitution didn't translate. You can find information about substitutions below, but if my assumption was wrong please better detail what you're wanting to do.

www.joomlapolis.com/support/tutorials/107-use-cases/18353-using-substitutions-throughout-cb


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: siwayjoomla

Please Log in or Create an account to join the conversation.

10 years 10 months ago #238856 by siwayjoomla
Replied by siwayjoomla on topic Translation of drop down list in user fields
Great I have all my answers!
For me this issue is closed.

Thank you very much,
Nicolas

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum