Difference between revisions of "IDE Window: Make ResourceString"

From Free Pascal 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.
+
カーソルを変換したい文字列定数もしくは選択されたその一部の上に置いてください。その上で、ツール → リソース文字列作成 を呼び出して下さい。
  
A string constant is for example 'Some text'.
+
例として、文字列定数を '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.
+
新しい識別子が自動的に作成されます。その新しい識別子は接頭辞(prefix)から始まり、文字列定数の単語が続きます。もし同じ値のリソース文字列が既にある場合、その古い識別子が提案されます。
The IDE remembers the prefixes for each unit, so the last used prefix for the current unit is preselected first.
+
IDEはユニット毎の接頭辞を記憶するため、現在のユニットで最後に用いられた接頭辞が始めに選択されます。
  
=== 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 ===
+
=== 1: フォームのcaptionの設定 ===
  
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セクションがまだなければ宣言部に追加して下さい。例えば'implementation'キーワードのすぐ上のあたりに:
  
 
   resourcestring
 
   resourcestring
 
     rsSomeText = 'Some text';
 
     rsSomeText = 'Some text';
  
Add in the FormCreate event the following line:
+
FormCreateイベントに次の行を追加して下さい:
 
    
 
    
 
   Caption:='An example caption';
 
   Caption:='An example caption';
  
Place the cursor on the string constant, i.e. somewhere between the two '.
+
カーソルをその文字列定数の上、つまり2つの 'の間のどこかに置き、ツール → リソース文字列作成
Then do Tools -> Make Resource String
 
  
Set in the identifier prefix 'rs' without the '.
+
その識別子の接頭辞に'rs'を('なしで)置きます。
The new automatically suggested identifier will be 'rsAnExampleCaption'.
+
新しく自動的に提案される識別子は'rsAnExampleCaption'になります。
The preview shows
+
プレビューでは次のように表示されます。
 
     Caption:=rsAnExampleCaption;
 
     Caption:=rsAnExampleCaption;
 
   --------------------------------------------------------------------------------
 
   --------------------------------------------------------------------------------
 
   rsAnExampleCaption = 'An example caption'   
 
   rsAnExampleCaption = 'An example caption'   
  
Click ok.
+
OKをクリックしてください。
  
=== Example 2 : Complex string constants ===
+
=== 2 : 複雑な文字列定数 ===
  
When converting a complex string expression with variables and functions, the tool will use the '''Format''' function. For instance the statement:
+
変数や関数をもつ複雑な文字列式を変換する場合、このツールは'''Format'''関数を用います。例えば次の文:
 
   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'       
 
+
となります。
The Format function is defined in the SysUtils unit. If your unit uses section does not already contain it, you must add it yourself.
+
このFormat関数はSysUtilsユニットで定義されています。ユニットのuses節にまだSysUtilsが含まれていない場合は追加して下さい。

Revision as of 04:51, 23 November 2006

このウィザードはある文字列定数をリソース文字列に変換するのを手助けします。

カーソルを変換したい文字列定数もしくは選択されたその一部の上に置いてください。その上で、ツール → リソース文字列作成 を呼び出して下さい。

例として、文字列定数を 'Some text'とします。

変換オプション

識別子の接頭辞

新しい識別子が自動的に作成されます。その新しい識別子は接頭辞(prefix)から始まり、文字列定数の単語が続きます。もし同じ値のリソース文字列が既にある場合、その古い識別子が提案されます。 IDEはユニット毎の接頭辞を記憶するため、現在のユニットで最後に用いられた接頭辞が始めに選択されます。

識別子の長さ

これは自動的に作成された識別子の最大長です。

カスタム識別子

自動的に作成された 識別子を用いる代わりに、ここにあなた自身が識別子を設定することができます。

リソース文字列セクション

このコンボボックスはスコープ内の全てのユニットで使用できる全てのリソース文字列セクションを含んでいます。これは現在のユニットの全てのセクションに加え、用いられているユニットの宣言部にある全てのセクションを加えたものです。

同じ値の文字列

このコンボボックスは新しいリソース文字列と同じ値を持つ全てのリソース文字列識別子を並べています。それらの一つを用いたい場合にここで選択できます。

リソース文字列セクションのどこに新しい識別子を置けばよいか

新しい識別子が作成された場合に、 リソース文字列セクションのどこにそれを置けばよいかを設定します。

  • セクションに追加 - 新しい識別子はセクションの末尾に置かれます。
  • アルファベット順に挿入 - 識別子をアルファベット順に挿入します。
  • 状況感知的に挿入 - 現在のコードの前後でリソース文字列識別子を探索します。もし見つけたら新しい識別子はそこに追加されます。なければセクションの末尾に置かれます。

ソース内の文字列定数

これは古いソースコードもしくは現在のソースコードを示しています。

ソースのプレビュー

これは文字列定数がどのように再配置されるかのプレビューで、破線がその下に引かれ、そのリソース文字列がどのように見えるかを示します。

例 1: フォームのcaptionの設定

resourcestringセクションがまだなければ宣言部に追加して下さい。例えば'implementation'キーワードのすぐ上のあたりに:

 resourcestring
   rsSomeText = 'Some text';

FormCreateイベントに次の行を追加して下さい:

 Caption:='An example caption';

カーソルをその文字列定数の上、つまり2つの 'の間のどこかに置き、ツール → リソース文字列作成

その識別子の接頭辞に'rs'を('なしで)置きます。 新しく自動的に提案される識別子は'rsAnExampleCaption'になります。 プレビューでは次のように表示されます。

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

OKをクリックしてください。

例 2 : 複雑な文字列定数

変数や関数をもつ複雑な文字列式を変換する場合、このツールはFormat関数を用います。例えば次の文:

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

は次の文に置き換わります。

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

そして新しいリソース文字列は

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

となります。 このFormat関数はSysUtilsユニットで定義されています。ユニットのuses節にまだSysUtilsが含まれていない場合は追加して下さい。