ASP.net controls to use in localized web applications.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
wjkTranslateControls
LICENSE
README.md

README.md

wjkTranslateControls

ASP.net controls to use in localized web applications.

Preamble

Eine deutsche Version kannst auf unseren Wiki-Sits finden.

It just made me annoyed, always having to make "pull-ups", when I was developing multilingual sites without good tools. Of course, there are the ressouces, but honestly, to work with it makes really no fun.
I've already started early, dissolve the whole during the term. Unfortunately that was not the answer I liked. Therefore, I have tackled some time ago where the translation starts: on the Controls.
Why do we handed translate: Quite simply, the translators still afford not what we want.

. In the wjkTranslateControls are based controls that are overwritten, they implement a translation function.

Translation function you must see very flexible.


If anyone has interest, so there is no objection that our SQL interface (which we handed translate) is replaced by other methods. It may be remembered that, for example, interfaces to

  • "Google-" or "Bing-" translators can be implemented;
  • the EntityFramework is used;
  • other data bases are installed etc.

There is no limit to the number of languages ​​and the number of entries. Only the database sets the limits.


The controls are "only" overwritten, you will of course retain all other features in, so they are compatible to all based frameworks, with all CSS-forms, etc..

Also, no one is prevented from expanding to the whole, in our application, for example, a "View Level" is implemented (what it is, is irrelevant at the moment), we have omitted here. For this purpose, the code was extended easily using a property:

[Category("ToTranslate")] 
[Description("The enumerable of viewing for.")] 
[DefaultValue(translator.ViewLevel.All)] 
[Bindable(true)] [Localizable(true)] 
public translator.ViewLevel level 
{ 
	get 
	{ 
		if (ViewState["ViewLevel"] == null) return translator.ViewLevel.All; 
		return (translator.ViewLevel)ViewState["ViewLevel"]; 
	} 
	set 
	{ 
		ViewState["ViewLevel"] = value; 
	} 
}

The exact technique you can also at the Controls "tConfirmButton" and "tImageButton" look again and understand.

Description


wjkTranslateControls is all his own, that the authoritative "Text" (and other) property when rendering undergoes a database query. Here, it is determined whether the particular control on the page "abc", with ID "xyz" and the property "123" a text in the language of "ef" is present. The controls are always created in a base language, it is the foundation of later translation (see there).

By handling via "Page", "ControlID" and "Proberty", we achieve that the controls can be clearly recognized to have no extra effort when creating. The feature language we accesible by "CurrentUICulture.Name.SubString (0.2)", so actually only the language is used. Of course, this could also be another form wall.
We each control one additional feature brings "setPage". This was for the "master sites" necessary. Otherwise, any control of the master site would be recognized again for each page and had to be recompiled. Then "Page" maintained for all sides. The feature must not be set

If we did then use the property "text" this is only exemplary character. All the properties are translated as text in the database are stored and treated equally (see, For example. "NavigateURL" in "tLink" control).

Then there are three possible answers:


  1. The corresponding control in the base language exists, but with a other text, the text is updated and given back.
  2. The control in the base language or translated language not exist in the base language of the text is stored. The original text is returned.
  3. The control in the base language or translated language exists, the text from the database is returned.

