theme-tools icon indicating copy to clipboard operation
theme-tools copied to clipboard

Feature Request: Tab stops for translations

Open david-w-shopify opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. After adding a translation, going backwards to add my variables is slow. It could be faster with built in tabstops.

Describe the solution you'd like On injecting a translation, add a tabstop for each variable that's already injected.

For example, given this in locales/en.default.json

{
  "product": {
    "add_count_product_to_cart": "Add {{ count }} {{ product }} to cart"
  }
}

The following completion would be used

{{ 'product.add_count_product_to_cart' | t: count: ${1:count}, product: ${2:product} }}

This would mean I can immediately replace the "count" and "product" variables if I need to.


As more powerful alternative, the completion could look like this

{{ 'product.add_count_product_to_cart' | t: ${1:count: ${2:count}, }${3:product: ${4:product}} }}

This would mean I can remove a variable entirely if I desire. This is useful for scenarios where a translation will be rendered in JS, rather than rendered entirely via Liquid.

I am assuming that extensions use the same snippet syntax as user configured snippets here. If they don't and it's not clear, hopefully this video will help get the idea across

https://github.com/user-attachments/assets/6ed8ced9-ef5e-4c79-b188-89b4c32a50dc

david-w-shopify avatar Oct 22 '24 10:10 david-w-shopify

Hello, @david-w-shopify. I tried a potential implementation of tab stops for translations by modifying the translation server :)

https://github.com/user-attachments/assets/e83dfc03-88a3-4472-9e24-67658ee7f934

Smintfy avatar Nov 16 '24 18:11 Smintfy