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 -> General/Other

 [SOLVED] Are there any tutorials or detailed information in order to develop bilingual sites with CCS4?

Print topic Send  topic

Author Message
joejac

Posts: 242
Posted: 01/15/2009, 3:27 PM

Hello,
Are there any tutorials or detailed information, step by step, in order to develop bilingual dynamic sites with CCS4?. Any links are very much appreciated.
Thanks a lot
Regards
joejac
View profile  Send private message
jjrjr1


Posts: 942
Posted: 01/18/2009, 7:23 AM

Hi

Not that I know of. But it is really very easy.

Have you set the internationalization checkbox on in the project settings?

You must do this at the very beginning of the project. Then add the languages you want available in your project.

After that I think you will see how easy it is in CCS. You can right click on any text and provide translations. You also can specify translations for each component.

If you are displaying content on the site that comes from tables and needs translation, that is easily done also but does require minor custom coding.

Here is an example of a site I developed in 4 languages.

http://ccselite.com/gallery_view.php?gallery_image_id=9&gallery_cat_id=2

click on Visit TaxiFeeDemp link.

CCS implementation of multi language is awesome and really pretty easy. Even images can be specified by language.

Let me know if I can help.

Have Fun.

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
joejac

Posts: 242
Posted: 01/18/2009, 11:34 AM

Thanks a lot John for you kind advice.

All the sites I do are in a different language, not in english, but now I have to do one in 2 languages. In the past I did something with CC2.0.7 for one customer but very manual, I mean:

1.- I passed the language parameter in the URL: &language_no=1
2.- I created a function for each of the web page elements in common.php that displayed the corresponding text or image for the language parameter passed.
3.- The content came from a table: articles, each article belonged to a menu item that came form a menu table, for web site menu, and I stored the corresponding language for each menu item in the field language_no.

So the customer created the content in the language he needed and he selected the corresponding menu category of that language for the content, this was easy. But step 2 was a pain to do that. This was a long time ago and now I would like to update my development using the nice features of the new CCS4.

I will try the "internationalization checkbox" this week for my new customer.

1.- Your TaxiFee example is very nice, it automatically detected my language, I guess this is done automatically by CCS, wright, or it required manual coding?

Quote jjrjr1:

If you are displaying content on the site that comes from tables and needs translation, that is easily done also but does require minor custom coding ...

CCS implementation of multi language is awesome and really pretty easy. Even images can be specified by language.

Let me know if I can help.

Have Fun.


2.- Yes John, the content comes from tables, one for the menu and other for the articles (web pages), where I can find the "minor custom coding" information or tutorial?

Please note that the customer will translate the text by himself, I do not think it is a good idea the machine translation.

3.- "Even images can be specified by language" how can I do this?

Any tip to do this easily is very much appreciated. I use PHP5-MySQL5

Thanks a lot for your help.
Best regards.
joejac
View profile  Send private message
jjrjr1


Posts: 942
Posted: 01/18/2009, 2:02 PM

Hi JoeJac

Using the language feature is slick. But there is alot of things associated with it and I suggest you dig in and play with it. Here are some more tips and hopefully answers to your questions.

First you must have internationalization turned on before creating any pages. It is very difficult to add language support after the fact but not impossible. You will also see all the languages CCS supports and has basic translations in place for basic page components. (I suppose you can add any language you want also yourself),

First, there is no reason to create custom code in Common.php for your languages. CCS uses an object called CCSLocales which does all the work. And there are even methods for this object that allow you to maintain language translations in events custom code actions.

CCS uses the locale value (and others) that are standard values defined in PHP. eg locale en = english de = German etc... In taxifee I used the url paramter locale=en or de or sp or fr to affect the site language. There are other values you can use and even some session variables are available. Once you call any page with a locale value the site will display in that language till changed. In taxifee I did do some special coding like reset to a default language when logged out, set the sites default language to a specific value. etc.

You can explore the code in a main page source if created after internationalzation is turned on and you can will see how much of this and CCSlocales is implemented.

Hope that helps with the basic concept...

Next content.

CCS manages and maintains all the "Translation Dictionaries" for you. It creates text files in the root of your site like en.txt, de.txt, & fr.txt. These are translation tables for English, German, French... or what ever languages you are using.

