Skip to content
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

WIP 1844 Part 1: auto-generated human-IDs and aliases #2108

Merged
merged 168 commits into from
Mar 12, 2024

Conversation

martin-lysk
Copy link
Collaborator

@martin-lysk martin-lysk commented Jan 24, 2024

This PR introduces auto-generated human-IDs and aliases behind the experimental: aliases flag.

For background, please see #1892 and #1844 (comment) and the message docs.

This PR also adds file-system-based locking to improve the behavior of concurrent message updates through the load/store plugin api. Most of these change are in loadProject.

In order to validate these changes, there is also a new sdk/load-test, and a mock machine translate api.

tasks

  • feature flag for human ids and aliases
  • enable feature flag for opral projects
  • add message.alias (non-optional) property
  • autogenerate human ids and set alias = plugin id on load
  • message file locking on load/save, read/write
  • validate file locking (should fix [bug] Can't machine-translate multiple new keys #1968)
  • validate with large project
  • add mock translation to rpc
  • add test for file locking with real FS and mock translation
  • uncomment cli translate progress bar or make it optional
  • replace console logs with debug logger flag
  • fink.
    • show aliases alongside message ids
    • seach messages by alias
  • ide-extension
    • recognize message aliases returned by matchers.
    • show aliases in inlang tab (design tbd)
    • (separate PR) auto-generate human ids for new (e.g. extracted) messages
  • paraglide
    • compile aliases into message functions
    • generate deprecation comments for aliases
  • add SDK docs for aliases and human IDs
  • revisit TODOs
  • PR review
  • changeset
  • 🚢

...onward to 1844 Part 2: inlang message persistence

human ids (opral only)

Message ids from a plugin are replaced with human ids derived from the message id. The id becomes the default alias.

Existing message references in code may continue to use the plugin id, now stored in the default alias. A new api messages.getByDefaultAlias() resolves aliases e.g. when matched by the ide-extension:

const highlightedMessages = matchedMessages
  // resolve messages from id or alias
  .map((message) => {
    return (
      state().project.query.messages.get({ where: { id: message.messageId } }) ??
      state().project.query.messages.getByDefaultAlias(message.messageId)
    )
  })

In fink, the alias is shown alongside the human id

Screenshot 2024-02-05 at 11 37 40

the ide-extension checks for aliases as well as ids when it matches references to messages

Screenshot 2024-02-11 at 23 48 16

The message.alias is a non-optional property of the message api. NOTE: This change to the TypeScript Message interface impacts a large number of tests. Additional modification was required in those tests which expect to be able to get() messages using the original message key.

…es to be stored in separate folders (like packages or git like hashbased distribution), fixes reactivitiy for message crud actions
…direcory

# Conflicts:
#	inlang/source-code/sdk/src/loadProject.ts
#	inlang/source-code/website/messages.json
…direcory

# Conflicts:
#	inlang/source-code/paraglide/paraglide-js/src/compiler/compile.test.ts
#	inlang/source-code/paraglide/paraglide-js/src/compiler/compileMessage.test.ts
#	inlang/source-code/paraglide/paraglide-js/src/compiler/compileMessage.ts
#	inlang/source-code/sdk/src/loadProject.ts
#	lix/source-code/client/package.json
Copy link
Collaborator Author

@martin-lysk martin-lysk left a comment

Choose a reason for hiding this comment

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

Some followup comments - but we are getting there

@samuelstroschein samuelstroschein temporarily deployed to 1844-sdk-persistence-of-messages-in-project-direcory - git-proxy PR #2108 March 12, 2024 10:16 — with Render Destroyed
@samuelstroschein samuelstroschein temporarily deployed to 1844-sdk-persistence-of-messages-in-project-direcory - badge-service PR #2108 March 12, 2024 10:16 — with Render Destroyed
@samuelstroschein samuelstroschein temporarily deployed to 1844-sdk-persistence-of-messages-in-project-direcory - fink-editor PR #2108 March 12, 2024 10:33 — with Render Destroyed
@samuelstroschein samuelstroschein temporarily deployed to 1844-sdk-persistence-of-messages-in-project-direcory - inlang-website PR #2108 March 12, 2024 10:33 — with Render Destroyed
@jldec jldec merged commit be81a4e into main Mar 12, 2024
5 of 6 checks passed
@jldec jldec deleted the 1844-sdk-persistence-of-messages-in-project-direcory branch March 12, 2024 13:09
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] Can't machine-translate multiple new keys SDK persistence of messages in project directory
6 participants