How to Set a Default LanguageId for PowerPoint Documents in C#?

I understand that each Portion can be set to a different LanguageId (e.g., "en-US", "ja-JP") via PortionFormat. However, is there a way to specify a default LanguageId for the entire document?

Also, what’s the purpose of AlternativeLanguageId? In the PowerPoint VBA object model, I can see the LangaugeID property under TextRange, but there is no AlternativeLanguageId. How is this property used?

Thanks!

@bingxie,
Thank you for contacting support. I am working on the question you posted and will get back to you soon.

@bingxie,
Unfortunately, I have not found a way to set a default language for an entire PowerPoint document. I’ve added a ticket with ID SLIDESNET-43700 to our issue-tracking system. Our development team will consider implementing such a feature. You will be notified when a new release of Aspose.Slides with the update is published.

I have also not found detailed information about that property. I’ve added a ticket with ID SLIDESNET-43701 to our issue-tracking system. We will provide the information ASAP.

@bingxie,
Our developers have investigated your requirements to set the default language for PowerPoint presentations. Please try using the ForEach.Portion method like this:

using (Presentation pres = new Presentation("pres.pptx"))
{
    Aspose.Slides.LowCode.ForEach.Portion(pres, (portion, para, slide, index) =>
    {
        portion.PortionFormat.LanguageId = "ja-JP";
    });

    pres.Save("pres-out.pptx", SaveFormat.Pptx);
}

Thank you @andrey.potapov.

While the code snippet updates the LanguageId of all existing portions in the presentation, will new portions inherit this setting? Or do I have to always perform this step before saving any presentation in Aspose.Slides?

P.S. Do you have an update about AlternativeLanguageId in the original post?

Thanks!

@bingxie,

I’ve forwarded your questions to our developers. We will let you know soon.

I’ve requested information from our development team.

@bingxie,
The SLIDESNET-43701 issue has been scheduled for investigation this week.

@andrey.potapov Thank you very much for the update!

@bingxie,
Thank you for using Aspose.Slides.

@andrey.potapov Do you have any update on this issue?

I would also like to report that the sample code provided does not update the language for slide notes. They still appear to be incorrectly set as “English (US)”, even on an installation with non-English Windows and non-English Office.

@bingxie,

Our developers are still working on the issue. Unfortunately, I don’t have additional information yet.

Please share the following:

  • input sample presentation file
  • output presentation file
  • screenshot with the problem you found

@andrey.potapov I can create some sample files if needed. However, they are very simple to create. Just run the code you previously provided (copied below) on any PowerPoint presentation with notes:

using (Presentation pres = new Presentation("pres.pptx"))
{
    Aspose.Slides.LowCode.ForEach.Portion(pres, (portion, para, slide, index) =>
    {
        portion.PortionFormat.LanguageId = "ja-JP";
    });

    pres.Save("pres-out.pptx", SaveFormat.Pptx);
}

When you open the pres-out.pptx file in PowerPoint, if you select any text on the slide, you will see the proofing language has been updated to Japanese as expected. However, if you select any text in the notes area, you will see the proofing language in the PowerPoint status bar is still the original language in the ‘pres.pptx’ file.

@bingxie,
Thank you for the additional information. I reproduced the problem with setting the default language for slide notes.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-43940

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you found earlier (filed as SLIDESNET-43940) have been fixed in Aspose.Slides for .NET 23.5 (ZIP, MSI).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.

The issues you found earlier (filed as SLIDESNET-43700) have been fixed in Aspose.Slides for .NET 23.6 (ZIP, MSI).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.

@bingxie,
With Aspose.Slides for .NET 23.6, you can solve the issue with a default language for an entire PowerPoint document like this:

LoadOptions loadOptions = new LoadOptions();
loadOptions.DefaultTextLanguage = "en-US";
using (Presentation pres = new Presentation(loadOptions))
{
    // Add a new rectangle shape with text
    IAutoShape shp = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 150, 50);
    shp.TextFrame.Text = "New Text";
    
    // Check the first portion language
    Console.WriteLine(shp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.LanguageId);
}

Thank you @andrey.potapov !

@bingxie,
Thank you for using Aspose.Slides.

@bingxie,
It seems that the AlternativeLanguageId property is obsolete and possibly was related to the language packs. Its presence or absence does not affect anything in the PPTX structure. In PPT, it may affect the order of RTL text portions only when it’s in the default properties of the entire presentation.

@andrey.potapov Thanks for the clarification. This is very useful.