How to translate text in text field

6 years 4 months ago #300191 by mk3
How to translate text in text field.
Whan a user enters for the first time his country/city in english in a multilingual site in a text field.
We need it translated when switching to other languages.
I've entered lang key and translate text in lang plugin override, but nothing happens.

Please Log in to join the conversation.

6 years 4 months ago #300197 by krileon
Replied by krileon on topic How to translate text in text field
Field values aren't passed through translations. You'd need to use a select field, supply all the countries, and translate the labels for the select options. CB Query Field can be used to generate a select list of countries from a custom database table as well to make things easier, but you'd still need to translate each country.


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: mk3

Please Log in to join the conversation.

6 years 4 months ago #300257 by mk3
Replied by mk3 on topic How to translate text in text field

You'd need to use a select field

I thought that you meant I can continue using my text fields and create a non-usable select list for translations, tried it but didn't work. As I understand you meant the only way is to use the select field - but this way isn't good for me. Because....
I'm using Google Places API to generate address and fill corresponding CB text fields (country, city, street.....)
This way there is no possibility for translations of country, city, street on userprofile?

I had an idea, that I could use CB replacerbot (or CB googletranslate) for this task?

Please Log in to join the conversation.

6 years 4 months ago #300323 by krileon
Replied by krileon on topic How to translate text in text field
Text field values are not passed through translations. They never will be as they're user input. I guess you can use a CB Code Field and utilize PHP to pass it through our CBTxt API to translate it.


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: mk3

Please Log in to join the conversation.

6 years 4 months ago #300339 by mk3
Replied by mk3 on topic How to translate text in text field
Alright. Could you please give an example, how to do that?
Something like create thousands of IF conditions in the PHP code field for each city translation?

Please Log in to join the conversation.

6 years 4 months ago #300398 by krileon
Replied by krileon on topic How to translate text in text field

Something like create thousands of IF conditions in the PHP code field for each city translation?

Nope, you just need to run the string through CBTxt API. Example as follows.

return CBTxt::T( '[FIELD_NAME]' );

CBTxt is a namespaced class so you may need to use the full path as follows, but should already be declared.

return \CBLib\Language\CBTxt::T( '[FIELD_NAME]' );


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: mk3

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.220 seconds

Facebook Twitter LinkedIn