The controls are according to relatives of their basic forms, they can be just pulled out of the toolbox on the page as the originals (for which they are unique in Visual Studio is installed (see Installation) In other respects, their application of their originals - with a few exceptions (see below).
Of course, they are also compatible with "bootstrap" and other extensions.

Installation


Simply download the zip file charge at GitHub[en] or on our "Wiki-Sits[en] and [de]" (it also includes this page).

Unpack it in your projects folder of Visual Studio (Express) 2012.

Open the folder and call the file "..\Visual Studio 2012\Projects\wjkTranslateControls\wjkTranslateControls\wjkTranslateControls.sln" in order to load the project.

Press F5 to see if everything runs or errors popping up, also it built in the "bin" folder the file "wjkTranslateControls.dll". Where you need now.

Stop debugging and open the "toolbox". Right-click there on a tab and choose "create a new tab" and name it "wjkTranslateControls". Then you right-click again on the newly created tab and select "Choose Items ...".
Now a new window appears, where you choose. "Net Framework Components" and go to "Browse" button. Navigate to "wjkTransalateControls" directory and there to "bin\debug" and select the. "Dll" file. Now you must confirm by selecting "OK".
After this little excursion should now appear in your toolbox the controls.

The aforementioned "DLL" must in all projects by using "Add Reference ..." referred to, in which you use the wjkTranslateControls.

To avoid that the controls are individually registered on all pages, you must in the "Web.config" still make the following entry:


    <System.web>
        <... >
        <pages controlRenderingCompatibilityVersion="4.0">
            <Controls>
                <add tagPrefix="wjk" namespace="wjkTranslateControls" assembly="wjkTranslateControls" />
            </Controls>
        </pages>
    </System.web>

Also, the base language is specified in the "web.config":


  <? Xml version = "1.0" encoding="utf-8">
  <configuration>
    <appSettings>
      <add key="baseLang" value="en"/>
      <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
    </appSettings>
    <...>
  

Now we have'll take care of the database. As we have already opened the "web.config", we carry this first one there:


  <...>
</appSettings>
<connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=[YOUR SQL-SERVER];Initial Catalog=[YOUR DATABASE];User ID=[YOUR DATABASE USER];Password=[YOUR PASSWORD]" providerName="System.Data.SqlClient" />
</connectionStrings>
    <system.web>
    <...>

In the project directory to "wjkTranslateControls" you can find the subdirectory "App_Data" and the file "tblRessources.sql" that you've got to perform, where the table should be created. Not forget to enter the database in the "Use" section of the script.


    USE [- INSERT your database name here -]
    GO
/****** Object:  Table [dbo].[tblRessources]    Script Date: 08/24/2013 12:08:59 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblRessources](
    [ID] [bigint] IDENTITY(1,1) NOT NULL,
    [lang] [nvarchar](10) NULL,
    [page] [nvarchar](100) NULL,
    [controlID] [nvarchar](100) NULL,
    [Property] [nvarchar](50) NULL,
    [Text] [nvarchar](max) NULL,
    [CreationDate] [datetime] NULL,
    [UpdateDate] [datetime] NULL,
    CONSTRAINT [PK_tblRessources] PRIMARY KEY CLUSTERED 
(
    [ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO


wjkTranslateControls


tLabel

This is the real origin of all of our control and there is not much to predict. Only the "Text" property is translated. "SetPage" we have explained above.

<wjk:tLabel ID="TLabel1" runat="server" setPage="Site.master" Text="tLabel"></wjk:tLabel>

Changed properties:
Text
setPage (optional)


tButton

tButton also has only a translation function for text. "SetPage" we have explained above.

<wjk:tButton ID="TButton1" runat="server" setPage="Site.master" Text="tButton" />

Changed properties:
Text
setPage (optional)



tCheckBox

tCheckBox also has to provide only the translation function for text. "SetPage" we have explained above.

<wjk:tCheckBox ID="TCheckBox1" runat="server" setPage="Site.master" Text="tCheckBox" />

Changed properties:
Text
setPage (optional)


tConfirmButton

tConfirmButton has much more to offer, it is only translated text.
Then, there is still the "ConfirmationMessage", i.e. as soon as you insert a text there, this appears when the button is clicked and the user can determine whether to trigger the action or not.
"SetPage" we have explained above.

<wjk:tConfirmButton ID="TConfirmButton1" runat="server" ConfirmationMessage="Go on?" setPage="Site.master" Text="tConfirmButton" />

Changed properties:
Text
setPage (optional)
New function:
ConfirmationMessage (optional)


tImageButton

tImageButton has much more to offer, it is "Alternate text (alt)" and "ImageUrl (src) 'translated.
Then there's the "ConfirmationMessage" as in "tConfirmButton", ie as soon as you insert a text there, this is displayed and the user can determine whether to trigger the action or not.
"SetPage" we have explained above.

<wjk:tImageButton ID="TImageButton1" runat="server" setPage="Site.master" AlternateText="wjk-logo" ConfirmationMessage="You clicked me. Go on?" ImageUrl="wjk75x75Trans.gif" />

Changed properties:
ImageUrl (src)
AlternateText (alt)
setPage (optional)
New function:
ConfirmationMessage (optional)


tLinkButton

tLinkButton knows only the translation of the text. "SetPage" we have explained above.

<wjk:tLinkButton ID="TLinkButton1" runat="server" setPage="Site.master" Text="tLinkButton"></wjk:tLinkButton>

Changed properties:
Text
setPage (optional)


tTemplateField und tBoundField

tTemplateField and tBoundField only know the translation of header text. Both "id" and "page" come from the parent control.
"SetPage" we have explained above.

<asp:GridView ID="GridView1" runat="server">
<Columns>
<wjk:tBoundField HeaderText="BoundField1" NullDisplayText="no Data" setPage="Site.master" />
<wjk:tTemplateField HeaderText="TemplateField1" setPage="Site.master"><ItemTemplate>No data</<ItemTemplate></wjk:tTemplateField>
</Columns> </asp:GridView>

Changed properties:
HeaderText
setPage (optional)

What still needs to be done

There are many building sites here. Some examples:


Translation tool

Of course still missing a tool that allows the database to be managed. Finally, the basic texts must be translated somewhere once.
We already have a ready-made tool, but it needs to be adjusted in the coming days. We hasten.

Missing controls

Some important controls are still missing and we would like to add some more functionality. Once we have some time, we will do it.

Code behind

We have also created classes that can be used in the source code. For example: myRessources.getRessource (and so on)
The're done, they'll just have to be revised, they resort to the same database and managed with the same tool.

Tooltips

This is a special building site because the tooltips are managed elsewhere. Who has come up with this(?).