-
Notifications
You must be signed in to change notification settings - Fork 37
Add hover on i18n translations #640
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
base: main
Are you sure you want to change the base?
Add hover on i18n translations #640
Conversation
| when "reload_i18n" | ||
| with_progress("rails-reload-i18n", "Reloading Ruby LSP Rails I18n") do | ||
| with_notification_error_handling(request) do | ||
| I18n.reload! if defined?(I18n) && I18n.respond_to?(:reload!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is provided because other I18n backend maybe does not implement the reloading feature.
| RunnerClient.any_instance.stubs(i18n: expected_response) | ||
|
|
||
| response = hover_on_source(<<~RUBY, { line: 0, character: 9 }) | ||
| I18n.t("foo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be just t if we consider that you could be inside Action View, but perhaps that is beyond the scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, its out of scope. This changes only support I18n.t("some-key") calls. With absolute key and string literal as argument.
To support t notation for ActionView, we need the context of which file is beign parsed and be able to complete the call of I18n in an ActionView context, or with the scope of that specific file. It could be a nice follow up if you want to help 👍🏻 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we need anything else other than the template filename to resolve a relative translation? I understand that you want to start with the simplest use case, I was just curious if we'd actually need the Action View context.
First implementation for I18n support (#639)
How it works
I18n.t("hello")key string argument, request the server all the translations available and provide hover info for that.It address points 1 and 2 of the issue list:
And is usefull for updating and creating translations because it gives feedback that the used translations "is correct" because makes direct calls to the I18n backend while typing and hovering it. Warning if the translation is missing.
This gives the following experience:
Screencast from 2025-07-27 00-40-33.webm