Skip to content

Allow using arrays of strings as messages in package.nls.json #251513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 15, 2025

This PR adds support for using arrays of strings in package.nls.json files, which are automatically joined with newline characters during the build process. This makes maintaining multiline strings much easier and more readable.

Problem

Currently, multiline strings in package.nls.json files must be written as single lines with explicit \n escape sequences:

{
  "configuration.markdown.editor.filePaste.videoSnippet": "Snippet used when adding videos to Markdown. This snippet can use the following variables:\n- `${src}` — The resolved path of the video file.\n- `${title}` — The title used for the video. A snippet placeholder will automatically be created for this variable."
}

This is difficult to read and maintain, especially for longer descriptions.

Solution

With this change, you can now use arrays of strings that are automatically joined with newlines:

{
  "configuration.markdown.editor.filePaste.videoSnippet": [
    "Snippet used when adding videos to Markdown. This snippet can use the following variables:",
    "- `${src}` — The resolved path of the video file.",
    "- `${title}` — The title used for the video. A snippet placeholder will automatically be created for this variable."
  ]
}

Implementation

The changes are minimal and surgical:

  1. Interface Update: Modified NLSFormat interface in build/lib/extensions.ts to accept string[] type
  2. Translation Logic: Enhanced the translatePackageJSON function to handle string arrays by joining with '\n'
  3. Backward Compatibility: All existing string and complex object formats continue to work unchanged

Key Features

  • Fully Backward Compatible: Existing extensions work without modification
  • Clean Syntax: Arrays automatically joined with newlines during build
  • Edge Case Handling: Empty arrays, single elements, and missing keys handled correctly
  • No Breaking Changes: Build pipeline and existing tooling continue to work

Testing

Added comprehensive test suite covering:

  • String array translation with multiple lines
  • Empty arrays (result in empty strings)
  • Single element arrays
  • Mixed types (strings, arrays, complex objects) in the same file
  • Backward compatibility with existing formats
  • Non-existent key handling

All tests pass and the implementation has been verified with real-world scenarios.

Fixes #203362.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • electronjs.org
    • Triggering command: node-gyp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Allow using arrays of strings as messages in package.nls.json Allow using arrays of strings as messages in package.nls.json Jun 15, 2025
@Copilot Copilot AI requested a review from TylerLeonhardt June 15, 2025 01:45
Copilot finished work on behalf of TylerLeonhardt June 15, 2025 01:45
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.

Allow using arrays of strings as messages in package.nls.json
2 participants