+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Localized News

Localized News

6 posts, 1 answered
  1. Kostadinka
    Kostadinka avatar
    16 posts
    Registered:
    27 Jul 2010
    27 Jul 2010
    Link to this post
    Hi,

    I'd like to have localized news. I have this in my web.config:

    in section 
    <cmsEngine defaultProvider="Generic_Content"
      
    <providers> :

     

      

     

     

    <add name="News" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" securityProviderName="" allowVersioning="True" applicationName="/News" versioningProviderName="" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.News.Data.DefaultNewsProvider, Telerik.News.Data" allowLocalization="true"/>

    in section

    <metaFields>: 

     

     

     

     

    <add key="News.Title" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" localizable="true"/>

    The generated URL for news are localized and in some languages they are unaccessible. But I need localized Title.
    Any suggestions?

    Thanks in advanced.

     

     

     

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    27 Jul 2010
    Link to this post
    Hello Kostadinka,

    1. You should enable localization for the whole website through <localization> node

    <localization defaultProvider="Sitefinity" persistenceMode="PathPrefix" defaultCulture="en" cultures="en, es, fr, de, bg, ar, pt, no, tr, cs, nl" >

    2. Then when you create a content item on the left side there is a holder with links that you can use copy an item from one language to another.

    I attached a sample video.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Kostadinka
    Kostadinka avatar
    16 posts
    Registered:
    27 Jul 2010
    27 Jul 2010
    Link to this post
    Hi!

    Thank you for your fast answer.

    I've done everything that you said.
    I created news item with Title "Празници". After that I created the English version with Title "Holidays". As a result when I try to access the item in Bulgarian version, I have the following:
    The resource cannot be found. 
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 
      
    Requested URL: /MySite/Home/News/10-06-30/Празници.aspx

    The url in the browser is http://localhost/MySite/bg-BG/Home/News/10-06-30/%d0%9f%d1%80%d0%b0%d0%b7%d0%bd%d0%b8%d1%86%d0%b8.aspx

    I can access the English version on address http://localhost/MySite/en-US/Home/News/10-06-30/Holidays.aspx

    I realized that the latest saved Title generates the url of the news that can be accessed.

    I'm using version 3.7

    Any ideas?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    27 Jul 2010
    Link to this post
    Hello Kostadinka,

    Create a new metakey ( UserManual page 219) of type LongTex/ShortTextt that will be used to for the title in your news items. The problem is in the way that the title is interpreted and encoded by the browser. You need to use this newly created metakey to enter the title in Bulgarian, since the default title should be in English, so that the link will not be broken. You have to override NewsView control and its SetItemMetadata method where depending on the CurrentUICulture you have to replace the Text property of the default Hyperlink control that is used for news title with the value of your custom metakey.

    below is a sample implementation

    public class NewsViewCustomControl : NewsView
    {
      
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx";
            }
      
        }
      
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx";
            }
      
        }
      
      
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
      
        public override Type AssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
      
        protected override void SetItemMetadata(Control itemContainer, IContent contentItem)
        {
            base.SetItemMetadata(itemContainer, contentItem);
            // get CurrentUICulture here and if it is "bg" do the logic below
            for (int i = 1; i < 6; i++)
            {
                var cntr = itemContainer.FindControl("fullContent" + i) as HyperLink;
                if (cntr != null)
                {
                    var lit = cntr.FindControl("Title") as Literal;
                    lit.Text =contentItem.GetMetaData("BgTitle").ToString();
                }
            }
              
              
        }
    }


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Kostadinka
    Kostadinka avatar
    16 posts
    Registered:
    27 Jul 2010
    28 Jul 2010
    Link to this post
    Hi,

    That's not a good solution. What happens if I have 5 more languages?

    Is it possible to add a matakey for URL of the news which is not localizable? But in this case I have to ensure unique values of this metakey, may be I have to set it on New and I don't have to allow editing of this key. I was thinking of using the ID of the news but it is not a meta key. Is it possible at all?

    Regards,
    K. Toteva
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Jul 2010
    Link to this post
    Hi Kostadinka,

    3.x edition does not provide localizable urls - you cannot use any special chars or Cyrillic in the url. This feature will be available in 4.0 edition which CTP is available.

    You can get the content item ID in the same method as described in the previous post.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
Register for webinar
6 posts, 1 answered