Drew Wutka
DWUTKA at Marlow.com
Tue Feb 24 13:09:22 CST 2009
(Whoops, posted this to OT first...) http://www.marlow.com/Translate.zip Sorry for the delay folks, I was sick all weekend and yesterday. Still feel like I walked into a wall this morning! But here's the database Rocky sent to me with a 'global class' handling the translations. I did a few things. First, I changed the table structure. I created a table called tblControlLanguages. The difference is that in the table I used, the language is a field value, instead of a separate field. I created an importlanguages function that took Rocky's initial table structure, and converted the data into the new table. There were a few duplicates and records where there was a blank form or control name. Deleted those. Then there is the Startup Function, which an Autoexec macro runs. That initiates the global class. Then each form has: Option Compare Database Option Explicit Dim WithEvents ContrlLang As ControlLanguage Private Sub ContrlLang_LanguageChanged() Dim ctrl For Each ctrl In Me.Controls If ContrlLang.Caption(Me.Name, ctrl.Name) <> "" Then ctrl.Caption = ContrlLang.Caption(Me.Name, ctrl.Name) End If Next End Sub Private Sub Form_Load() Set ContrlLang = CurrentControlLanguages ContrlLang_LanguageChanged End Sub Behind it. This way, when the form loads, it automatically gets it's controls set.... If you open Form1, you can change the language. If you keep the other forms open, you'll notice they all change when the language is changed (due to an event being raised by the ControlLanguage global instance! This is a nitty gritty example....no real errorhandling, and it doesn't do anything with fonts, which I believe Rocky mentioned he has to do for certain languages. But it shows how a global class (which loads when the app starts (and it loads in a split second...putting all that translation info into memory...and it hardly uses any space)) can handle something like this very quick and easy. And, as you can see, to add a new language, or to add a new form with controls, it's just adding records into the table (no need to change the table design for a new language...) Drew The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.