-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,4 +16,8 @@ class User < ApplicationRecord | |
| def foo | ||
| puts "test" | ||
| end | ||
|
|
||
| def hello | ||
| I18n.t("hello") | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --- | ||
| es: | ||
| hello: "Hola mundo" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --- | ||
| fr: | ||
| hello: "Bonjour le monde" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -321,6 +321,28 @@ class Bar < ApplicationRecord | |
| CONTENT | ||
| end | ||
|
|
||
| test "returns I18n translation information" do | ||
| expected_response = { | ||
| en: "hello", | ||
| es: "hola", | ||
| fr: "bonjour", | ||
| } | ||
|
|
||
| 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 commentThe reason will be displayed to describe this comment to others. Learn more. This could also be just There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| RUBY | ||
|
|
||
| assert_equal(<<~CONTENT.chomp, response.contents.value) | ||
| ```yaml | ||
| en: hello | ||
| es: hola | ||
| fr: bonjour | ||
| ``` | ||
| CONTENT | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def hover_on_source(source, position) | ||
|
|
||
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.