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
View Source
Translator()
Simple constructor for the Translator component
Declaration
View Source
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
View Source
ResourceAssembly
Declaration
public Assembly ResourceAssembly
Field Value
Properties
View Source
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
View Source
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
View Source
Count
Number of items in the resource file
Declaration
public int Count { get; }
Property Value
View Source
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
View Source
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
View Source
LookForResource
Declaration
public bool LookForResource { get; set; }
Property Value
Methods
View Source
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.
|
View Source
Dispose(bool)
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type |
Name |
Description |
| bool |
disposing |
|
Overrides
View Source
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
|
View Source
FindAssemblyResource(string)
Declaration
public static Stream FindAssemblyResource(string nfilename)
Parameters
| Type |
Name |
Description |
| string |
nfilename |
|
Returns
View Source
FindResource()
Declaration
public Stream FindResource()
Returns
View Source
FindResource(bool, ref bool, string, Assembly)
Declaration
public static Stream FindResource(bool searchonly, ref bool found, string nfilename, Assembly ResourceAssembly)
Parameters
Returns
View Source
GetLanguageDescriptions(IList)
Fills a list with language descriptions
Declaration
public static void GetLanguageDescriptions(IList alist)
Parameters
| Type |
Name |
Description |
| IList |
alist |
|
View Source
LoadFromFile(string)
Load the resource from a file.
Declaration
public void LoadFromFile(string filename)
Parameters
| Type |
Name |
Description |
| string |
filename |
|
View Source
LoadFromStream(Stream)
Load the resource from any Stream.
Declaration
public void LoadFromStream(Stream astream)
Parameters
| Type |
Name |
Description |
| Stream |
astream |
|
View Source
SaveFileJson(string)
Declaration
public void SaveFileJson(string fileName)
Parameters
| Type |
Name |
Description |
| string |
fileName |
|
View Source
SaveFileJsonDefault(string)
Declaration
public static void SaveFileJsonDefault(string fileName)
Parameters
| Type |
Name |
Description |
| string |
fileName |
|
View Source
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 |
|
View Source
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
View Source
UpdateContent()
Call this method to reload content from resource file
Declaration
public void UpdateContent()
Implements