Now it gets even better than that. You can select any control and view / edit the translations for any control you want. CCS supplies all the translations for the basic controls. It gets even better. You can select static text or blocks of static text on your page and assign all the translation for that block of text by right clicking on the selected text and select add / edit translation. So CCS is also managing your static text translation. Play with this also and you will quickly get the idea of how CCS is doing all this for you and it will become incredibly easy for you. What I did in taxifee (Basically because I added translation after the fact, much more difficult) I created a dummy page where I could generate the translations and cut and pasted the translated text to the original page. You might not need to do that.

Images are just as easy. Remamber en de fr??? Those little standard strings that designate locale and you might have used to set the sites language?? Well in your images directory just create a en / fr/ de directory and put your language specific images in each one. Be sure all the images have the same name for the same image just with a different language.

If CCS has not added this to your path for images just manually add it yourself in image properties.
example: <img src=images/{res:CCS_LocaleID}/imagename.jpg />

This also applies to style sheets that you might want to be language specific. If CCS does not automatically do it for you set style sheets like this.
<link rel="stylesheet" type="text/css" href="Styles/Taxi/{res:CCS_LocaleID}/stylepdf.css" />

And if you want FCKEditor and other javascript scripts that are language sensitive also pass
{res:CCS_LocaleID} for the argument to the language parameter.

Ok still with me I hope. I know this is a lot of info. But once you play with it it will all make sense.

Lastly. language specific tables. This is also easily done. In your before execute database type events like for select, deleted, or update. simply swithch in the appropriate table that has the content in the langiage you are working with.

What you have to create are identically structered tables for each language. So now when you switch the table based on your locale value you are updating and rertrieving the content using the correct language.

What I did in taxifee was to create identical tables called en_content de_content... and so on. In the before execute events just took the string _content and added the locale string to the beginning and replace the table name with that. Very simple and works like a chimp...

Note: if you do it like I did above it is easy if you create the form using a table without the en_ etc in front of the table name. Create all your ccs forms using that one. Be sure it works as you like on the form. Then clone the table to en_content de_content etc. That way you can debug and build your form with one table and it will work for all.

I hope this all helps. If you need more info after playing with this rather large chunk of info, feel free to let me know.

BTW. Language support in CCS is really so easy I was able to convert taxifee from single language to 4 in just 2 days. I was very impressed with CCS and this feature as anyone who knows me know I am a very slow coder. :-) So you should have no problem.

Have fun...

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
joejac

Posts: 242
Posted: 01/18/2009, 7:26 PM

Hello John, this is a great tutorial!

I appreciate a lot your valuable time for such a nice and detailed explanation, really great, because before I felt confused of how to start doing this, I wanted to do it in the right way from the very beginning.

My final 2 questions are:

1.- From your explanation I understand that one different table for each language ("en_content de_conten") is best than one single table for all, so I would have to do the same for the menu, like en_menu, es_menu, right?

2.- Doing all these different tables will not complicate the administrative module of the site?
Because I always provide the customer with the ability to create and change menu items as well as the content for each articles (web page).
2.1 The locales facilities will handle this for me or this will require a lot of custom programming?. My approach is the easiest administrative procedure for my customer, no complicated things.

Thanks a lot for such a nice advice :-)
Best regards
joejac
View profile  Send private message
jjrjr1


Posts: 942
Posted: 01/18/2009, 8:15 PM

Hi

Glad this has been helpful to you.

1. Some folks have tables with fields to indicate language of the data. You can certainly do it that way. But separate tables will allow better performance of your datanase. Sinc you would have to append the local value in every insert or update and build queries to select the data, you may as well switch to a different table instead. The place to make the table switch is in the before execute select, before execute insert, before execute update, and before execute delete. As long as all your tables are sructured the same and you swap in the new table in all 4 of those places, all edits, inserts basically all table maintenance is taken care of and the logic is the same for all functions. You just do it on the table set for that language. (This of course excludes blog or forum type tables unless you also want to keep the posts there separated by language.)

