Unit F_Lang

F_Lang.pas Autor: (c) José Mª Gías sigecom@arrakis.es 18.04.98 Freeware F_Lang.Dcu Shareware F_Lang.Pas Commentary un English and Spanish English ------------------------------------------------------------------------------ This Unit, it contains the necessary functions to obtain the @@strings of the components of an Form and to write them in a table in the language field indicated. For defect table will be called GLang.Dbf and will be kept in the directory in which take-off the application, but we can incorporate it into an Alias instead of indicating to you a directory. In principle this preparation for Spanish, Italian, English, German, French and Portuguese, but enough with adding or erasing language fields in table so that it is adapted to our needs. Table by defect is .Dbf, but is wished enough with indicating a table with extension .Db so that it will be Paradox. To generate initial table one must to call to the procedure 'DbfStringComponen an alone time, and automatically will create table that we indicate to you in the language elected. If we indicate 'All' will fill all the fields. There is no limit of quantity of form incorporated to table, enough with calling to this procedure once by each created Form and will add the data of the same. Also it incorporates the necessary functions to recover the stored String in table and to return them to our Form in the language that we indicate to you. For this enough with calling to the procedure 'LangDbfComponent' As miscellany is included the function of recording the String in a file .Ini Examples of call: -------------------------------------------------------------------------------- // Call to add the data in GLang.dbf procedure TForm1.Button2Click(Sender: TObject); var Dir : String; begin Dir := ExtractFilePath(ExpandFileName('Demo1.Exe')); if Dir[Length(Dir)] <> '\' then Dir := Dir + '\'; Table1.DatabaseName := Dir; Table1.TableName := 'Lang.Dbf'; ExisteTabla(Table1, Dir); Table1.Close; // To capture the string of the components DbfStringComponent(Table1, // Data Table Form1, // Form of where they are captured the string Dir, // DatabaseName, o directory of de application 'ALL', // Languages that will fill in table. SP,IT,EN,DE,FR,PO,(ALL) True, // To write the Strings in White False;) // ReWrite existing String in table // As of here it can be called to the procedure as many times as Form they may // have been created with precedence, or well to create them, to call to the // function and to eliminate them subsequently. This alone will be necessary to // accomplish it an alone time in design time. ShowMessage('Process Finish'); end; -------------------------------------------------------------------------------- // Call to recover the String from a language of table procedure TForm1.Button3Click(Sender: TObject); begin LangDbfComponent(Table1, // Data table Form1, // Form of the that will be obtained the data 'SP'); // Language that will catch in table. SP,IT,EN,DE,FR,PO end; -------------------------------------------------------------------------------- // Call to add the data in a fichero.ini procedure TForm1.Button1Click(Sender: TObject); begin // Si incluimos la claúsula una vez por idioma, nos los irá añadiendo secuencialmente en el fichero .Ini para traducir despues y poder llamar mas tarde desde la aplicación el idioma deseado. IniStringComponent(Form1, // Form del que obtendrá los datos 'GLang', // Nombre del fichero .INI (Lo dejará en el directorio \Windows 'English'); // Nombre del Idioma. end; Español -------------------------------------------------------------------------------- Esta Unit, contiene las funciones necesarias para obtener las strings de los componentes de un Form y escribirlas en una tabla en el campo de lenguaje indicado. Por defecto la tabla se llamará GLang.Dbf y se guardará en el directorio en que arranque la aplicación, pero podemos incorporarla a un Alias en lugar de indicarle un directorio. En principio esta preparado para Español, Italiano, Ingles, Aleman, Frances y Portugues, pero basta con añadir o borrar campos de idioma en la tabla para que se adapte a nuestras necesidades. La tabla por defecto es .Dbf, pero si se desea basta con indicar una tabla con extensión .Db para que sea Paradox. Para generar la tabla inicial hay que llamar al procedimiento 'DbfStringComponent' una sola vez, y automáticamente creará la tabla que le indiquemos en el idioma elegido. Si indicamos 'All' rellenará todos los campos. No hay límite de cantidad de form incorporados a la tabla, basta con llamar a este procedimiento una vez por cada Form creado y añadirá los datos del mismo. También incorpora las funciones necesarias para recuperar las String almacenadas en la tabla y devolverlas a nuestro Form en el idioma que le indiquemos. Para ello basta con llamar al procedimiento 'LangDbfComponent' Como miscelanea se incluye la función de grabar las String en un fichero .Ini Ejemplos de llamada: -------------------------------------------------------------------------------- // Llamada para añadir los datos en Lang.dbf procedure TForm1.Button2Click(Sender: TObject); var Dir : String; begin Dir := ExtractFilePath(ExpandFileName('Demo1.Exe')); if Dir[Length(Dir)] <> '\' then Dir := Dir + '\'; Table1.DatabaseName := Dir; Table1.TableName := 'Lang.Dbf'; ExisteTabla(Table1, Dir); Table1.Close; // Capturar los textos de los componentes DbfStringComponent(Table1, // Tabla de Datos Form1, // Form de donde se capturan los datos Dir, // DatabaseName, o directorio de la aplicación 'ALL', // Idiomas que rellenará en la tabla. SP,IT,EN,DE,FR,PO,(ALL Todos) True, // Grabar los Strings en Blanco False;) // Sobreescribir las String existentes en la tabla. // A partir de aquí se puede llamar al procedimiento tantas veces como Form // se hayan creado con anterioridad, o bién crearlos, llamar a la función y // eliminarlos seguidamente. Esto solo será necesario realizarlo una sola vez // en tiempo de diseño. ShowMessage('Proceso terminado'); end; -------------------------------------------------------------------------------- // Llamada para recuperar los String desde un idioma de la tabla procedure TForm1.Button3Click(Sender: TObject); begin LangDbfComponent(Table1, // Tabla de datos Form1, // Form odel cual se obtendrán las string de los componentes 'SP'); // Lenguaje que se añadirá a la tabla. SP,IT,EN,DE,FR,PO end; -------------------------------------------------------------------------------- // Llamada para añadir los datos en un fichero.ini procedure TForm1.Button1Click(Sender: TObject); begin // Si incluimos la claúsula una vez por idioma, nos los irá añadiendo secuencialmente en el fichero .Ini para traducir despues y poder llamar mas tarde desde la aplicación el idioma deseado. IniStringComponent(Form1, // Form del que obtendrá los datos 'GLang', // Nombre del fichero .INI (Lo dejará en e directorio \Windows 'English'); // Nombre del Idioma. end;

