Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> i18n design / implementation
 

Pages: 1
LLBLGen Pro Runtime Framework
i18n design / implementation
Page:1/1 

  Print all messages in this thread  
Poster Message
lad4bear
User



Location:

Joined on:
22-Oct-2005 01:38:22
Posted:
192 posts
# Posted on: 22-Dec-2005 21:11:32.  
Hi Guys,

Am building a sample i18n app and have opted for the two table approach.

Table <EnittyName> contains language neutral informaton and Table <EntityName>Details containts language specific information. There is 1 ..* relationship between the <EntityName> Table and the <EntityName>Details Table. The PK of the <EntityName> Table is the <EntityName>.id and the PK of the <EntityName>Details Table is a compound key that includes the <EntityName>.id and the <EntityName>Details.language attribute. So I now have a situation where I can support as many languages as I like for each <EntityName> but only have a single instance of each language

For Example:

Quote:
Table Hotel
{
Id int (PK)
Name nVarChar(255),
StarRating int,
CountryId int, (FK)
CityId int, (FK)
AreaId int (FK)
}

Table HotelDetails
{
Id int, (PK)
Language char(2), (PK)
Summary nVarChar(1500),
Description nText,
}


So my data might look like the following:

Quote:
Table Hotel : 1 Row
-------------------------
id:1
Name: Hotel 1
StarRating 3
CountryId: 6
CityId: 14
AreaId: 6

Table HotelDetails : 2 Rows
-----------------------------------
Id: 1
Language: en
Summary: Hotel 1 Summary
Description
: Hotel 1 Description

Id: 1
Language: fr
Summary: Sommaire De l'Hôtel 1
Description
: Description De l'Hôtel 1


So now I am trying to figure out how to use the data that is in my tables using the code generated by LLBLGENPro. And I'm a bit baffled about where to start. i.e How would I go about selecting a single hotel with all of the required language specific information?

Hope this isn't too dumb a question.

Cheers,

Peter (aka lad4bear)


LLBLGENPro Version: 4.1
Framework: .Net 4.5.x
Database: SQL Server 2014
 
Top
bclubb
User



Location:
Norman, Oklahoma
Joined on:
12-Feb-2004 22:18:04
Posted:
934 posts
# Posted on: 23-Dec-2005 02:51:15.  
My suggestion would be to have HotelDetails look like this. Then you can set your relationship between tables using the HotelId and use the relation to access a HotelDetail collection.

Table HotelDetails
{
Id int, (PK)
HotelId int,
Language char(2),
Summary nVarChar(1500),
Description
nText,
}


  Top
lad4bear
User



Location:

Joined on:
22-Oct-2005 01:38:22
Posted:
192 posts
# Posted on: 23-Dec-2005 18:14:15.  
Hi there,

Thanks for wading through my original posting - it was a bit long! Regular Smiley

However, I'm not sure I understand your reponse. If I was to create a HotelEntity the HotelEntity.HotelDetails property will return a HotelDetailsEntity Collection which contains all rows that match the HotelEntity.id property. What I actually want to do is return only the HotelDetailsEntities where the HotelId matches and where the language equals the selected language.

Is it possible to apply a filter / predicate / somthing else to the HotelDetailsEntity collection so I can return the single row from the HotelDetails table I am interested in?

Again, thanks for your help.

Peter (aka lad4bear)
LLBLGENPro Version: 4.1
Framework: .Net 4.5.x
Database: SQL Server 2014
 
Top
pilotboba
User



Location:

Joined on:
05-Aug-2005 21:31:38
Posted:
434 posts
# Posted on: 23-Dec-2005 20:25:20.  
lad4bear wrote:

Is it possible to apply a filter / predicate / somthing else to the HotelDetailsEntity collection so I can return the single row from the HotelDetails table I am interested in?


This sounds like a basic multi-entity query to me. Did you read that section of the help?

BOb



  Top
lad4bear
User



Location:

Joined on:
22-Oct-2005 01:38:22
Posted:
192 posts
# Posted on: 27-Dec-2005 19:08:22.  
The following seems to work pretty well for me. I've hard-coded the Hotel Key and Language Filter but you get the idea.

Am only posting in case it proves useful to someone.

Cheers Pete (aka lad4bear)

Code:

    public class WebForm4 : Page
    {
        protected DataGrid DataGrid1;
        protected RadGrid RadGrid1;
        protected EntityCollection myHotels;            

        #region Web Form Designer generated code

        protected override void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.RadGrid1.NeedDataSource += new Telerik.WebControls.GridNeedDataSourceEventHandler(this.RadGrid1_NeedDataSource);
            this.RadGrid1.DetailTableDataBind += new Telerik.WebControls.GridDetailTableDataBindEventHandler(this.RadGrid1_DetailTableDataBind);
        }

        #endregion


        private void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            if(! e.IsFromDetailTable )
            {
                //    Create Hotel Collection
                myHotels = new EntityCollection( new HotelsEntityFactory());

                //    Create Filter        
                IPredicateExpression filter = new PredicateExpression();
                filter.Add(PredicateFactory.CompareValue(HotelsdetailsFieldIndex.HotelsDetailsLanguageCode, ComparisonOperator.Equal, "en"));

                //    Create Prefetch Path
                IPrefetchPath2 prefetchPath = new PrefetchPath2((int) EntityType.HotelsEntity);
                prefetchPath.Add(HotelsEntity.PrefetchPathHotelsdetails, 1, filter);

                //    Retrieve Data using DataAdapter
                using (DataAccessAdapter adapter = new DataAccessAdapter())
                {
                    adapter.FetchEntityCollection(myHotels, null, prefetchPath);
                }

                RadGrid1.MasterTableView.DataSource = myHotels;
            }
        }

        private void RadGrid1_DetailTableDataBind(object source, Telerik.WebControls.GridDetailTableDataBindEventArgs e)
        {
            GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
            
            Int32 HotelsKey = Convert.ToInt32(parentItem["HotelsKey"].Text);

            Int32 HotelsIndex = myHotels.Find(
                new EntityPropertyDescriptor2(EntityFieldFactory.Create(HotelsFieldIndex.HotelsKey),
                typeof(HotelsEntity), false), HotelsKey );

            
            HotelsEntity currentHotel = (HotelsEntity)myHotels[HotelsIndex];
            
            e.DetailTableView.DataSource = currentHotel.Hotelsdetails;
        }
