Web App Optimization

After reading through the excellent Xojo article on optimizing a web application, I have a questions about another optimization possibility.

I run a multilingual (fr/en) web application that is used by people in Canada. The tricky part with this is that a French speaking person could be using an English browser, thus I cannot rely on the browser localization. With the excellent ability for Xojo to force this (zDate(Session.StaffLanguage)) I am able to achieve what I need.

For every label, on every “page”, I add a single line of code to all Shown events, which means this triggers off MANY times for every page (me.text = zDate(Session.StaffLanguage). Would it be more efficient (faster application) if I populated all the labels at once, or individually?

All opinions are welcome. :slight_smile:

If I were in that boat, I’d try to figure out the easiest way to either let it happen in the browser, or before the page is delivered to the browser. How exactly to do it, I’m not sure but I’m pretty sure if nothing else, you could deliver all the words for that page to the browser in one go and then have a JS drop in the text.

I’d be surprised if someone hasn’t run into this and already come up with some sort of solution. I’ll be interested myself to see the other replies.

I develop web apps exactly with the same constraints for the same region. Precisely because of the fact that we cannot rely on the keyboard or on the browser language, I decided to forego the dynamic constants. Instead, all my application texts are in a database table. All my messages are in a separate table (just a choice, I could use just one table. But ) and all my form texts are in a third table. the key to the table is Text Number - Language. So, text 1 exists in French and also in English. Any other language could be added also. For languages, I use the ISO 3-letter codes. When the user logs in, he needs to select the language. The application texts table is loaded all at once into a session property (an array of strings). Every webcontainer or page has a method to apply the right string to the right UI element. It is fast and easy.

@Kevin Windham
I’ll take a look at this option as it makes a lot of sense…

@Louis Desjardins
Merci…C’est probablement une bonne idée. Cela me permettra d’apporter des modifications sans avoir à “compile” l’application.

Robert

@Robert Litchfield On ne sait jamais si l’idée plaira. D’autres pourraient ne pas l’aimer. Tant mieux si l’idée est utile!

You are correct Robert. I maintain texts directly in the database (I usually develop with MS SQL Server), so there is no need to recompile just for a text adjustment. One of my apps currently under development will allow to manage short track speed skating clubs. The text tables are designed with also the club identifier (the key is text number, club, language). The app includes a webcontainer designed to do text maintenance. The administrator for a club can adjust texts as required or desired, within design limits.

You do know that you can set Session.languagecode as well right? If users log in to access your app, just store their preferred language and set it when they log in… heck, you could use a cookie to store it! Then using dynamic constants still works!

Absolutely true. And certainly a good way to go when adjusting app texts “on the fly” without recompiling is not a requirement. It is always nice to have more than one option.