CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Translate content from DB in before show event.

Print topic Send  topic

Author Message
feha


Posts: 712
Posted: 01/13/2006, 7:21 PM

I made a small function out of CCS code

  
function VISION_TO_TRANSLATE($output)  
{  
global $CCSLocales;  
$output = preg_replace("/\\{res:\s*(\w+)\\}/ise", "\$CCSLocales->GetText('\\1')", $output);  
return $output;  
}  

in before show event add like this:

  
$new_content=VISION_TO_TRANSLATE($Page_Info_inc->content->GetValue());  
$Page_Info_inc->content->SetValue($new_content);  

set content label property to HTML ...
you will need to add your words manually in to locale text files ...

example {res:My_Translation}
if used in db content ...

you need to add:
My_Translation=My Translation

etc ...



_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
Walter Kempees
Posted: 01/19/2006, 6:10 AM

This is to translate dynamic data, obtained from database throug an SQL
statement, right ?
Nice solution, thanks.

But simpeler:
When doing a custom validation, how to use Internationalization?

  
form_field_on_validate  
if (condition)  
  $form->{Errors}->addError('A message in local language to be automatically   
translated when in another language'');  

Walter

feha


Posts: 712
Posted: 01/19/2006, 7:19 AM

Hi Walter
I'm glad you like it :-)

If you insert in to DB content any text as axample {res:_error_404_more}
it will be translated if found in locale files ...

This is good for making e-mail responders in different languages :-)

about error function should be similar ...

example for {res:_error_404_more}

  
form_field_on_validate    
if (condition)    
  $form->{Errors}->addError(VISION_TO_TRANSLATE("{res:_error_404_more}"));    

enjoy
:-)




_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
Walter Kempees
Posted: 01/19/2006, 1:33 PM

feha,
With respect to you for your solution, I figured out this one (partly
pointed by you)
see tips-and-solutions: onValidate Errormessages Internationalized



"feha" <feha@forum.codecharge> schreef in bericht
news:2543cfadee981b8@news.codecharge.com...
> Hi Walter
> I'm glad you like it :-)
>
> If you insert in to DB content any text as axample {res:_error_404_more}
> it will be translated if found in locale files ...
>
> This is good for making e-mail responders in different languages :-)
>
> about error function should be similar ...
>
> example for {res:_error_404_more}
>
>
  
> form_field_on_validate  
> if (condition)  
>  $form->{Errors}->addError(VISION_TO_TRANSLATE("{res:_error_404_more}"));  
> 
>
> enjoy
> :-)
>
>
>
>
> _________________
> Regards
> feha
> Vision.To Design
> www.vision.to
> wowdev.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

TGau
Posted: 02/01/2006, 4:13 AM

@feha:
Its possible to make it more simply.

function TranslateKey(& $Control){  
		global $CCSLocales;  
		$Control->SetValue($CCSLocales->GetText($Control->GetValue()));  
	}
This is a function for php4 working with assign by reference.

From Contol (DB) you just have to get the translation key without "res" afterwards there is the corresponding text from translation file.

TGau
feha


Posts: 712
Posted: 02/01/2006, 4:39 AM

Thank You TGau
This is much better :-)
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
Walter Kempees
Posted: 02/01/2006, 8:40 AM

nice one!

"TGau" <TGau@forum.codecharge> schreef in bericht
news:2543e0a6015e2ee@news.codecharge.com...
> @feha:
> Its possible to make it more simply.
>
>
function TranslateKey(& $Control){  
> global $CCSLocales;  
> $Control->SetValue($CCSLocales->GetText($Control->GetValue()));  
> }
> This is a function for php4 working with assign by reference.
>
> From Contol (DB) you just have to get the translation key without "res"
> afterwards there is the corresponding text from translation file.
>
> TGau
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.