Class Translator
Translator component helps in translating aplications to multiple languages
using current user regional configuration loads the specified file
with the regional extension for the file
Assembly: Reportman.Drawing.dll
Syntax
public class Translator : Component, IComponent, IDisposable
Constructors
Translator()
Simple constructor for the Translator component
Declaration
Translator(IContainer)
Translator is a component to help the translation of applications in multiple languages.
It can open a translation file created from Report Manager Translation utility.
It's capable of searching for a file with a file extension according to the regional
settings, that is for example if regional setting is Spanish Mexico, it will search for
a file with extension .ESM, but if not found, it will search for a file with extension .ES.
Declaration
public Translator(IContainer container)
Parameters
| Type |
Name |
Description |
| IContainer |
container |
The container of the Translator, when used in Windows.Forms designer
|
Fields
ResourceAssembly
Declaration
public Assembly ResourceAssembly
Field Value
Properties
Active
Set this property to true to open the resource file.
Before obtaining translations, this property must be set.
Declaration
public bool Active { get; set; }
Property Value
AutoLocale
When this property is set to true, the provided file name will
extended with the current user regional extension
Declaration
public bool AutoLocale { get; set; }
Property Value
Count
Number of items in the resource file
Declaration
public int Count { get; }
Property Value
Filename
Resource file to load strings from, you usually provide
the file name without extension, so with, Autolocale set
to true, the extension will be added based on the current
user regional settings.
Declaration
public string Filename { get; set; }
Property Value
this[int]
You can access translation providing an integer index.
The Active property must be set to true before accessing translations
Declaration
public string this[int index] { get; }
Parameters
| Type |
Name |
Description |
| int |
index |
|
Property Value
LookForResource
Declaration
public bool LookForResource { get; set; }
Property Value
Methods
AddString(string)
You can add elements to the resource using this function.
Declaration
public int AddString(string astring)
Parameters
| Type |
Name |
Description |
| string |
astring |
|
Returns
| Type |
Description |
| int |
Returns the index for the element added.
|
Dispose(bool)
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type |
Name |
Description |
| bool |
disposing |
|
Overrides
FileExists()
Check if the resource file exists.
Declaration
Returns
| Type |
Description |
| bool |
Returns true if the resource file exists or a resource can be found
|
FindAssemblyResource(string)
Declaration
public static Stream FindAssemblyResource(string nfilename)
Parameters
| Type |
Name |
Description |
| string |
nfilename |
|
Returns
FindResource()
Declaration
public Stream FindResource()
Returns
FindResource(bool, ref bool, string, Assembly)
Declaration
public static Stream FindResource(bool searchonly, ref bool found, string nfilename, Assembly ResourceAssembly)
Parameters
Returns
GetLanguageDescriptions(IList)
Fills a list with language descriptions
Declaration
public static void GetLanguageDescriptions(IList alist)
Parameters
| Type |
Name |
Description |
| IList |
alist |
|
LoadFromFile(string)
Load the resource from a file.
Declaration
public void LoadFromFile(string filename)
Parameters
| Type |
Name |
Description |
| string |
filename |
|
LoadFromStream(Stream)
Load the resource from any Stream.
Declaration
public void LoadFromStream(Stream astream)
Parameters
| Type |
Name |
Description |
| Stream |
astream |
|
SaveFileJson(string)
Declaration
public void SaveFileJson(string fileName)
Parameters
| Type |
Name |
Description |
| string |
fileName |
|
SaveFileJsonDefault(string)
Declaration
public static void SaveFileJsonDefault(string fileName)
Parameters
| Type |
Name |
Description |
| string |
fileName |
|
SetDefaultTranslatorPath(string)
You can override the default path to the search of translation files, useful for example
when your translation files are not in the application directory, for example in web
applications
Declaration
public static void SetDefaultTranslatorPath(string apath)
Parameters
| Type |
Name |
Description |
| string |
apath |
|
TranslateStr(int)
TranslateStr is a class function, can be called without instantiating any
Translator, it will look for reportmanres.xxx resource files
the file must be in path, else a default string will be returned
this.Text=Reportman.Translator.TranslateStr(4);
Declaration
public static string TranslateStr(int index)
Parameters
| Type |
Name |
Description |
| int |
index |
|
Returns
UpdateContent()
Call this method to reload content from resource file
Declaration
public void UpdateContent()
Implements