- edited description
Extract custom label refactoring for string literals
I think this will be huge help for developers, whose deal with old, bad-written code.
Example scenario:
-
User selects hard-coded string.
-
User opens 'Refactor this' option.
-
User selects 'Export to Custom Labels'
-
IC opens PopUp where user can enter: * ApiName *Description
-
IC creating new CustomLabel and swap hard-coded string.
Comments (7)
-
reporter -
reporter - edited description
-
repo owner That's a great idea. Would be a perfect extension to the Extract Constant refactoring that I'll be working on pretty soon. If the underlying expression is a string provide an option to extract as a custom label. Thanks for the suggestion!
-
I'm not sure if it's implicit in the request but this would be useful in apex, visualforce and lightning component markup / javascript.
-
Apex / Visualforce / Aura markup and JS can all directly replace strings with the appropriate expression to include the created label.
In LWCs it’d be useful to be able to take the following paths:
String value in html tag attribute → JS Property
<img alt="Logo" >
→<img alt={logo} >
String value in html → JS Property<div>hello</div>
→<div>{hello}</div>
String value in html tag attribute → JS Method returning the string
String value in html → JS MethodString value in html tag attribute → CustomLabel + JS import + JS Property
String value in html → CustomLabel + JS import + JS PropertyString property in JS → CustomLabel + JS import
Default value for the custom label API name should be the string in PascalCase.
Default value for the JS property (or method?) and JS import should be the string in camelCase
-
repo owner - changed title to Refactore hard-coded string to CustomLabel
- removed version
-
repo owner - changed title to Extract custom label refactoring for string literals
- Log in to comment