cLocalization

Zurück Home
 

 

Description

cLocalization enables the integration of language files exported with vbLocalization Manager.
This class can only be used in combination with vbLocalization Manager.

Content

Properties
Methods
Events
Notes
Language File Specification
Sample
Module
Version History
See Also

Properties

.Changed As Boolean

True if the file content has changed since the last load or save process.

.LastError As String

Last occurred error.
Read only.

.Folder As String

Folder loaded with GetFiles.
Read only.

.Languages As Variant

Variant String Array. Names (without Extension) of the language files found by GetFiles.
These Names represent the available languages.
Read only.

[.Item](OriginalText As String,[Value1 As Variant, Value2 As Variant, ...]) As String

Translation of OriginalText.
Value1 to ValueN are values that replace the corresponding placeholders.
The property returns the original text (with replaced placeholders) if no translation is found.
Standard property.
Read only.

.ItemA(OriginalText As String) As String

Translation of OriginalText.
The property returns a Nullstring if no translation is found.
Placeholders are returned and saved unchanged.

.Keys As Variant

Variant String Array containing all original/source text entries. Read only.

.Items As Variant

Variant String Array containing all translation entries. Read only.

.Language As String

Currently loaded language.
Read only.

.CurrentFile As String

Path of the currently loaded language file.
Read only.

.CharSet As Long

The used char set of the translation. This property is needed for proper display.
The property is saved to the language file.
ANSI is taken as default.

.RightToLeft As Boolean

This property is set to True, if the language direction is RTL.
The property is saved to the language file.

.CharSets As Scripting.Dictionary

Handle to a Scripting.Dictionary. Contains the key-value pairs for the loaded CharSets: Description (String) = CharSet (Long)
See LoadCharSets

Methods

.GetFiles(Folder As String, [FileExtension As String]) As Boolean

Reads the files of the Folder.
Only files with the specified FileExtension are read. Standard is "lng".
The method returns a Boolean value, that is False if errors occurred during the read process.

.Load(Language As String) As Boolean

Loads the specified language file by the name (Language).
The method returns a Boolean value, that is False if errors occurred during the load process.

.LoadA(Language As String) As Boolean

Loads a language file that is v2.08 alpha5-. This method is called by Load and LoadFile, if the file is not v2.11 alpha6+

.LoadFile(FilePath As String) As Boolean

Loads the specified language file by the path.
The method returns a Boolean value, that is False if errors occurred during the load process.

.Save(FilePath As String) As Boolean

Saves the currently loaded language file.
The method returns a Boolean value, that is False if errors occurred during the save process.

.ClearFiles

Removes all files from the current list.
No return.

.ClearTranslation

Removes all translated values from the currently loaded language file.
No return.

.LoadCharSets(Optional FilePath As String) As Boolean

Loads all available char sets from the specified file. The file is delivered with the class: charsets.ini
If no file is specified, the default char sets are loaded.
The method returns a Boolean value, that is False if errors occurred during the save process.

.ReadTextFileU(ByRef FilePath As String, Optional Format As Tristate = TristateTrue) As String

Reads the specified file and returns the content.
Tristate determines whether the file is uses narrow (1 byte) or wide characters (2 byte; Unicode).
If an error occurs, vbNullChar is returned.

WriteTextFileU(ByRef FilePath As String, ByRef Text As String, Optional Format As Tristate = TristateTrue) As Boolean

Writes the specified file from a string and returns True if the process succeeds otherwise False.
Tristate determines whether the file is uses narrow (1 byte) or wide characters (2 byte; Unicode).
The file is created if it doesn't exist. Existing files are overwritten.

 

Events

_OnError(Message As String)

Event is raised if an error occurs.

Notes

Placeholders are replaced by the corresponding values during runtime, when you are accessing the Item property.

Placeholder Description
%b Line break (vbCRLF)
%t Tab Character
%1 ... %N Values, that are passed as arguments. (Item property)

Language names are the names of the language files without extension.

Methods and properties meant for editing language files are needed only for editing but not for common access. Therefore they are displayed in green color.

Language File Specification

Language files are saved as DBCS UNICODE. The files can be edited with Notepad.

The language file header is enclosed in a head-Tag and contains language specific information.

For properly displaying Unicode languages, the Font Charset property needs to be set to the right code page.

  Unicode languages are displayed without limitation, but only on systems having this language set to default.
For example you will not be able to edit (in vbLM) or display a Greek language file on a English system for which the default language is set to something else than Greek.

Sample


HTML Samples created with vbConverter

Module

cLocalization (v0.2 alpha2)

Needs fso as Scripting.FileSystemObject and the 'Microsoft Scripting Runtime' reference.

Version history

0.2 alpha 2 - Default charsets don't need to be loaded from the ini file. Just use LoadCharSets ""
                 - Removed LCID functionality including modLoc.bas
2.11 alpha8 - Functions ReadTextFileU and WriteTextFileU are public
                  - Fixed: CRLF in assigned translation is automatically replaced with %b
2.11 alpha7 - Unicode languages are displayed without limitation, but only on systems having this language set to default
                    the LCID property is no longer needed, as no conversions take place anymore
2.11 alpha6 - added Unicode support: LCID, CharSet, RightToLeft, LoadLCIDs, LCIDs, LoadCharSets, CharSets
                    LoadA for loading old (non-unicode) language files
                    Keys and Items properties and OnError event
2.08 alpha5 - changed: GetItem, SetItem -> ItemA
2.08 alpha4 - improved error message (LastError) for file operations
2.08 alpha3 - updated TextFile functions
2.08 alpha2 - added: Save, Language, SetItem, strExtension (GetFiles), CurrentFile, LoadFile, Folder

See also

vbLocalization Manager

     


© 2002-2007 VBX System