locked
problem in multilanguage databinding controls RRS feed

  • Question

  • User1727401126 posted

    Hi Dear

    I have multilanguage site (http://www.iranpezeshkan.com). and I use Resource file to change language.

    but i have problem. how can i change the value of databinding value like state, city, ... dropdowns

    -------------------------

    Kohan Co (SoftWare Network Hardware)

    Thursday, July 11, 2013 6:22 AM

Answers

  • User1315475095 posted

    In my designs I have the City Table like CityID, CityName, CountryID

    I use a single table to handle all translations like:

    TableKeyID: the id of your table (same value: CityID) for example: 2

    TableFieldName: (the field you are translating) in this case CityID, you can have the same ID in City table and Country Table... and I'm not using tableName because maybe in the future you need to translate more than 1 field in the same table like CityName and CityDescription

    LanguageID....

    TableFieldValue: nvarchar(2000)  the translation you have to use nvarchar to store hebrew , chinese, arabic....

    so your query will look like:

    var list= (from City in db.City
            from DT in db.DataTranslation.Where(DT.TableKeyID=>City.CityID && DT.TableFieldName == "CityName" &&  DT => DT.LanguageID == languageID ).DefaultIfEmpty()
    select new  { ID = City.CityID, Name = (DT == null ? City.CityName : DT.TableFieldValue) }).AsQueryable();

     

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 12, 2013 3:30 PM

All replies

  • User1315475095 posted

    In your system you will need to store master data in the defaul language (english) and let the user to provide translation for each record in each available language in your system

    then you have to do a left join from your masterdata table with your table of translation to show values based on the selected user language, I suggest you to do a left join because it will show english description if translation is not provided

    Thursday, July 11, 2013 8:39 AM
  • User1727401126 posted

    can you explain more. how my query understood selected language.

    -------------------------

    Kohan Co (SoftWare Network Hardware)

    Thursday, July 11, 2013 8:58 AM
  • User1315475095 posted

    I think you have in some place: screen, user table the selected language

    then you need to send the language as parameter of your query

     

     

     

    Thursday, July 11, 2013 9:02 AM
  • User1727401126 posted

    I have City Table : ( [CityID] [, [CityName] )

    the data like    1  -  Tabriz     2 -   London   ,  .....

    the data bind bind in dropdownlist. the default language is English when change the language i want change the city name to other language

    (german, arabic , ...)

    I think i have it : Create master table like : ( [MasterID] [, [MasterName] ,[LangID] ) and left join with City.

    -----------------------------

    Kohan Co (SoftWare Network Hardware)

    Friday, July 12, 2013 3:13 PM
  • User1315475095 posted

    In my designs I have the City Table like CityID, CityName, CountryID

    I use a single table to handle all translations like:

    TableKeyID: the id of your table (same value: CityID) for example: 2

    TableFieldName: (the field you are translating) in this case CityID, you can have the same ID in City table and Country Table... and I'm not using tableName because maybe in the future you need to translate more than 1 field in the same table like CityName and CityDescription

    LanguageID....

    TableFieldValue: nvarchar(2000)  the translation you have to use nvarchar to store hebrew , chinese, arabic....

    so your query will look like:

    var list= (from City in db.City
            from DT in db.DataTranslation.Where(DT.TableKeyID=>City.CityID && DT.TableFieldName == "CityName" &&  DT => DT.LanguageID == languageID ).DefaultIfEmpty()
    select new  { ID = City.CityID, Name = (DT == null ? City.CityName : DT.TableFieldValue) }).AsQueryable();

     

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 12, 2013 3:30 PM