Sign in Join
Wiki copytemporary

IDE Window: Make ResourceString: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-This wizard helps to convert a string constant into a resourcestring.
2-
3-Place the cursor on a string constant or select the part of the constant that should be converted. Then do <Right click> Refactoring | Make Resource String.
4-
5-A string constant is for example 'Some text'.
1+This wizard helps to convert a string constant into a resourcestring.
62
7-## Contents
3+Place the cursor on a string constant or select the part of the constant that should be converted. Then do \<Right click\> Refactoring \| Make Resource String.
84
9- * 1 Conversion Options
10- * 1.1 Identifier prefix
11- * 1.2 Identifier length
12- * 1.3 Custom identifier
13- * 1.4 Resourcestring section
14- * 1.5 String with same value
15- * 1.6 Where to put the new identifier in the resourcestring section
16- * 2 String constant in source
17- * 3 Source preview
18- * 4 Examples
19- * 4.1 Example 1: Setting the caption of a form
20- * 4.2 Example 2 : Complex string constants
21- * 5 See also
5+A string constant is for example 'Some text'.
226
237## Conversion Options
248
259### Identifier prefix
2610
27-You can create automatically a new identifier. The new identifier will start with the prefix, followed by the words of the string constant. If there is already a resourcestring with this value, the old identifier will be suggested. The IDE remembers the prefixes for each unit, so the last used prefix for the current unit is preselected first.
11+You can create automatically a new identifier. The new identifier will start with the prefix, followed by the words of the string constant. If there is already a resourcestring with this value, the old identifier will be suggested. The IDE remembers the prefixes for each unit, so the last used prefix for the current unit is preselected first.
2812
2913### Identifier length
3014
31-This is the maximum length of the automatically created identifier.
15+This is the maximum length of the automatically created identifier.
3216
3317### Custom identifier
3418
35-Instead of using an automatically created identifier, you can specify the identifier on your own here.
19+Instead of using an automatically created identifier, you can specify the identifier on your own here.
3620
3721### Resourcestring section
3822
39-This combobox contains all available resourcestring sections of all units in scope. That means all sections of the current unit plus all sections in the interface parts of all used units.
23+This combobox contains all available resourcestring sections of all units in scope. That means all sections of the current unit plus all sections in the interface parts of all used units.
4024
4125### String with same value
4226
43-This combobox contains all resourcestring identifiers with the same value as the new resourcestring. You can choose here, if you want to take one of them.
27+This combobox contains all resourcestring identifiers with the same value as the new resourcestring. You can choose here, if you want to take one of them.
4428
4529### Where to put the new identifier in the resourcestring section
4630
47-If a new identifier is created, this defines where it will be added in the resourcestring section.
31+If a new identifier is created, this defines where it will be added in the resourcestring section.
4832
49- * Append to section - add the new identifier at the end of the section.
50- * Insert alphabetically - insert the identifier alphabetically.
51- * Insert context sensitive - search the code above and below the current code position and search for resourcestring identifiers. If it finds one, then the new identifier is added there, otherwise it is appended at the end of the section.
33+- Append to section - add the new identifier at the end of the section.
34+- Insert alphabetically - insert the identifier alphabetically.
35+- Insert context sensitive - search the code above and below the current code position and search for resourcestring identifiers. If it finds one, then the new identifier is added there, otherwise it is appended at the end of the section.
5236
5337## String constant in source
5438
55-This shows the old or current source code.
39+This shows the old or current source code.
5640
5741## Source preview
5842
59-This is a preview, how the string constant is replaced, followed by a line of dashes and then a preview of how the resourcestring will look like.
43+This is a preview, how the string constant is replaced, followed by a line of dashes and then a preview of how the resourcestring will look like.
6044
6145## Examples
6246
6347### Example 1: Setting the caption of a form
6448
65-If you do not have already a resource string section, start one in the interface part of the unit. For example right above the 'implementation' keyword:
66-```
67-resourcestring
68- rsSomeText = 'Some text';
69-```
49+If you do not have already a resource string section, start one in the interface part of the unit. For example right above the 'implementation' keyword:
7050
71-Add in the FormCreate event the following line:
72-```
73-Caption:='An example caption';
51+``` pascal
52+
53+ resourcestring
54+ rsSomeText = 'Some text';
7455```
7556
76-Place the cursor on the string constant, i.e. somewhere between the two '. Then do -> <Right click> Refactoring | Make Resource String
57+Add in the FormCreate event the following line:
7758
78-Set in the identifier prefix 'rs' without the '. The new automatically suggested identifier will be 'rsAnExampleCaption'. The preview shows
79-```
80-Caption:=rsAnExampleCaption;
81- --------------------------------------------------------------------------------
82- rsAnExampleCaption = 'An example caption'
59+``` pascal
60+
61+ Caption:='An example caption';
8362```
8463
85-Click ok.
64+Place the cursor on the string constant, i.e. somewhere between the two '. Then do -\> \<Right click\> Refactoring \| Make Resource String
8665
66+Set in the identifier prefix 'rs' without the '. The new automatically suggested identifier will be 'rsAnExampleCaption'. The preview shows
67+
68+`   Caption:=rsAnExampleCaption;`\
69+` --------------------------------------------------------------------------------`\
70+` rsAnExampleCaption = 'An example caption'   `
71+
72+Click ok.
73+
8774### Example 2 : Complex string constants
8875
89-When converting a complex string expression with variables and functions, the tool will use the **Format** function. For instance the statement:
90-```
91-Caption:='Left='+IntToStr(Left)+' Top='+IntToStr(Top);
92-```
76+When converting a complex string expression with variables and functions, the tool will use the **Format** function. For instance the statement:
9377
94-will be replaced with
95-```
96-Caption:=Format(rsLeftTop, [IntToStr(Left), IntToStr(Top)]);
78+``` pascal
79+
80+ Caption:='Left='+IntToStr(Left)+' Top='+IntToStr(Top);
9781```
9882
99-and the new resourcestring will be
100-```
101-rsLeftTop = 'Left=%s Top=%s'
83+will be replaced with
84+
85+``` pascal
86+
87+ Caption:=Format(rsLeftTop, [IntToStr(Left), IntToStr(Top)]);
10288```
10389
104-The Format function is defined in the SysUtils unit. If your unit uses section does not already contain it, you must add it yourself.
90+and the new resourcestring will be
10591
106-
92+``` pascal
93+
94+ rsLeftTop = 'Left=%s Top=%s'
95+```
10796
97+The Format function is defined in the SysUtils unit. If your unit uses section does not already contain it, you must add it yourself.
98+
10899## See also
109100
110- * [[Getting translation strings right]]
101+- [[Getting translation strings right]]
111102
112103---
113-*From the Free Pascal wiki, page "IDE Window: Make ResourceString", as the Internet Archive kept it on 2025-03-16. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
104+*From the Free Pascal wiki, page "IDE Window: Make ResourceString", as it stood on 2021-10-11 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history