![]() |
![]() |
|
![]() |
Subject: TIP:PdoxWin:Suggested way of providing language support:2001.02.11 Version 1.0 (2001.02.11) Written by Rick Kelly Edited by Mike Irwin: 2001.02.11 ==================== 0. Introduction ==================== This FAQ addresses the need for writers to support multiple languages in their users. In the US it is often overlooked that a sizable minority of the population is not really comfortable reading English, and, in many countries in Europe, despite their small size and obvious proximity to areas dominated by other languages, what might be termed "linguistic chauvinism" tends to run rampant. ------------------------------- 0.1 Legal Info and Disclaimers ------------------------------- Paradox is a trademark of Corel. Borland Database Engine (BDE) is a trademark of Inprise. The information provided in this FAQ is provided "as is" and is not warranted in any way. The information provided in this FAQ is not endorsed or authorized by Corel or Inprise in any shape, form, or manner. The editors claim NO responsibility for ANY illegal activity regarding this file, or as a result of someone reading this file. You may distribute this file, as long as the copies are complete, unaltered, and are in electronic form only. ------------- 0.2 Feedback ------------- Please send feedback in a Corel Paradox newsgroup or the news:comp.databases.Paradox newsgroup to any of the FAQ Team mentioned in the "FAQ: FAQ FAQ" document. Please preface the subject of your post with the string "PDXWIN FAQ" to alert Team members to the function of the message. Please specify the FAQ name and section number the comment applies to, if any. ------------- 0.3 Attachment ------------- LangTest.exe. This is a self-extracting Zip supplying the items mentioned in the text. ====================== 1. General Information ====================== English is the predominant global language of business and in marketing your applications, it may be necessary to support other languages. Even in-house developed applications may require multiple language support such as French in Canada. What follows is one way of supporting languages in applications developed using Corel Paradox. The techniques presented have been tested using version 8 and 9. To effectively support other languages, all visual textual elements of the user interface need a method of defining their values and the application requires a straightforward way for both default and current values to be defined and presented. Fortunately, ObjectPAL supports profile files. A profile file is an ASCII text file divided into sections beginning with a section header. Within each section, a keyword marker is followed by an equal sign with a value. For example: [Section1] Keyword1=Value1 Keyword2=Value2 [Section2] etc… A good example of this type of file is WIN.INI in MS Windows. We will use profile files to store current values for our visual textual elements using a unique section name for each form. In your applications you could also add a special section of “System” for application wide values. We also want our applications to function in the absence of any profile file with acceptable default values. ====================== 2. A Simple Example ====================== Lets start with a simple form containing one field with multiple radio buttons defining the months of the year. After adding this unbound field with values from 1 to 12 for each month of the year and rearranging the radio buttons a bit, our form would look like that shown in Fig1.jpg in the attachment. Our field name will be MonthOfYear and can contain a number from 1 to 12. Now lets change the labels for each value to the name of its associated month. Our form now looks like that shown in Fig2.jpg in the attachment. Tip: Give each label extra space. Different languages may require more space. There are 12 text labels to support. Now we will save this form as “LangTest” and return later. ====================== 3. Using a Library ====================== To keep each form independent from the mechanics of manipulating profile files and to maximize performance, we will encapsulate all the required methods in a library using a global method to return a DynArray of strings corresponding to the current values of each textual element. Our library “LangTest” will look like this: Type stringArray = DynArray[] String endType Var defaultStrings DynArray[] String endVar Proc ReadINI(iniFile String, sectionName String, keyName String, defaultValue String) Var keyValue String endVar ;............. ; Retrieve value, returns blank if not found ;............. keyValue = readProfileString (iniFile,sectionName,keyName) ;............. ; If value returned is blank, use default ; otherwise use what is found ; Our dynArray - defaultStrings is used to store the ; result keyed on the same keyName as the profile file ;............. switch case isBlank(keyValue) : defaultStrings[keyName] = defaultValue otherwise : defaultStrings[keyName] = keyValue endSwitch endProc ;=========================== Proc BuildDefaultStrings() var profileSource String endVar ;............. ; Source of the profile to use – replace yourAlias ; and yourName ;............. profileSource = getAliasPath("yourAlias") + "\\yourName.ini" sectionName = "LangTest" ReadINI(profileSource,”LangTest”,”Jan”,”January”) ReadINI(profileSource,”LangTest”,”Feb”,”February”) ReadINI(profileSource,”LangTest”,”Mar”,”March”) ReadINI(profileSource,”LangTest”,”Apr”,”April”) ReadINI(profileSource,”LangTest”,”May”,”May”) ReadINI(profileSource,”LangTest”,”Jun”,”June”) ReadINI(profileSource,”LangTest”,”Jul”,”July”) ReadINI(profileSource,”LangTest”,”Aug”,”August”) ReadINI(profileSource,”LangTest”,”Sep”,”September”) ReadINI(profileSource,”LangTest”,”Oct”,”October”) ReadINI(profileSource,”LangTest”,”Nov”,”November”) ReadINI(profileSource,”LangTest”,”Dec”,”December”) endProc method GetDefaultTextStrings() stringArray ;............. ; This is each forms interface to the dynArray of ; strings that we build ;............. return defaultStrings endMethod method open(var eventInfo Event) ;............. ; Build our dynArray of strings only once ;............. switch case defaultStrings.size() > 0 : otherwise : BuildDefaultStrings() endSwitch endMethod ====================== 4. Results ====================== Now we have a library that will check for our profile file and use it to override default text string values, storing the results in a dynArray that is made available through the GetDefaultTextStrings method. Our default profile file now looks like this: [LangTest] Jan=January Feb=February Mar=March Apr=April May=May Jun=June Jul=July Aug=August Sep=September Oct=October Nov=November Dec=December Returning the our earlier “LangTest” form, lets add the changes to use our library to retrieve the dynArray of strings and for each textual label to alter its value. At the form level: Type stringArray = DynArray[] String endType Var defaultStrings DynArray[] String endVar Uses ObjectPAL GetDefaultTextStrings() stringArray endUses method init(var eventInfo Event) var myLib Library endVar ;............. ; Open the library and retrieve the dynArray of ; text strings ;............. switch case myLib.open(":yourAlias:LangTest") = False : msgStop("Error",errorMessage()) eventInfo.setErrorCode(UserError) errorClear() close() otherwise : defaultStrings = myLib.GetDefaultTextStrings() myLib.close() endSwitch doDefault endMethod On each of the text labels on our “LangTest” form, add the following, changing “Jan” for each month (a total of 12 text labels Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec): method open(var eventInfo Event) self.value = defaultStrings["Jan"] endMethod ====================== 5. Testing ====================== That’s all there is to it! We now have a form that will us to override its text labels with whatever we want by building profile files. For fun, here are the month names in some other languages. Build profile files with them and watch your changes come to life. [LangTest] English French German Spanish Italian Jan= January Janvier Januar Enero Gennaio Feb= February Février Februar Febrero Febbraio Mar= March Mars März Marzo Marzo Apr= April Avril April Abril Aprile May= May Mai Mai Mayo Maggio Jun= June Juin Juni Junio Giugno Jul= July Juillet Juli Julio Luglio Aug= August Août August Agosto Agosto Sep= September Septembre September Septiembre Settembre Oct= October Octobre Oktober Octubre Ottobre Nov= November Novembre November Noviembre November Dec= December Décembre Dezember Diciembre Dicembrelangtest.exe Paradox Community Newsgroups |
![]() Feedback | Paradox Day | Who Uses Paradox | I Use Paradox | Downloads ![]() |
|
![]() The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation. Paradox is a registered trademark of Corel Corporation. ![]() |
|
![]() Modified: 15 May 2003 Terms of Use / Legal Disclaimer ![]() |
![]() Copyright © 2001- 2003 Paradox Community. All rights reserved. Company and product names are trademarks or registered trademarks of their respective companies. Authors hold the copyrights to their own works. Please contact the author of any article for details. ![]() |
![]() |
|