Skip to content

DYN-9801: Add Locale property to ExtensionStartupParams to pass locale info from Dynamo to apps like LibG#17060

Merged
aparajit-pratap merged 6 commits intomasterfrom
dyn-9801
Apr 20, 2026
Merged

DYN-9801: Add Locale property to ExtensionStartupParams to pass locale info from Dynamo to apps like LibG#17060
aparajit-pratap merged 6 commits intomasterfrom
dyn-9801

Conversation

@aparajit-pratap
Copy link
Copy Markdown
Contributor

@aparajit-pratap aparajit-pratap commented Apr 16, 2026

Purpose

Part of DYN-9801. Companion Dynamo change for the LibG localization modernization in LibG PR #1648. This PR needs to be merged before LibG PR 1948.

Root cause of the old approach being broken

Dynamo previously set the LibG/gettext locale by calling _putenv("LANGUAGE=xx_XX") via a P/Invoke to msvcrt.dll. This was unreliable: msvcrt.dll's _environ block and libintl.dll's own CRT _environ block are separate memory regions in the same process, so the write was never visible to gettext. In practice, geometry error strings were never reliably localized — gettext fell back to the Windows registry (Control Panel → Region), not to Dynamo's selected language.

What LibG PR #1648 does

Replaces the env-var approach with a programmatic Localization::set_language() C++ API (exposed to managed code via SWIG) that calls libintl_setlocale() directly into libintl.dll's address space, bypassing the CRT boundary entirely. LibG's IExtensionApplication.StartUp() now calls Localization.initialize() and Localization.set_language() using the locale passed in via ExtensionStartupParams.

What this PR does

  • Adds Locale property to ExtensionStartupParams (NodeServices/Interfaces.cs) so Dynamo can pass the resolved UI locale to IExtensionApplication implementors like LibG.
  • Declares the new property in PublicAPI.Unshipped.txt for the NodeServices assembly.
  • Populates Locale in ExtensionAppLoader.InitializeExtensionApp() from Thread.CurrentThread.CurrentUICulture.Name (set earlier by DynamoModel.SetUICulture()).
  • Removes the dead _putenv("LANGUAGE=...") call and the msvcrt.dll P/Invoke from DynamoCoreSetup — this never worked correctly (see root cause above).
  • Deprecates StartupUtils.SetLocale() and removed calls to it.

Declarations

Check these if you believe they are true

Release Notes

N/A — internal localization plumbing change; no user-visible behavior changes in this PR alone. Geometry error string localization will work correctly once the companion LibG PR #1648 ships.

Reviewers

(FILL ME IN) Reviewer 1

This PR must be reviewed alongside LibG PR #1648 — both sides need to ship together. The key change reviewers should focus on is ExtensionAppLoader.cs: Locale is read from Thread.CurrentThread.CurrentUICulture.Name at the time StartUp() is called, which is after DynamoModel.SetUICulture() has run (locale is set during model construction; FFI assembly loading happens later on first graph execution).

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

Copilot AI review requested due to automatic review settings April 16, 2026 17:16
@github-actions github-actions Bot changed the title Add Locale property to ExtensionStartupParams to pass locale info from Dynamo to apps like LibG DYN-9801: Add Locale property to ExtensionStartupParams to pass locale info from Dynamo to apps like LibG Apr 16, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-9801

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the ExtensionStartupParams public API to carry locale information from Dynamo into FFI extension applications, and updates startup code paths to set UI culture earlier while removing the previous env-var–based locale plumbing.

Changes:

  • Add a new Locale property to Autodesk.DesignScript.Interfaces.ExtensionStartupParams (public API) and record it in PublicAPI.Unshipped.txt.
  • Pass the current UI culture name into extension apps via ExtensionAppLoader during StartUp(...).
  • Simplify CLI/Sandbox/WPFCLI startup locale handling to only call StartupUtils.SetLocale(...) (no longer capturing/using its return value).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/NodeServices/PublicAPI.Unshipped.txt Adds the new public API entries for ExtensionStartupParams.Locale get/set.
src/NodeServices/Interfaces.cs Introduces ExtensionStartupParams.Locale on the public struct.
src/Engine/ProtoCore/FFI/ExtensionAppLoader.cs Populates Locale when calling extensionApp.StartUp(...).
src/DynamoWPFCLI/Program.cs Stops storing the SetLocale return value (now just calls it).
src/DynamoSandbox/DynamoCoreSetup.cs Removes _putenv usage and only calls SetLocale.
src/DynamoCLI/Program.cs Stops storing the SetLocale return value (now just calls it).
src/DynamoApplications/StartupUtils.cs Changes SetLocale to only set UI culture (when provided) and return an empty string.

Comment thread src/NodeServices/Interfaces.cs
Comment thread src/DynamoApplications/StartupUtils.cs
Comment thread src/NodeServices/PublicAPI.Unshipped.txt Outdated
Comment thread src/DynamoCLI/Program.cs Fixed
Comment thread src/DynamoSandbox/DynamoCoreSetup.cs Fixed
Comment thread src/DynamoWPFCLI/Program.cs Fixed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread src/Engine/ProtoCore/FFI/ExtensionAppLoader.cs
Comment thread src/DynamoApplications/StartupUtils.cs Outdated
Comment thread src/DynamoCLI/Program.cs Outdated
Comment thread src/DynamoWPFCLI/Program.cs Outdated
Copy link
Copy Markdown
Contributor

@zeusongit zeusongit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread src/DynamoApplications/StartupUtils.cs
Comment thread src/DynamoApplications/StartupUtils.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@aparajit-pratap aparajit-pratap merged commit 795ddd9 into master Apr 20, 2026
27 checks passed
@aparajit-pratap aparajit-pratap deleted the dyn-9801 branch April 20, 2026 19:30
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants