Skip to content

Hard coded Strings Extraction

Alex Terehov edited this page Jul 14, 2021 · 12 revisions

Supported

  • Vue templates,
  • JSX templates,
  • HTML files.

File types supported: vue, js, ts, jsx, tsx

Extraction UI (TODO Screenshots of triggers and before/after result)

i18n Ally hardcoded string extraction UI

Commands

i18n-ally.detect_hard_strings (expiremental) Detect hard-coded strings in the current file

Configuration options (document enabledFrameworks: at least general)

// Parser options for extracting HTML, see https://github.com/lokalise/i18n-ally/blob/master/src/extraction/parsers/options.ts
"i18n-ally.extract.parsers.html": {
  "attributes": ['title', 'alt', 'placeholder', 'label', 'aria-label'],
  "ignoredTags": ['script', 'style'],
  "vBind": true,
  "inlineText": true
},

// Enables hard-coded strings detection automatically whenever opening supported a file
"i18n-ally.extract.autoDetect": false,

// Make sure that particular refactoring templates would be picked up be the bulk extraction depending on the context
"i18n-ally.refactor.templates": [
   {
     // affect scope (optional)
     // see https://github.com/lokalise/i18n-ally/blob/master/src/core/types.ts#L156-L156
     "source": "html-attribute",
     "templates": [
       "i18n.t('{key}'{args})",
       "custom.t('{key}'{args})",
     ],
     // accept globs, resolved to project root (optional)
     "include": [
       "src/**/*.{vue,ts,js}",
       "index.html"
     ],
     "exclude": [
       "scr/config/**"
     ]
   },
   // ...
]