Classes

Functions

DbfStringComponent - Add the data in GLang.
GetComponentProp - Returns the value or content of a property if exists Devuelve el valor o contenido de una propiedad si esta existe

Get property component if exists Devuelve el valor o contenido de una propiedad si esta existe
GrabaReg - Record a record with the data of a property Graba un registro con los datos de una propiedad

Record a record with the data of a property Graba un registro con los datos de una propiedad
IfExistsTable - Watch exist table GLang, and if it does not create it Mira si existe la tabla Lang, y si no la crea

Mira si existe la tabla de Idioma, y si no la crea Watch exist table GLang, and if it does not create it
IfProperty - Says us if a component has the indicated property Nos dice si un componente tiene la propiedad indicada

True if Exist property of component Devuelve True si esxiste la propiedad en el componente
LangDbfComponent - Returns the String of the language selected for the form past Devuelve los String del idioma seleccionado para el form pasado

Returns the String of the language selected for the form past Devuelve los String del idioma seleccionado para el form pasado
LeeReg - Read a record with the data of a property Lee un registro con los datos de una propiedad

Read a record with the data of a property Lee un registro con los datos de una propiedad
SetComponentProp - Change the content of the property of the component Cambia el contenido de la propiedad del componente

Set property component Cambia el contenido de la propiedad del componente

Types

Constants

Variables

FicLang
Lenguage


Functions


procedure DbfStringComponent(var T : TTable; Form : TForm; Dir, Lang : String; Blancos, ReWrite : Boolean);

Add the data in GLang.dbf with the String of the components of a Form Añade los datos en Lang.dbf con las String de los componentes de un Form

try


function GetComponentProp(C: TComponent; Name: String): String;

Returns the value or content of a property if exists Devuelve el valor o contenido de una propiedad si esta existe

Get property component if exists Devuelve el valor o contenido de una propiedad si esta existe


procedure GrabaReg(var T: TTable; Lang : String; ReWrite : Boolean);

Record a record with the data of a property Graba un registro con los datos de una propiedad

Record a record with the data of a property Graba un registro con los datos de una propiedad


procedure IfExistsTable(var Table1 : TTable; Dir : String);

Watch exist table GLang, and if it does not create it Mira si existe la tabla Lang, y si no la crea

Mira si existe la tabla de Idioma, y si no la crea Watch exist table GLang, and if it does not create it


function IfProperty(C: TComponent; Propiedad : String) : Boolean;

Says us if a component has the indicated property Nos dice si un componente tiene la propiedad indicada

True if Exist property of component Devuelve True si esxiste la propiedad en el componente


procedure LangDbfComponent(var T : TTable; Form : TForm; Lang : String);

Returns the String of the language selected for the form past Devuelve los String del idioma seleccionado para el form pasado

Returns the String of the language selected for the form past Devuelve los String del idioma seleccionado para el form pasado


procedure LeeReg(var T: TTable; Lang : String);

Read a record with the data of a property Lee un registro con los datos de una propiedad

Read a record with the data of a property Lee un registro con los datos de una propiedad


procedure SetComponentProp(C: TComponent; const Name, Valor: String);

Change the content of the property of the component Cambia el contenido de la propiedad del componente

Set property component Cambia el contenido de la propiedad del componente


Types


Constants


Variables

FicLang : String

Lenguage : String