2. Menus are also handled by CCS unless you are using table data for the menu text. I have not implemented database driven menu text in multi language so you might have to look at that in CCS. For database driven menu text you might need to switch out those tables also.

2.1 CCSLocales class will handle most of your needs and I found very little custom programming is necessary to implement multi language support.

You will see exactly what I mean as soon as you start messing with is some.

Let me know if you need more info.

Have Fun

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
Stanj

Posts: 166
Posted: 01/18/2009, 9:07 PM

Hi John
Your detailed description was great. I just did not understand the multilanguage features of CCS so avoided them. I just created a simple test site for two languages to try it out; works great!

We should suggest that YESSoftware contract with you to rewrite the docs, they would save a great deal of time not having to answer so many Support questions regarding features.

_________________
Stan
St Petersburg Russia
View profile  Send private message
datadoit
Posted: 01/19/2009, 7:59 AM

Or YES could step up to the new millennium and get a dern wiki online!
jjrjr1


Posts: 942
Posted: 01/19/2009, 9:05 AM

I very am glad this helps out.

I felt the same as you Stanj. But, Like JoeJac, was forced to look at it for a clients requirement. I knew CCS had the ability but it seemed awfully complicated. But after trying it, I was very pleasantly suprised. My case was even worse since the site had been built and now the hidden MultiLanguage requirement crept in. Yes support said you could not add it to an existing project but it had to be set at the start. I was not prepared to start the site from the beginning again so, Baptism by fire or being a fool, I tackled it by adding it to an existing project. The benefit of that was I did get to delve into the code to see how it worked.

I think MultiLanguage support is one of the best kept secrets in CCS and, even though it sound intimidating, It is suprisingly easy to implement ,all things being considered.

We have considered an On-Line tutorial at CCS ELite on this subject.

Just have not had time to do it yat.

If you need any more info.... Let me know.

Have fun.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 01/19/2009, 10:08 AM

Incidentally....

Here is sample code for switching out the database names. This needs to be in all 4 before execute. update, insert, delete, select events as custom code.

global $locale; // you need to be sure this is set by you
$temp = $Component->DataSource->SQL;
$temp1 = $Component->DataSource->CountSQL;
$Component->DataSource->SQL=str_replace("content",$locale."_content",$temp);
$Component->DataSource->CountSQL=str_replace("content",$locale."_content",$temp1);

So, when you build your pages initially, as I explained before, use a table without the locale_ in the name. (In This Case it was content) This way the str_replace has the table name to change at run time. Now when you have the x number of language tables the proper language one is switched in before anything is done to the database and your application logic is the same for all languages.

As JoeJac asked, you can do this for menu tables, listbox tables, radio button tables,,, etc. Although Listbox and radio button tables might be canditates for the language to be a field in the table since not much mysql energy is used here. Up to you. If you do use field in listbox and radio button tables, remember you cannot necessarily use the URL locale parameter for the where statement for that table as the URL parameter will not necessarily persist. You will want to use one of the locale session variables based on how you set up internationalization. Use session locale or lang or whatever.

Note: You must be sure you have $locale set in every case. The example would be if your site is accessed without a ?locale= parameter. You need to set the default $locale (as a global) so the proper database table will be used.

eg: in some white space on the events page. (I usually put this kind of stuff at the very top of the page in the events file)

$locale = CCGetParam("locale",$YourDefaultLocaleString);

There are several variations of this depending on what language switch you are using. and of course the value of $locale needs to be set if you are using this example and need to swap DB tables. If you are not switching tables, none of this is needed.

Another note: to use the CCSLocales class in a event it must be declared global.

IE: good Idea to have these globals in all your event processing routines.

global $locale;
global $CCSLocales;

Hope this all makes sense.

Have fun

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
joejac

Posts: 242
Posted: 03/19/2009, 4:06 PM

Hello jjrjr1,

First thanks a lot, your tutorial is excellent and I was able to handle everything in internationalization until the last step: switching the database table names with the language. Let me say that your solution is perfect.

I got into problems because I had a query unnecessary complex. I suspected that was the problem after printing the SQL objects, so I simplified and finally it worked good.

So I do appreciate a lot your time in posting this excellent tutorial.
Best regards
joejac
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.

Web Database

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.