CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Easy way to localize your JavaScript using CCS localization utilities

Print topic Send  topic

Author Message
Lucius

Posts: 220
Posted: 02/22/2013, 2:07 PM

Hi,

Recently during development I started do delve more and more into JavaScript jQuery libraries and doing more and more interactive client-side coding.

Today I started to create my own jQuery library for JavaScript that simplifies adding jQuery client-side objects to my project.

Anyway one of the things I encountered is how to best use the localization resource files from CCS to localize my jQuery functions. I have found out an easy solution that uses CCS mechanisms that is already used to translate CCS generated js files. And it all took 5 minutes to set up!

1. CCS uses ClientI18N.php file to parse JS files to enable localisation. Create a copy of this file, and name it like "ClientI18N_Custom.php".

2. Open the new file in CCS or external editor and edit the following REGEX lines, so your custom JS file is allowed to be parsed:
$AllowedFiles = array(  
    "/^DatePicker\\.js$/" => "content-type: text/javascript; charset=$ClientFileEncoding",  
    "/^Functions\\.js$/" => "content-type: text/javascript; charset=$ClientFileEncoding",  
    "/^[\\w\\/]+_events\\.js$/" => "content-type: text/javascript; charset=$ClientFileEncoding"  
);
Remember to publish the new php file to the server !

3. In your HTML file link your custom JS file, so it's loaded through ClientI18N_Custom.php:
<script language="JavaScript"   
  src="/ClientI18N_Custom.php?file=/js/CustomFunctions.js&localeTWS={res:CCS_LocaleID}"   
  type="text/javascript" charset="utf-8"></script>

4. In your custom functions you can now use the same resource localisations, like you do in HTML:

function foo() {  
  var translatedString = "{res:my_localized_string}";  
  alert(translatedString);  
}

5. Profit 8-)
View profile  Send private message
DataDoIT
Posted: 02/22/2013, 4:11 PM

Very nice.
aiza

Posts: 1
Posted: 09/04/2013, 11:52 PM

That's excellent. I'd become resigned to disabling paging and sorting when using stored procedures. I'll try this next time.

_________________
pass4sure.mx [url=http://www.pass4sure.mx]pass4sure.mx[/url]
pass4sure network+ test questions [url=http://www.pass4sure.com/CompTIA-Network-plus.html]pass4sure network+ test questions[/url]
View profile  Send private message

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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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