LLBLGENPro Version: 4.1
Framework: .Net 4.5.x
Database: SQL Server 2014
 
Top
lad4bear
User



Location:

Joined on:
22-Oct-2005 01:38:22
Posted:
192 posts
# Posted on: 06-Feb-2006 21:08:03.  
Although the code I outlined above works but it seems a little awkward. I know you guys are already working extra hard on version 2.0 (something I'm very excited about) but are there plans with LLBLGENPro v 2.0 to provide support for databases that require i18n?

I guess in the general sense it would require the ability to 'flatten' a two table relationship into a single entity based on a discriminating field(s) in the * side of the relationship. In this case languageCode. Because in reality a single Hotel entity actually spans two tables (Hotel and HotelDetails).

It would be nice to be able to write something like the code below rather the code outlined in my previous post :

Code:

// create a new HotelEntity
MyHotelEntity = new HotelEntity();

// set the details. note: no need to use MyHotelEntity.HotelDetails property
MyHotelEntity.Name = "HotelName";
MyHotelEntity.LanguageCode = 'en'; // descrimnator
MyHotelEntity.StarRating = 5;
MyHotelEntity.Description = "HotelDescription in French";

// save the entity:
MyHotelEntity.Save();


I would appreciate your feedback on whether this is something we can see in the future.

And I'd also be interested to hear how other developers have used LLBLGENPRO to work with databases that require i18n.

Cheers, Pete


LLBLGENPro Version: 4.1
Framework: .Net 4.5.x
Database: SQL Server 2014
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37803 posts
# Posted on: 07-Feb-2006 08:48:42.  
THere aren't plans to support in general n-table entities without inheritance. (only through inheritance).

This because we've seen multiple ways of doing this in the last couple of years, so which technique we'll pick might not match what some people want (and thus mitigate the usage of it).

The problem is that some choose to store all translations in one table, defining subtypes on that table, while others want to merge 2 or more tables over a relation (m:1).
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
lad4bear
User



Location:

Joined on:
22-Oct-2005 01:38:22
Posted:
192 posts
# Posted on: 07-Feb-2006 17:37:57.  
Hi Otis,

Thanks for the feedback. Am happy to use inheritence to deal with this. Haven't used this inheritance feature yet so will have to hit the help files. Could you give any pointers i.e TargetPerEntityHierarchy vs SomeOtherOption ?

Cheers, Pete


LLBLGENPro Version: 4.1
Framework: .Net 4.5.x
Database: SQL Server 2014
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37803 posts
# Posted on: 10-Feb-2006 10:30:47.  
lad4bear wrote:
Hi Otis,

Thanks for the feedback. Am happy to use inheritence to deal with this. Haven't used this inheritance feature yet so will have to hit the help files. Could you give any pointers i.e TargetPerEntityHierarchy vs SomeOtherOption ?
Cheers, Pete

It will take more than that I'm afraid. Inheritance can be used to map an entity onto multiple 1:1 related tables, through inheritance, (every 1:1 related table is a subtype of the PK side) so not what you need.

Sometimes the following is done: store all translations into one table, and use the language type field as a discriminator column and define subtypes for each language in the llblgen pro designer. You can then fetch all english translations by simply doing an entity collection fetch for the english subtype.

Though I'm not sure if this fits your requirements.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
lad4bear
User



Location:

Joined on:
22-Oct-2005 01:38:22
Posted:
192 posts
# Posted on: 10-Feb-2006 16:09:46.  
Hi Otis,

Does this mean I would I have to explicitly create a sub-type for each supported language (for each i18n entity) in the designer?

Cheers,

Pete


LLBLGENPro Version: 4.1
Framework: .Net 4.5.x
Database: SQL Server 2014
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37803 posts
# Posted on: 12-Feb-2006 14:31:10.  
lad4bear wrote:
Hi Otis,

Does this mean I would I have to explicitly create a sub-type for each supported language (for each i18n entity) in the designer?

Yes. Though I don't know if it's worth the effort, as you always will keep the has-a relationship: the translated description field will never become a part of the entity which is containing the description field which is translated.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
VerlSnake
User



Location:
Paderborn, Germany
Joined on:
03-Jun-2008 21:11:00
Posted:
1 posts
# Posted on: 03-Jun-2008 21:23:23.  
What are the current recommendations for providing g11n/i18n/l10n in the persistence layer
? Has the advent of new technologies like LINQ changed the game "i18n in databases" ?

I would very much appreciate a step-by-step instruction guide which tells LLBLGen Pro users how to provide i18n in their back-ends. It should be a topic which is important enough to justify spending some time on it; so that not everybody facing the problem "i18n in databases" has to reinvent this i18n-wheel ...


  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 04-Jun-2008 11:13:04.  
IMHO, there is no fixed standard for Internationalization.
Quote:
I would very much appreciate a step-by-step instruction guide which tells LLBLGen Pro users how to provide i18n in their back-ends.

You came to the right thread, please check Pete's (lad4bear) example above
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.