Shopify / Shopify/ruby-lsp-rails
Add go to definition to I18n translations
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 688
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
When using I18n, it will be useful to have GoToDefinition support. Improving the developer experience when working with translations.
Examples:
I18n.t("some-key")in.erband.rbfile.I18n.translate("some-key")in.erband.rbfile.
Both should go to the definition(s) of that translation(s)
Some considerations:
- Changes in the yaml files that have the translations should be considered, the definition must be synced between the I18n backend when their sources changes (exampel: if I change a yaml file es.yml, the go to definition should change too).
- I18n could have different/custom translation backends.
My take on this is that this could be implemented in the following way:
- Make I18n have the metadata of where is each translation located. This should be opt-in so we only turn it on in development mode, so now the translation
I18n.t("key")gives the pair(value, source_location)instead of just the value. This could be done via contribution toI18nor monkey patching in this addon, i prefer the first aproach. - Use the same strategy as #640 but use a new request that use this new metadata from the I18n running in the rails background process to get the source_location of the translation in the go_to_definition_request.
The key is easily accessible by the AST tree in the I18n.t("string") call.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the strategy from #640 and the AST handling for I18n.t and I18n.translate calls. Trace how go_to_definition_request communicates with the Rails background process and how translation locations could stay synced when YAML sources change. Done means supported calls can navigate to their translation definitions, including updated locations after source changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby, yaml
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100