Difference between revisions of "IDE Window: Make ResourceString"

From Lazarus wiki
Jump to navigationJump to search
(リソース文字列no作成)
Line 1: Line 1:
このウィザードはある文字列定数をリソース文字列に変換するのを手助けします。
+
This wizard helps to convert a string constant into a resourcestring.
  
カーソルを変換したい文字列定数もしくは選択されたその一部の上に置いてください。その上で、ツール → リソース文字列作成 を呼び出して下さい。
+
Place the cursor on a string constant or select the part of the constant that should be converted. Then invoke Tools -> Make Resource String.
  
例として、文字列定数を 'Some text'とします。
+
A string constant is for example 'Some text'.
  
== 変換オプション ==
+
== Conversion Options ==
  
=== 識別子の接頭辞 ===
+
=== Identifier prefix ===
  
新しい識別子が自動的に作成されます。その新しい識別子は接頭辞(prefix)から始まり、文字列定数の単語が続きます。もし同じ値のリソース文字列が既にある場合、その古い識別子が提案されます。
+
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.
IDEはユニット毎の接頭辞を記憶するため、現在のユニットで最後に用いられた接頭辞が始めに選択されます。
+
The IDE remembers the prefixes for each unit, so the last used prefix for the current unit is preselected first.
  
=== 識別子の長さ ===
+
=== Identifier length ===
  
これは自動的に作成された識別子の最大長です。
+
This is the maximum length of the automatically created identifier.
  
=== カスタム識別子 ===
+
=== Custom identifier ===
  
自動的に作成された 識別子を用いる代わりに、ここにあなた自身が識別子を設定することができます。
+
Instead of using an automatically created identifier, you can specify the identifier on your own here.
  
=== リソース文字列セクション ===
+
=== Resourcestring section ===
  
このコンボボックスはスコープ内の全てのユニットで使用できる全てのリソース文字列セクションを含んでいます。これは現在のユニットの全てのセクションに加え、用いられているユニットの宣言部にある全てのセクションを加えたものです。
+
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.
  
=== 同じ値の文字列 ===
+
=== String with same value ===
  
このコンボボックスは新しいリソース文字列と同じ値を持つ全てのリソース文字列識別子を並べています。それらの一つを用いたい場合にここで選択できます。
+
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.
  
=== リソース文字列セクションのどこに新しい識別子を置けばよいか ===
+
=== Where to put the new identifier in the resourcestring section ===
  
新しい識別子が作成された場合に、 リソース文字列セクションのどこにそれを置けばよいかを設定します。
+
If a new identifier is created, this defines where it will be added in the resourcestring section.
  
* セクションに追加 - 新しい識別子はセクションの末尾に置かれます。
+
* Append to section - add the new identifier at the end of the section.
* アルファベット順に挿入 - 識別子をアルファベット順に挿入します。
+
* Insert alphabetically - insert the identifier alphabetically.
* 状況感知的に挿入 - 現在のコードの前後でリソース文字列識別子を探索します。もし見つけたら新しい識別子はそこに追加されます。なければセクションの末尾に置かれます。
+
* 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.
  
== ソース内の文字列定数 ==
+
== String constant in source ==
  
これは古いソースコードもしくは現在のソースコードを示しています。
+
This shows the old or current source code.
  
== ソースのプレビュー ==
+
== Source preview ==
  
これは文字列定数がどのように再配置されるかのプレビューで、破線がその下に引かれ、そのリソース文字列がどのように見えるかを示します。
+
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.
  
== ==
+
== Examples ==
  
=== 1: フォームのcaptionの設定 ===
+
=== Example 1: Setting the caption of a form ===
  
resourcestringセクションがまだなければ宣言部に追加して下さい。例えば'implementation'キーワードのすぐ上のあたりに:
+
If you do not have already a resource strin section, start one in the interface part of the unit. For example right above the 'implementation' keyword:
  
 
   resourcestring
 
   resourcestring
 
     rsSomeText = 'Some text';
 
     rsSomeText = 'Some text';
  
FormCreateイベントに次の行を追加して下さい:
+
Add in the FormCreate event the following line:
 
    
 
    
 
   Caption:='An example caption';
 
   Caption:='An example caption';
  
カーソルをその文字列定数の上、つまり2つの 'の間のどこかに置き、ツール → リソース文字列作成
+
Place the cursor on the string constant, i.e. somewhere between the two '.
 +
Then do Tools -> Make Resource String
  
その識別子の接頭辞に'rs'を('なしで)置きます。
+
Set in the identifier prefix 'rs' without the '.
新しく自動的に提案される識別子は'rsAnExampleCaption'になります。
+
The new automatically suggested identifier will be 'rsAnExampleCaption'.
プレビューでは次のように表示されます。
+
The preview shows
 
     Caption:=rsAnExampleCaption;
 
     Caption:=rsAnExampleCaption;
 
   --------------------------------------------------------------------------------
 
   --------------------------------------------------------------------------------
 
   rsAnExampleCaption = 'An example caption'   
 
   rsAnExampleCaption = 'An example caption'   
  
OKをクリックしてください。
+
Click ok.
  
=== 2 : 複雑な文字列定数 ===
+
=== Example 2 : Complex string constants ===
  
変数や関数をもつ複雑な文字列式を変換する場合、このツールは'''Format'''関数を用います。例えば次の文:
+
When converting a complex string expression with variables and functions, the tool will use the '''Format''' function. For instance the statement:
 
   Caption:='Left='+IntToStr(Left)+' Top='+IntToStr(Top);
 
   Caption:='Left='+IntToStr(Left)+' Top='+IntToStr(Top);
は次の文に置き換わります。
+
will be replaced with
 
   Caption:=Format(rsLeftTop, [IntToStr(Left), IntToStr(Top)]);
 
   Caption:=Format(rsLeftTop, [IntToStr(Left), IntToStr(Top)]);
そして新しいリソース文字列は
+
and the new resourcestring will be
 
   rsLeftTop = 'Left=%s Top=%s'       
 
   rsLeftTop = 'Left=%s Top=%s'       
となります。
+
 
このFormat関数はSysUtilsユニットで定義されています。ユニットのuses節にまだSysUtilsが含まれていない場合は追加して下さい。
+
The Format function is defined in the SysUtils unit. If your unit uses section does not already contain it, you must add it yourself.

Revision as of 04:55, 23 November 2006

This wizard helps to convert a string constant into a resourcestring.

Place the cursor on a string constant or select the part of the constant that should be converted. Then invoke Tools -> Make Resource String.

A string constant is for example 'Some text'.

Conversion Options

Identifier prefix

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.

Identifier length

This is the maximum length of the automatically created identifier.

Custom identifier

Instead of using an automatically created identifier, you can specify the identifier on your own here.

Resourcestring section

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.

String with same value

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.

Where to put the new identifier in the resourcestring section

If a new identifier is created, this defines where it will be added in the resourcestring section.

  • Append to section - add the new identifier at the end of the section.
  • Insert alphabetically - insert the identifier alphabetically.
  • 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.

String constant in source

This shows the old or current source code.

Source preview

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.

Examples

Example 1: Setting the caption of a form

If you do not have already a resource strin section, start one in the interface part of the unit. For example right above the 'implementation' keyword:

 resourcestring
   rsSomeText = 'Some text';

Add in the FormCreate event the following line:

 Caption:='An example caption';

Place the cursor on the string constant, i.e. somewhere between the two '. Then do Tools -> Make Resource String

Set in the identifier prefix 'rs' without the '. The new automatically suggested identifier will be 'rsAnExampleCaption'. The preview shows

   Caption:=rsAnExampleCaption;
 --------------------------------------------------------------------------------
 rsAnExampleCaption = 'An example caption'   

Click ok.

Example 2 : Complex string constants

When converting a complex string expression with variables and functions, the tool will use the Format function. For instance the statement:

 Caption:='Left='+IntToStr(Left)+' Top='+IntToStr(Top);

will be replaced with

 Caption:=Format(rsLeftTop, [IntToStr(Left), IntToStr(Top)]);

and the new resourcestring will be

 rsLeftTop = 'Left=%s Top=%s'      

The Format function is defined in the SysUtils unit. If your unit uses section does not already contain it, you must add it yourself.