• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

FreeTrainの進化系を目指す


Commit MetaInfo

Revision23 (tree)
Time2014-07-26 22:34:26
Authorc477

Log Message

Improve text resources management to consider multi language.
Several minor modifications.

Change Summary

Incremental Difference

--- trunk/core/impl/game/GameImpl.cs (revision 22)
+++ trunk/core/impl/game/GameImpl.cs (revision 23)
@@ -3,6 +3,7 @@
33 using nft.core.game;
44 using nft.core.schedule;
55 using nft.core;
6+using nft.framework;
67
78 namespace nft.impl.game
89 {
@@ -30,7 +31,7 @@
3031 }
3132
3233 public GameImpl(ITerrainMap map, Calendar cal)
33- : this(Core.GetString("game.new_game","NewGame"), map, cal) {
34+ : this(I18n.T("GameManager","NewGame"), map, cal) {
3435 }
3536
3637 public TerrainMapImpl TerrainMap {
--- trunk/core/impl/game/TerrainPieceTemplate.cs (revision 22)
+++ trunk/core/impl/game/TerrainPieceTemplate.cs (revision 23)
@@ -82,7 +82,7 @@
8282 [Obsolete]
8383 public static ushort MakeTemplateIDX(int ne, int nw, int sw, int se){
8484 throw new NotSupportedException();
85- return GroundPolygon.MakePolygonID(sw, nw, ne, se);
85+ //return GroundPolygon.MakePolygonID(sw, nw, ne, se);
8686 }
8787
8888 public static ushort MakeTemplateID(int near, int left, int far, int right) {
--- trunk/core/impl/view/IOperationMode.cs (revision 22)
+++ trunk/core/impl/view/IOperationMode.cs (nonexistent)
@@ -1,12 +0,0 @@
1-using System;
2-using System.Collections.Generic;
3-using System.Text;
4-
5-namespace nft.impl.view
6-{
7- public interface IOperationMode
8- {
9- ITargetSelector Selector { get; set; }
10-
11- }
12-}
--- trunk/core/impl/view/ITargetSelector.cs (revision 22)
+++ trunk/core/impl/view/ITargetSelector.cs (nonexistent)
@@ -1,48 +0,0 @@
1-using System;
2-using System.Collections.Generic;
3-using System.Text;
4-
5-namespace nft.impl.view
6-{
7- //public enum SelectionState { NONE = 0, NORMAL, WARN, DANGER }
8- public delegate void TargetSelectorEvent();
9-
10- public class SelectionEventArgs
11- {
12- public enum EventTypes {SELECTION_CHANGED, PHASE_PROCEEDED, PHASE_ROLLBACKED, VIEW_CHANGED ,CANCELD }
13-
14- protected ITargetSelector selector;
15- protected EventTypes status;
16-
17- public SelectionEventArgs(ITargetSelector sel, EventTypes stat) {
18- this.selector = sel;
19- this.status = stat;
20- }
21-
22- EventTypes Status {
23- get {
24- return status;
25- }
26- set {
27- status = value;
28- }
29- }
30-
31- ITargetSelector TargetSelector {
32- get {
33- return selector;
34- }
35- }
36-
37- }
38-
39- public interface ITargetSelector
40- {
41- int MaxPhases { get; }
42- int CurrentPhase { get; }
43- object CurrentSelection { get; }
44- event TargetSelectorEvent OnSelectionChanged;
45- event TargetSelectorEvent OnPhaseChanged;
46- event TargetSelectorEvent OnViewChanged;
47- }
48-}
--- trunk/core/contributions/graphics/CtbImageResource.cs (revision 22)
+++ trunk/core/contributions/graphics/CtbImageResource.cs (revision 23)
@@ -30,6 +30,12 @@
3030 return conditionedResource;
3131 }
3232 }
33+
34+ protected override string ParseName(ParamsReader r) {
35+ ParamsReader rn = r["name"];
36+ rn = rn.IsNull? r["default|value"]["src"]:rn;
37+ return rn.InnerText;
38+ }
3339 }
3440
3541 public class ImageResource
--- trunk/core/nftcore.resource.xml (revision 22)
+++ trunk/core/nftcore.resource.xml (revision 23)
@@ -1,16 +1,22 @@
11 <?xml version="1.0" encoding="utf-8" ?>
22 <properties name="core">
3- <properties name="direction">
4- <property name="names" type="string" readonly="true">北,東,南,西,北東,南東,南西,北西,北北東,東南東,南南西,西北西,東北東,南南東,西南西,北北西</property>
3+ <properties name="Direction">
4+ <property name="N,E,S,W,NE,SE,SW,NW,NNE,ESE,SSW,WNW,ENE,SSE,WSW,NNW" type="string" readonly="true">北,東,南,西,北東,南東,南西,北西,北北東,東南東,南南西,西北西,東北東,南南東,西南西,北北西</property>
55 </properties>
6- <properties name="world">
7- <property name="district_replace_prompt" type="string" readonly="true">置き換えによって、地域マップ『{0}』のデータは破棄されます。
6+ <properties name="World">
7+ <property name="Are you sure to over write the district '{0}'? (Current data will be lost.)" type="string" readonly="true">置き換えによって、地域マップ『{0}』のデータは破棄されます。
88 よろしいですか?</property>
9- <property name="create_districts_prompt" type="string" readonly="true">今までのマップは全て破棄します。
9+ <property name="Are you sure to clear and replace all existing map data?" type="string" readonly="true">今までのマップは全て破棄します。
1010 よろしいですか?</property>
1111 </properties>
12- <properties name="game">
13- <property name="new_game" type="string" readonly="true">新規ゲーム</property>
14- <property name="savefile_filter" type="string" readonly="true">ゲームデータ (*.ftgd)|*.ftgd|ゲームデータ(互換形式) (*.ftgt)|*.ftgt</property>
12+ <properties name="GameManager">
13+ <property name="Unsaved game data will be lost. Are you sure?" type="string" readonly="true">
14+ セーブしていないゲームデータは破棄されます。
15+ よろしいですか?
16+ </property>
17+ <property name="NewGame" type="string" readonly="true">新規ゲーム</property>
18+ <property name="Faild to load a game from the file '{0}'." type="string" readonly="true">ファイル{0}からのゲームのロードに失敗しました。</property>
19+ <property name="game_create_error" type="string" readonly="true">新規ゲームの作成に失敗しました。</property>
20+ <property name="Game data (*.ftgd)|*.ftgd|Game data[full packaged] (*.ftgt)|*.ftgt" type="string" readonly="true">ゲームデータ (*.ftgd)|*.ftgd|ゲームデータ(互換形式) (*.ftgt)|*.ftgt</property>
1521 </properties>
1622 </properties>
\ No newline at end of file
--- trunk/core/core/game/GameManager.cs (revision 22)
+++ trunk/core/core/game/GameManager.cs (revision 23)
@@ -123,7 +123,7 @@
123123 bool b = true;
124124 if(_curGame!=null && _curGame.Modified)
125125 {
126- string text = Main.resources["game.close_game_warning"].stringValue;
126+ string text = I18n.T("Unsaved game data will be lost. Are you sure?");
127127 b = UIUtil.ConfirmMessage(text,UIMessageType.warning,UIInformLevel.normal);
128128 if( b )
129129 {
@@ -134,7 +134,7 @@
134134 return b;
135135 }
136136
137- private readonly string filterString = Core.GetString("game.savefile_filter","All|*.*");
137+ private readonly string filterString = I18n.T("Game data (*.ftgd)|*.ftgd|Game data[full packaged] (*.ftgt)|*.ftgt");
138138 /// <summary>
139139 /// Saves the current game.
140140 /// </summary>
--- trunk/core/core/view/ITargetSelector.cs (nonexistent)
+++ trunk/core/core/view/ITargetSelector.cs (revision 23)
@@ -0,0 +1,48 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+
5+namespace nft.core.view
6+{
7+ //public enum SelectionState { NONE = 0, NORMAL, WARN, DANGER }
8+ public delegate void TargetSelectorEvent(SelectionEventArgs args);
9+
10+ public class SelectionEventArgs
11+ {
12+ public enum EventTypes {SELECTION_CHANGED, PHASE_PROCEEDED, PHASE_ROLLBACKED, VIEW_CHANGED ,COMPLETED, CANCELD }
13+
14+ protected ITargetSelector selector;
15+ protected EventTypes status;
16+
17+ public SelectionEventArgs(ITargetSelector sel, EventTypes stat) {
18+ this.selector = sel;
19+ this.status = stat;
20+ }
21+
22+ EventTypes Status {
23+ get {
24+ return status;
25+ }
26+ set {
27+ status = value;
28+ }
29+ }
30+
31+ ITargetSelector TargetSelector {
32+ get {
33+ return selector;
34+ }
35+ }
36+
37+ }
38+
39+ public interface ITargetSelector
40+ {
41+ int MaxPhases { get; }
42+ int CurrentPhase { get; }
43+ object CurrentSelection { get; }
44+ event TargetSelectorEvent OnSelectionChanged;
45+ event TargetSelectorEvent OnPhaseChanged;
46+ event TargetSelectorEvent OnViewChanged;
47+ }
48+}
--- trunk/core/core/World.cs (revision 22)
+++ trunk/core/core/World.cs (revision 23)
@@ -117,7 +117,7 @@
117117 {
118118 if(!silent && !(_districts.Length>0))
119119 {// show confirmation message
120- string text = Core.GetString("world.create_districts_prompt","Are you sure to clear current map?");
120+ string text = I18n.T("Are you sure to clear and replace all existing map data?");
121121 if(!UIUtil.ConfirmMessage(text,UIMessageType.warning,UIInformLevel.normal))
122122 return;
123123 }
@@ -148,9 +148,8 @@
148148 throw new ArgumentException("cannnot replace. Location or Size does not match.");
149149 if(!silent && !(old is ProvisionalDistrict))
150150 {// show confirmation message
151- string text = Core.GetString("world.district_replace_prompt","Are you sure to replace district '{0}'?");
152- text = string.Format(text,old.Name);
153- if(!UIUtil.ConfirmMessage(text,UIMessageType.warning,UIInformLevel.normal))
151+ string msg = I18n.F("Are you sure to over write the district '{0}'? (Current data will be lost.)", old.Name);
152+ if(!UIUtil.ConfirmMessage(msg,UIMessageType.warning,UIInformLevel.normal))
154153 return;
155154 }
156155 districts[districts.IndexOf(old)]=newone;
--- trunk/core/core/geometry/Direction.cs (revision 22)
+++ trunk/core/core/geometry/Direction.cs (revision 23)
@@ -3,6 +3,7 @@
33 using System.Drawing;
44 using System.Runtime.Serialization;
55 using System.Collections.Generic;
6+using nft.framework;
67
78 namespace nft.core.geometry {
89 /// <summary>
@@ -63,7 +64,7 @@
6364 private static readonly int[] angles;
6465
6566 static Direction() {
66- string names = Core.resources["direction.names"].stringValue;
67+ string names = I18n.T("N,E,S,W,NE,SE,SW,NW,NNE,ESE,SSW,WNW,ENE,SSE,WSW,NNW");
6768 DirNames = names.Split(new char[] { ',' });
6869 Array db = Enum.GetValues(typeof(Direction16));
6970 directions = new Direction[16];
--- trunk/core/core/Core.cs (revision 22)
+++ trunk/core/core/Core.cs (revision 23)
@@ -11,16 +11,13 @@
1111 public class Core
1212 {
1313 /// <summary> Main resources. </summary>
14- public static readonly NftProperties resources = NftProperties.LoadFromFile(Directories.AppBaseDir + "nftcore.resource.xml", false);
14+ //public static readonly NftProperties resources = NftProperties.LoadFromFile(Directories.AppBaseDir + "nftcore.resource.xml", false);
1515
1616 static Core()
1717 {
18- ConfigureService.RegisterAssembly(Assembly.GetAssembly(Type.GetType("nft.core.Core")));
18+ I18n.LoadFile(Directories.AppBaseDir + "nftcore.resource.xml");
19+ ConfigureService.RegisterAssembly(Assembly.GetAssembly(Type.GetType("nft.core.Core")));
1920 }
20-
21- public static string GetString(string name, string default_val) {
22- return resources.getString(name, default_val);
23- }
2421
2522 }
2623 }
--- trunk/core/core/schedule/ClockEventQueue.cs (revision 22)
+++ trunk/core/core/schedule/ClockEventQueue.cs (revision 23)
@@ -79,7 +79,7 @@
7979 int n = list.Count;
8080 for(int i=n-1; i>0; i--){
8181 HandlerWrapper hw = list[i];
82- if (hw.handler == h) {
82+ if (hw.handler == (Delegate)h) {
8383 RemoveAt(i);
8484 }
8585 }
--- trunk/framework/contributions/ui/CtbCommandEntity.cs (revision 22)
+++ trunk/framework/contributions/ui/CtbCommandEntity.cs (revision 23)
@@ -43,7 +43,7 @@
4343
4444 if( methodName == null )
4545 {
46- string templ = Main.resources["xml.attribute_not_found"].stringValue;
46+ string templ = I18n.T("An attribute '{1}' is required for the node '{0}'.");
4747 throw new Exception(string.Format(templ,"method","name",contrib.SourceURI));
4848 }
4949 }
@@ -65,9 +65,9 @@
6565 ICommandEntity_Old entity = CreateTarget() as ICommandEntity_Old;
6666 if(entity==null)
6767 {
68- string templ = Main.resources["plugin.invalid_command_entity"].stringValue;
69- string[] args = new string[]{ commandType, targetType.Name, methodName };
70- throw new PluginXmlException(contrib,string.Format(templ,args));
68+ string[] args = new string[] { commandType, targetType.Name, methodName };
69+ string msg = I18n.F("Failed to create CommandEntity[type={0}, class={1}, method={2}].", args);
70+ throw new PluginXmlException(contrib,msg);
7171 }
7272 return entity;
7373 }
@@ -100,7 +100,7 @@
100100 }
101101 catch( Exception e )
102102 {
103- string templ = Main.resources["xml.class_load_error"].stringValue;
103+ string templ = I18n.T("Failed to create an instance of the class '{0}'.");
104104 throw new Exception(string.Format(templ,targetType.FullName,path),e);
105105 }
106106 }
--- trunk/framework/nftfw.resource.xml (revision 22)
+++ trunk/framework/nftfw.resource.xml (revision 23)
@@ -1,79 +1,75 @@
11 <?xml version="1.0" encoding="utf-8" ?>
22 <!--エラーメッセージは、改行やタブがそのまま使用されるので、ご注意ください。-->
33 <properties name="framework">
4- <properties name="directories">
5- <property name="create_dir_prompt" type="string" readonly="true">{0}は存在しません。
4+ <properties name="Directories">
5+ <property name="Directory '{0}' is not exist. Do you want to create?">{0}は存在しません。
66 作成しますか?</property>
7- <property name="errormsg_on_dir_creation" type="string" readonly="true">{0}は作成できませんでした。
7+ <property name="Failed to create a directory '{0}'. Use default path instead.">{0}は作成できませんでした。
88 標準の設定を使用します。</property>
99 </properties>
10- <properties name="plugin">
11- <property name="too_many_errors" type="string" readonly="true">プラグインロードエラーが多すぎます。以降のエラーは省略します。
12- エラーの発生したプラグインを確認するには、プラグイン一覧をご覧下さい。</property>
13- <property name="dependency_not_found" type="string" readonly="true">プラグイン{0}に必要な
14- プラグイン{1}が見つかりません。</property>
15- <property name="contrib_load_error" type="string" readonly="true">ファイル{0}
16-からのコントリビューション[{1}]のロードに失敗しました。
17- ID={2}</property>
18- <property name="plugin_load_error" type="string" readonly="true">プラグイン{0}がロードできませんでした。</property>
19- <property name="contrib_init_error" type="string" readonly="true">プラグイン{0}内のコントリビューション[{1}]が初期化できませんでした。
20- ID={2}</property>
21- <property name="invalid_command_entity" type="string" readonly="true">コマンドコントリビューションを初期化できません。
22- Type={0}
23- Class={1}
24- Method={2}</property>
25- </properties>
26- <properties name="pluginlist">
27- <property name="normal_message" type="string" readonly="true">コンピューターに使わせたくないプラグインは、
10+ <properties name="PluginListDialog">
11+ <property name="Uncheck to forbid cpu using this plug-in.">コンピューターに使わせたくないプラグインは、
2812 チェックを外して下さい。</property>
29- <property name="error_message" type="string" readonly="true">このコントリビューションは無効化できません。</property>
13+ <property name="This contribution cannot invalidate.">このコントリビューションは無効化できません。</property>
3014 </properties>
31- <properties name="xml">
32- <property name="attribute_not_found" type="string" readonly="true">XMLノード[{0}]には[{1}]属性が必要です。
15+ <properties name="nft.framework.plugin">
16+ <property name="Too many plug-in load errors! Check out remaining errors in the 'Plug-in List'.">
17+ プラグインロードエラーが多すぎます。以降のエラーは省略します。
18+ エラーの発生したプラグインを確認するには、プラグイン一覧をご覧下さい。
19+ </property>
20+ <property name="Dependent plug-in:{1} (required for the plug-in:{0}) is not found.">
21+ プラグイン{0}に必要な
22+ プラグイン{1}が見つかりません。
23+ </property>
24+ <property name="Failed to load contribution[{1}] (ID={2}) from the file '{0}'.">
25+ ファイル{0}
26+ からのコントリビューション[{1}]のロードに失敗しました。
27+ ID={2}
28+ </property>
29+ <property name="Failed to load plug-in:{0}.">プラグイン{0}がロードできませんでした。</property>
30+ <property name="Failed to initialize contribution[{1}] in the plug-in:{0}.">
31+ プラグイン{0}内のコントリビューション[{1}]が初期化できませんでした。
32+ ID={2}
33+ </property>
34+ <property name="Failed to create CommandEntity[type={0}, class={1}, method={2}].">
35+ コマンドコントリビューションを初期化できません。
36+ Type={0}
37+ Class={1}
38+ Method={2}
39+ </property>
40+ <property name="An attribute '{1}' is required for the node '{0}'.">XMLノード[{0}]には[{1}]属性が必要です。
41+ ソース:{2}</property>
42+ <property name="Failed to create an instance of the class '{0}'.">指定されたクラス[{0}]のインスタンス作成に失敗しました。
3343 ソース:{1}</property>
34- <property name="class_load_error" type="string" readonly="true">指定されたクラス[{0}]のインスタンス作成に失敗しました。
35- ソース:{1}</property>
36- <property name="class_cast_error" type="string" readonly="true">クラス[{0}]を[{1}]にキャストできません。
44+ <property name="Cannot cast the class'{0}' to the class'{1}'.">クラス[{0}]を[{1}]にキャストできません。
3745 ソース:{2}</property>
3846 </properties>
39- <properties name="global_modules">
40- <property name="load_error" type="string" readonly="true">コア・モジュール読み込みエラー</property>
47+ <properties name="GlobalModules">
48+ <property name="ERROR while loading a core module.">コア・モジュール読み込みエラー</property>
4149 </properties>
42- <properties name="webloader">
43- <property name="web_exception" type="string" readonly="true">ファイルのダウンロードに失敗しました。
50+ <properties name="WebLoader">
51+ <property name="Web Exception: {0}(state={1}, url={2} ).">ファイルのダウンロードに失敗しました。
4452 URL:{0}
4553 {1} state={2}</property>
46- <property name="other_exception" type="string" readonly="true">ダウンロード中に例外が発生しました。
54+ <property name="Exception raised while downloading url={0} .">ダウンロード中に例外が発生しました。
4755 URL:{0}</property>
4856 </properties>
49- <properties name="command">
50- <property name="exception@execute" type="string" readonly="true">コマンド[ID={0}]の実行中に例外が発生しました。</property>
57+ <properties name="nft.ui.command">
58+ <property name="Exception raised while executing the command[ID={0}].">コマンド[ID={0}]の実行中に例外が発生しました。</property>
5159 </properties>
52- <properties name="game">
53- <property name="close_game_warning" type="string" readonly="true">セーブしていないゲームデータは破棄されます。
54- よろしいですか?</property>
55- <property name="game_load_error" type="string" readonly="true">ファイル{0}からのゲームのロードに失敗しました。</property>
56- <property name="game_create_error" type="string" readonly="true">新規ゲームの作成に失敗しました。</property>
57- </properties>
58- <properties name="directxview">
59- <property name="exception@OnLoad" type="string" readonly="true">DirectXサーフェイスの初期化に失敗しました。</property>
60- <property name="exception@RecreateDrawBuffer" type="string" readonly="true">オフスクリーンサーフェイスの生成に失敗しました。</property>
61- <property name="exception@updateView" type="string" readonly="true">オフスクリーンサーフェイスの生成に失敗しました。</property>
62- <property name="exception@overrideMethod" type="string" readonly="true">描画オーバーライドメソッド{0}が例外を発生しました。</property>
63- </properties>
64- <properties name="imageutil">
65- <property name="type_rgb" type="string" readonly="true">{0}bit RGB</property>
66- <property name="type_argb" type="string" readonly="true">{0}bit ARGB</property>
67- <property name="type_indexed_color" type="string" readonly="true">{1}色パレット</property>
68- <property name="type_indexed_grayscale" type="string" readonly="true">{1}色グレー</property>
69- <property name="type_grayscale" type="string" readonly="true">{0}bit グレー</property>
60+ <properties name="ImageUtil">
61+ <property name="{0}bit RGB">{0}bit RGB</property>
62+ <property name="{0}bit ARGB">{0}bit ARGB</property>
63+ <property name="Indexed {1} Colors">{1}色パレット</property>
64+ <property name="Indexed {1} Gray scales">{1}色グレー</property>
65+ <property name="{0}bit Gray scales">{0}bit グレー</property>
7066 </properties>
71- <properties name="ui_util">
72- <property name="confirm_exit_message" type="string" readonly="true">NeoFTを終了してよろしいですか?</property>
67+ <properties name="UiUtil">
68+ <property name="Are you sure to exit 'NeoFT'?">NeoFTを終了してよろしいですか?</property>
7369 </properties>
74- <properties name="mainframe">
75- <property name="long_title" type="string" readonly="true">Neo Free Train</property>
76- <property name="short_title" type="string" readonly="true">NeoFT</property>
70+ <properties name="MainFrame">
71+ <property name="long_title">Neo Free Train</property>
72+ <property name="short_title">NeoFT</property>
7773 </properties>
7874
7975 </properties>
\ No newline at end of file
--- trunk/framework/framework/GlobalModules.cs (revision 22)
+++ trunk/framework/framework/GlobalModules.cs (revision 23)
@@ -32,7 +32,7 @@
3232 Register(gm);
3333 }
3434 }catch(Exception e){
35- string txt = Main.resources["global_modules.load_error"].stringValue;
35+ string txt = I18n.T("ERROR while loading a core module.");
3636 if(UIUtil.ShowException(txt,e,UIInformLevel.severe))
3737 throw;
3838 }
@@ -58,11 +58,11 @@
5858 } catch( Exception e ) {
5959 Debug.WriteLine(e.Message);
6060 Debug.WriteLine(e.StackTrace);
61- string templ = Main.resources["xml.class_load_error"].stringValue;
61+ string templ = I18n.T("nft.framework.plugin", "Failed to create an instance of the class '{0}'.");
6262 throw new Exception(string.Format(templ,t.FullName,node.SourceURI),e);
6363 }
6464 if(!(result is IGlobalModule)){
65- string templ = Main.resources["xml.class_cast_error"].stringValue;
65+ string templ = I18n.T("nft.framework.plugin", "Cannot cast the class'{0}' to the class'{1}'.");
6666 object[] args = new object[] { t.FullName, "IGlobalModule", node.SourceURI };
6767 throw new InvalidCastException(string.Format(templ,args));
6868 }
--- trunk/framework/framework/plugin/Contribution.cs (revision 22)
+++ trunk/framework/framework/plugin/Contribution.cs (revision 23)
@@ -29,7 +29,7 @@
2929 string short_id = contrib["id"].InnerText;
3030 if( short_id == null )
3131 {
32- string templ = Main.resources["xml.attribute_not_found"].stringValue;
32+ string templ = I18n.T("An attribute '{1}' is required for the node '{0}'.");
3333 throw new PluginXmlException(contrib,string.Format(
3434 templ,"contribution","name",contrib.SourceURI));
3535 }
@@ -45,27 +45,22 @@
4545 #endregion
4646
4747 protected Contribution(Plugin owner, ParamsReader contrib)
48- : this(owner, contrib,
49- contrib["name"].InnerTextOr("<unknown>"),
50- contrib["description"].InnerTextOr("")) {}
51-
52- protected Contribution(Plugin owner, ParamsReader contrib, string name, string description)
5348 {
49+ this.id = GenerateID(contrib);
5450 this.parent = owner;
51+ this.CtbType = ParseType(contrib);
52+ //Debug.WriteLine("name:" + name + " ,baseDir:" + baseDir);
53+ this.name = ParseName(contrib);
54+ this.description = ParseDescription(contrib);
55+ }
56+
57+ protected Contribution(Plugin owner, ParamsReader contrib, string name, string description) {
58+ this.id = GenerateID(contrib);
59+ this.parent = owner;
60+ this.CtbType = ParseType(contrib);
5561 this.name = name;
5662 this.description = description;
5763 //Debug.WriteLine("name:" + name + " ,baseDir:" + baseDir);
58- id = GenerateID(contrib);
59- try
60- {
61- CtbType = contrib["type"].InnerText;
62- }
63- catch
64- {
65- string templ = Main.resources["xml.attribute_not_found"].stringValue;
66- throw new PluginXmlException(contrib, string.Format(
67- templ, "contribution", "type", contrib.SourceURI));
68- }
6964 }
7065
7166 // for override use only. please
@@ -77,7 +72,25 @@
7772 this.name = _name;
7873 this.description = _description;
7974 }
80-
75+
76+ protected virtual string ParseName(ParamsReader r) {
77+ return r["name"].InnerTextOr("<unknown>");
78+ }
79+
80+ protected virtual string ParseDescription(ParamsReader r) {
81+ return r["description"].InnerTextOr("");
82+ }
83+
84+ protected virtual string ParseType(ParamsReader r) {
85+ try {
86+ return r["type"].InnerText;
87+ } catch {
88+ string templ = I18n.T("An attribute '{1}' is required for the node '{0}'.");
89+ throw new PluginXmlException(r, string.Format(
90+ templ, "contribution", "type", r.SourceURI));
91+ }
92+ }
93+
8194 /// <summary>
8295 /// This method is a backdoor to configure a contribution.
8396 ///
--- trunk/framework/framework/plugin/PluginManager.cs (revision 22)
+++ trunk/framework/framework/plugin/PluginManager.cs (revision 23)
@@ -143,9 +143,8 @@
143143 if(p!=null)
144144 p._state = InstallationState.FatalError;
145145
146- string templ = Main.resources["plugin.plugin_load_error"].stringValue;
147- templ+="\n"+e.Message;
148- if(ReportError(string.Format(templ,Path.GetFileName(dir)),e))
146+ string msg = I18n.F("Failed to load plug-in:{0}.",Path.GetFileName(dir));
147+ if(ReportError(msg+"\n"+e.Message,e))
149148 throw;
150149 }
151150 }
@@ -265,8 +264,9 @@
265264 }
266265 } catch (Exception e) {
267266 contrib._state = InstallationState.FatalError;
268- string templ = Main.resources["plugin.contrib_init_error"].stringValue;
269- if(ReportError(string.Format(templ, contrib.Parent.ID, "contrib.name", contrib.ID), e))
267+ string msg = I18n.F("Failed to initialize contribution[{1}] in the plug-in:{0}.",
268+ contrib.Parent.ID, "contrib.name", contrib.ID);
269+ if(ReportError(msg, e))
270270 throw;
271271 }
272272 }
@@ -286,8 +286,9 @@
286286 catch( Exception e )
287287 {
288288 contrib._state = InstallationState.FatalError;
289- string templ = Main.resources["plugin.contrib_init_error"].stringValue;
290- if(ReportError(string.Format(templ,contrib.Parent.ID,"contrib.name",contrib.ID),e))
289+ string msg = I18n.F("Failed to initialize contribution[{1}] in the plug-in:{0}.",
290+ contrib.Parent.ID, "contrib.name", contrib.ID);
291+ if(ReportError(msg,e))
291292 throw;
292293 }
293294 }
@@ -300,8 +301,9 @@
300301 monitor.Progress(2, 1, contrib.ID);
301302 } catch (Exception e) {
302303 contrib._state = InstallationState.FatalError;
303- string templ = Main.resources["plugin.contrib_init_error"].stringValue;
304- if(ReportError(string.Format(templ, contrib.Parent.ID, "contrib.name", contrib.ID), e))
304+ string msg = I18n.F("Failed to initialize contribution[{1}] in the plug-in:{0}.",
305+ contrib.Parent.ID, "contrib.name", contrib.ID);
306+ if(ReportError(msg, e))
305307 throw;
306308 }
307309 }
@@ -330,7 +332,7 @@
330332 return UIUtil.ShowException(msg, e, UIInformLevel.minor);
331333 } else {
332334 if (errCount == SkipTooMenyErrorsCount) {
333- string templ = Main.resources["plugin.too_many_errors"].stringValue;
335+ string templ = I18n.T("Too many plug-in load errors! Check out remaining errors in the 'Plug-in List'.");
334336 Exception ex = new Exception(templ,e);
335337 UIUtil.ShowException(templ, ex, UIInformLevel.minor);
336338 }
@@ -359,8 +361,8 @@
359361 string name = depend["on"].InnerText;
360362 Plugin p2 = GetPlugin(name);
361363 if (p2 == null) {
362- string templ = Main.resources["plugin.dependency_not_found"].stringValue;
363- throw new Exception(String.Format(templ, p.ID, name));
364+ string msg = I18n.F("Dependent plug-in:{1} (required for the plug-in:{0}) is not found.", p.ID, name);
365+ throw new Exception(msg);
364366 }
365367 a.Add(p2);
366368 }
@@ -480,10 +482,11 @@
480482 }
481483
482484 private string MakeContribExceptionMessage(Plugin p, ParamsReader pr) {
483- string templ = Main.resources["plugin.contrib_load_error"].stringValue;
484485 string _id = pr["id"].InnerTextOr("unknown");
485486 string _name = pr["name"].InnerTextOr("unknown");
486- return string.Format(templ, p.Uri.AbsoluteUri, _name, _id);
487+ string msg = I18n.F("Failed to load contribution[{1}] (ID={2}) from the file '{0}'.",
488+ p.Uri.AbsoluteUri, _name, _id);
489+ return msg;
487490 }
488491
489492 /// <summary>
--- trunk/framework/framework/plugin/PluginUtil.cs (revision 22)
+++ trunk/framework/framework/plugin/PluginUtil.cs (revision 23)
@@ -79,7 +79,7 @@
7979 // give XmlNode as first argument of constructor.
8080 object result = Activator.CreateInstance(t, args);
8181 if (result == null) {
82- string templ = Main.resources["xml.class_load_error"].stringValue;
82+ string templ = I18n.T("Failed to create an instance of the class '{0}'.");
8383 throw new Exception(string.Format(templ, t.FullName, elm.SourceURI));
8484 }
8585 return result;
@@ -86,7 +86,7 @@
8686 } catch (TargetInvocationException e) {
8787 Debug.WriteLine(e.Message);
8888 Debug.WriteLine(e.StackTrace);
89- string templ = Main.resources["xml.class_load_error"].stringValue;
89+ string templ = I18n.T("Failed to create an instance of the class '{0}'.");
9090 throw new Exception(string.Format(templ, t.FullName, elm.SourceURI), e);
9191 }
9292 }
@@ -124,7 +124,7 @@
124124 Type t = loadTypeFromManifest(e);
125125 if (required != null) {
126126 if (!required.IsAssignableFrom(t)) {
127- string templ = Main.resources["xml.class_cast_error"].stringValue;
127+ string templ = I18n.T("Cannot cast the class'{0}' to the class'{1}'.");
128128 object[] a2 = new object[] { t.FullName, required.Name, e.SourceURI };
129129 throw new InvalidCastException(string.Format(templ, a2));
130130 }
--- trunk/framework/framework/plugin/CtbAnonymousCtbFactory.cs (revision 22)
+++ trunk/framework/framework/plugin/CtbAnonymousCtbFactory.cs (revision 23)
@@ -25,7 +25,7 @@
2525 Type t = PluginUtil.loadTypeFromManifest(reader["class"]);
2626 if (!t.IsSubclassOf(required))
2727 {
28- string templ = Main.resources["xml.class_cast_error"].stringValue;
28+ string templ = I18n.T("Cannot cast the class'{0}' to the class'{1}'.");
2929 object[] a2 = new object[] { t.FullName, required.Name, reader.SourceURI };
3030 throw new InvalidCastException(string.Format(templ, a2));
3131 }
@@ -39,7 +39,7 @@
3939 {
4040 Debug.WriteLine(e.Message);
4141 Debug.WriteLine(e.StackTrace);
42- string templ = Main.resources["xml.class_load_error"].stringValue;
42+ string templ = I18n.T("Failed to create an instance of the class '{0}'.");
4343 throw new Exception(string.Format(templ, t.FullName, reader.SourceURI), e);
4444 }
4545 return result;
--- trunk/framework/framework/WebLoader.cs (revision 22)
+++ trunk/framework/framework/WebLoader.cs (revision 23)
@@ -42,15 +42,14 @@
4242 catch(WebException e)
4343 {
4444 Debug.WriteLine(e);
45- string templ = Main.resources["webloader.web_exception"].stringValue;
46- string msg = string.Format(templ,url,e.Message,e.Status);
45+ string msg = I18n.F("Web Exception: {0}(state={1}, url={2} ).",e.Message,e.Status.ToString(),url);
4746 UIUtil.Message(msg,UIMessageType.warning,UIInformLevel.normal);
4847 }
4948 catch(Exception e)
5049 {
5150 Debug.WriteLine(e);
52- string templ = Main.resources["webloader.other_exception"].stringValue;
53- if(UIUtil.ShowException(string.Format(templ,url),e,UIInformLevel.normal))
51+ string msg = I18n.F("Exception raised while downloading url={0} .", url);
52+ if(UIUtil.ShowException(msg,e,UIInformLevel.normal))
5453 throw;
5554 }
5655 return null;
@@ -70,14 +69,14 @@
7069 catch(WebException e)
7170 {
7271 Debug.WriteLine(e);
73- string templ = Main.resources["webloader.web_exception"].stringValue;
74- string msg = string.Format(templ,url,e.Message,e.Status);
72+ string msg = I18n.F("Web Exception: {1}(state={2}, url={0} ).",
73+ e.Message, e.Status.ToString(), url);
7574 UIUtil.Message(msg,UIMessageType.warning,UIInformLevel.normal);
7675 }
7776 catch(Exception e)
7877 {
7978 Debug.WriteLine(e);
80- string templ = Main.resources["webloader.other_exception"].stringValue;
79+ string templ = I18n.F("Exception raised while downloading url={0} .",url);
8180 if(UIUtil.ShowException(string.Format(templ,url),e,UIInformLevel.normal))
8281 throw;
8382 }
@@ -97,15 +96,14 @@
9796 catch(WebException e)
9897 {
9998 Debug.WriteLine(e);
100- string templ = Main.resources["webloader.web_exception"].stringValue;
101- string msg = string.Format(templ,url,e.Message,e.Status);
99+ string msg = I18n.F("Web Exception: {0}(state={1}, url={2} ).",e.Message,e.Status.ToString(),url);
102100 UIUtil.Message(msg,UIMessageType.warning,UIInformLevel.normal);
103101 }
104102 catch(Exception e)
105103 {
106104 Debug.WriteLine(e);
107- string templ = Main.resources["webloader.other_exception"].stringValue;
108- if(UIUtil.ShowException(string.Format(templ,url),e,UIInformLevel.normal))
105+ string msg = I18n.F("Exception raised while downloading url={0} .",url);
106+ if(UIUtil.ShowException(msg,e,UIInformLevel.normal))
109107 throw;
110108 }
111109 finally
@@ -135,15 +133,15 @@
135133 catch(WebException e)
136134 {
137135 Debug.WriteLine(e);
138- string templ = Main.resources["webloader.web_exception"].stringValue;
139- string msg = string.Format(templ,url,e.Message,e.Status);
136+ string msg = I18n.F("Web Exception: {1}(state={2}, url={0} )."
137+ , url, e.Message, e.Status.ToString());
140138 UIUtil.Message(msg,UIMessageType.warning,UIInformLevel.normal);
141139 }
142140 catch(Exception e)
143141 {
144142 Debug.WriteLine(e);
145- string templ = Main.resources["webloader.other_exception"].stringValue;
146- if(UIUtil.ShowException(string.Format(templ,url),e,UIInformLevel.normal))
143+ string msg = I18n.F("Exception raised while downloading url={0} .",url);
144+ if (UIUtil.ShowException(msg, e, UIInformLevel.normal))
147145 throw;
148146 }
149147 }
@@ -179,15 +177,14 @@
179177 }
180178 catch(WebException e)
181179 {
182- string templ = Main.resources["webloader.web_exception"].stringValue;
183- string msg = string.Format(templ,url,e.Message,e.Status);
180+ string msg = I18n.F("Web Exception: {0}(state={1}, url={2} ).",e.Message,e.Status.ToString(),url);
184181 UIUtil.Message(msg,UIMessageType.warning,UIInformLevel.normal);
185182 }
186183 catch(Exception e)
187184 {
188185 Debug.WriteLine(e);
189- string templ = Main.resources["webloader.other_exception"].stringValue;
190- if(UIUtil.ShowException(string.Format(templ,url),e,UIInformLevel.normal))
186+ string msg = I18n.F("Exception raised while downloading url={0} .",url);
187+ if(UIUtil.ShowException(msg,e,UIInformLevel.normal))
191188 throw;
192189 }
193190 }
@@ -227,8 +224,7 @@
227224 {
228225 Debug.WriteLine(e);
229226 Release();
230- string templ = Main.resources["webloader.web_exception"].stringValue;
231- string msg = string.Format(templ,url,e.Message,e.Status);
227+ string msg = I18n.F("Web Exception: {0}(state={1}, url={2} ).",e.Message,e.Status.ToString(),url);
232228 UIUtil.Message(msg,UIMessageType.warning,UIInformLevel.normal);
233229 }
234230 catch(Exception e)
@@ -235,8 +231,8 @@
235231 {
236232 Debug.WriteLine(e);
237233 Release();
238- string templ = Main.resources["webloader.other_exception"].stringValue;
239- if(UIUtil.ShowException(string.Format(templ,url),e,UIInformLevel.normal))
234+ string msg = I18n.F("Exception raised while downloading url={0} .",url);
235+ if(UIUtil.ShowException(msg,e,UIInformLevel.normal))
240236 throw;
241237 }
242238 }
--- trunk/framework/framework/Directories.cs (revision 22)
+++ trunk/framework/framework/Directories.cs (revision 23)
@@ -80,8 +80,8 @@
8080 }
8181 catch(Exception e)
8282 {
83- string templ = Main.resources["directories.errormsg_on_dir_creation"].stringValue;
84- if(UIUtil.ShowException(string.Format(templ,path),e,UIInformLevel.normal))
83+ string msg = I18n.F("Failed to create a directory '{0}'. Use default path instead.", path);
84+ if(UIUtil.ShowException(msg,e,UIInformLevel.normal))
8585 throw;
8686 }
8787 return defaultPath;
@@ -121,8 +121,8 @@
121121 {
122122 if(prompt)
123123 {
124- string templ = Main.resources["directories.create_dir_prompt"].stringValue;
125- if(!UIUtil.YesNoMessage(string.Format(templ,dir)))
124+ string msg = I18n.F("Directory '{0}' is not exist. Do you want to create?",dir);
125+ if(!UIUtil.YesNoMessage(msg))
126126 return null;
127127 }
128128 Directory.CreateDirectory(dir);
--- trunk/framework/framework/I18n.cs (nonexistent)
+++ trunk/framework/framework/I18n.cs (revision 23)
@@ -0,0 +1,234 @@
1+using System;
2+using System.Reflection;
3+using nft.util;
4+using System.Globalization;
5+using System.Collections.Generic;
6+using System.Diagnostics;
7+
8+namespace nft.framework
9+{
10+ /// <summary>
11+ /// Internationalization, the utility class for multi language support.
12+ /// 多言語対応
13+ /// (I18nとは I-18文字略-n という意味でプログラミング言語の世界でよく使われる略称です。)
14+ /// </summary>
15+ public class I18n
16+ {
17+ static readonly string COMMON_GROUP = "common";
18+ static List<NftProperties> properties;
19+ static private CultureInfo invariant;
20+
21+ static I18n() {
22+ invariant = CultureInfo.InvariantCulture;
23+ properties = new List<NftProperties>();
24+ }
25+
26+ public static void LoadFile(string path) {
27+ NftProperties pps = NftProperties.LoadFromFile(path, true);
28+ properties.Insert(0,pps);
29+ }
30+
31+ /// <summary>
32+ /// Get localized text by name, pick caller automatically from stack.
33+ /// </summary>
34+ /// <param name="name"></param>
35+ /// <returns></returns>
36+ public static string T(string name) {
37+ return _T1(name, ToGroupCandidates(1), true);
38+ }
39+
40+ /// <summary>
41+ /// Get localized text by name, suppose caller type as group name.
42+ /// </summary>
43+ /// <param name="caller">caller object or type</param>
44+ /// <param name="name"></param>
45+ /// <returns></returns>
46+ public static string T(object caller, string name) {
47+ return _T2(name, ToGroupCandidates(caller), true);
48+ }
49+
50+ /// <summary>
51+ /// Get localized text by name, pick caller automatically from stack.
52+ /// 'args' are inserted using String.Format method.
53+ /// </summary>
54+ /// <param name="name"></param>
55+ /// <param name="args">insert parameters</param>
56+ /// <returns></returns>
57+ public static string F(string name, params object[] args) {
58+ string ret = _T1(name, ToGroupCandidates(1), true);
59+ return String.Format(ret,ToString(args));
60+ }
61+
62+ /// <summary>
63+ /// Get localized text by name, pick caller automatically from stack.
64+ /// placeholders of parameters like a part '#{hoge}' are replaced by dictionary value.
65+ /// </summary>
66+ /// <param name="name"></param>
67+ /// <param name="_params">insert parameters</param>
68+ /// <returns></returns>
69+ public static string F(string name, Dictionary<string, object> _params) {
70+ string ret = _T1(name, ToGroupCandidates(1), true);
71+ foreach (KeyValuePair<string, object> pair in _params) {
72+ ret = ret.Replace("#{" + pair.Key + "}", ToString(pair.Value));
73+ }
74+ return ret;
75+ }
76+
77+ /// <summary>
78+ /// Get localized text by name, suppose caller type as group name.
79+ /// 'args' are inserted using String.Format method.
80+ /// </summary>
81+ /// <param name="caller">caller object or type</param>
82+ /// <param name="name"></param>
83+ /// <param name="args">insert parameters</param>
84+ /// <returns></returns>
85+ public static string F2(object caller, string name, params object[] args) {
86+ string ret = _T2(name, ToGroupCandidates(caller), true);
87+ return String.Format(ret, ToString(args));
88+ }
89+
90+ /// <summary>
91+ /// Get localized text by name, suppose caller type as group name.
92+ /// placeholders of parameters like a part '#{hoge}' are replaced by dictionary value.
93+ /// </summary>
94+ /// <param name="caller">caller object or type</param>
95+ /// <param name="name"></param>
96+ /// <param name="_params">insert parameters</param>
97+ /// <returns></returns>
98+ public static string F2(object caller, string name, Dictionary<string, object> _params) {
99+ string ret = _T2(name, ToGroupCandidates(caller), true);
100+ foreach (KeyValuePair<string, object> pair in _params) {
101+ ret = ret.Replace("#{" + pair.Key + "}", ToString(pair.Value));
102+ }
103+ return ret;
104+ }
105+
106+ protected static string _T1(string name, ICollection<string> groupCandidates, bool strict) {
107+ string ret = null;
108+ foreach (string group in groupCandidates) {
109+ ret = GetText(group, name);
110+ if (ret != null) return ret;
111+ }
112+ if (strict) {
113+ string tname = name.Trim();
114+ if (!tname.Equals(name)) {
115+ ret = _T1(tname, groupCandidates, false);
116+ if (ret != null) return '?' + ret;
117+ }
118+ TextInfo textInfo = invariant.TextInfo;
119+ tname = textInfo.ToTitleCase(name);
120+ if(!tname.Equals(name)) {
121+ ret = _T1(tname, groupCandidates, false);
122+ if (ret != null) return '?' + ret;
123+ }
124+ tname = textInfo.ToLower(name);
125+ if(!tname.Equals(name)) {
126+ ret = _T1(tname, groupCandidates, false);
127+ if (ret != null) return '?' + ret;
128+ }
129+ }
130+ return name;
131+ }
132+
133+ protected static string _T2(string name, ICollection<string> groupCandidates, bool strict) {
134+ string ret = null;
135+ int n = 0;
136+ foreach (string group in groupCandidates) {
137+ ret = GetText(group, name);
138+ if (ret != null) {
139+ return (n == 0) ? ret : '?' + ret;
140+ }
141+ n++;
142+ }
143+ if (strict) {
144+ string tname = name.Trim();
145+ if (!tname.Equals(name)) {
146+ ret = _T2(tname, groupCandidates, false);
147+ if (ret != null) return '?' + ret;
148+ }
149+ TextInfo textInfo = invariant.TextInfo;
150+ tname = textInfo.ToTitleCase(name);
151+ if (!tname.Equals(name)) {
152+ ret = _T2(tname, groupCandidates, false);
153+ if (ret != null) return '?' + ret;
154+ }
155+ tname = textInfo.ToLower(name);
156+ if (!tname.Equals(name)) {
157+ ret = _T2(tname, groupCandidates, false);
158+ if (ret != null) return '?' + ret;
159+ }
160+ }
161+ return name;
162+ }
163+
164+ protected static string GetText(string group, string name) {
165+ foreach(NftProperties pps in properties){
166+ Property p1 = pps[group + Property.SEPARATOR + name, false];
167+ if (p1 != null) return p1.stringValue;
168+ }
169+ return null;
170+ }
171+
172+ protected static string ToString(object param) {
173+ return param.ToString();
174+ }
175+
176+ protected static object[] ToString(ref object[] _params) {
177+ int n = _params.Length;
178+ for (int i = 0; i < n; i++) {
179+ _params[i] = ToString(_params[i]);
180+ }
181+ return _params;
182+ }
183+
184+ protected static ICollection<String> ToGroupCandidates(int stackcount) {
185+ StackFrame callerFrame = new StackFrame(++stackcount);
186+ Type callerType = callerFrame.GetMethod().ReflectedType;
187+ return TypeToGroupCandidates(callerType);
188+ }
189+
190+ protected static ICollection<String> ToGroupCandidates(object caller) {
191+ if (caller is string || caller.GetType().IsPrimitive) {
192+ List<String> l1 = new List<string>(1);
193+ string name = caller.ToString();
194+ l1.Add(name);
195+ string tname = name.ToLower();
196+ if (!tname.Equals(name)) {
197+ l1.Add(tname);
198+ }
199+ tname = name.ToUpper();
200+ if (!tname.Equals(name)) {
201+ l1.Add(tname);
202+ }
203+ l1.Add(COMMON_GROUP);
204+ return l1;
205+ } else {
206+ Type callerType = (Type)((caller is Type) ? caller : caller.GetType());
207+ return TypeToGroupCandidates(callerType);
208+ }
209+ }
210+
211+ protected static ICollection<String> TypeToGroupCandidates(Type callerType) {
212+ List<Type> lstTypes = new List<Type>();
213+ lstTypes.Add(callerType);
214+ lstTypes.AddRange(callerType.GetInterfaces());
215+ Type btype = callerType.BaseType;
216+ while(btype!=null && !btype.Assembly.GlobalAssemblyCache){
217+ lstTypes.Add(btype);
218+ btype = btype.BaseType;
219+ }
220+ List<String> l1 = new List<string>(lstTypes.Count*2);
221+ List<String> l2 = new List<string>(lstTypes.Count);
222+ foreach (Type t in lstTypes) {
223+ l1.Add(t.FullName);
224+ l1.Add(t.Name);
225+ string ns = t.Namespace;
226+ if (!l2.Contains(ns)) l2.Add(ns);
227+ }
228+ l1.AddRange(l2);
229+ l1.Add(COMMON_GROUP);
230+ return l1;
231+ }
232+
233+ }
234+}
--- trunk/framework/framework/Main.cs (revision 22)
+++ trunk/framework/framework/Main.cs (revision 23)
@@ -30,7 +30,7 @@
3030 { get{ return theFrame; } }
3131
3232 /// <summary> Main resources. </summary>
33- public static readonly NftProperties resources = NftProperties.LoadFromFile(Directories.AppBaseDir + "nftfw.resource.xml", false);
33+ //public static readonly NftProperties resources = NftProperties.LoadFromFile(Directories.AppBaseDir + "nftfw.resource.xml", false);
3434
3535 /// <summary> Plug-ins. </summary>
3636 public static readonly PluginManager pluginManager = new PluginManager();
@@ -69,7 +69,7 @@
6969 /// </param>
7070 public static void init( string[] args, MainFrame frame )
7171 {
72-
72+ I18n.LoadFile(Directories.AppBaseDir + "nftfw.resource.xml");
7373 Hashtable h_args = paresArgs(args);
7474 Directories.Initialize(h_args);
7575
--- trunk/framework/ui/command/CommandUI.cs (revision 22)
+++ trunk/framework/ui/command/CommandUI.cs (revision 23)
@@ -216,7 +216,7 @@
216216 subcmds = new Dictionary<string, TriggerCommandUI>(subitems);
217217 }
218218
219- public ISingleSelectCommandEntity CommandEntity {
219+ public new ISingleSelectCommandEntity CommandEntity {
220220 get { return base.CommandEntity as ISingleSelectCommandEntity; }
221221 set {
222222 ISingleSelectCommandEntity old = CommandEntity;
--- trunk/framework/ui/command/CommandUI2.cs (revision 22)
+++ trunk/framework/ui/command/CommandUI2.cs (revision 23)
@@ -112,8 +112,7 @@
112112 }
113113 catch(Exception e)
114114 {
115- string templ = Main.resources["command.exception@execute"].stringValue;
116- string msg = string.Format(templ,new string[]{ID});
115+ string msg = I18n.T("Exception raised while executing the command[ID={0}].",ID);
117116 if(UIUtil.ShowException(msg,e,UIInformLevel.normal))
118117 throw;
119118 }
--- trunk/framework/ui/mainframe/MainFrame.cs (revision 22)
+++ trunk/framework/ui/mainframe/MainFrame.cs (revision 23)
@@ -281,8 +281,8 @@
281281
282282 public void SetSubTitle(string subtitle)
283283 {
284- string long_title = Main.resources["mainframe.long_title"].stringValue;
285- string short_title = Main.resources["mainframe.short_title"].stringValue;
284+ string long_title = I18n.T("long_title");
285+ string short_title = I18n.T("short_title");
286286 if( subtitle==null || subtitle.Trim().Length==0 )
287287 this.Text = long_title;
288288 else
--- trunk/framework/util/UIUtil.cs (revision 22)
+++ trunk/framework/util/UIUtil.cs (revision 23)
@@ -118,7 +118,7 @@
118118 public bool ShowException(string text,Exception caused,UIInformLevel level)
119119 {
120120 Debug.WriteLine(text);
121- Debug.WriteLine(caused.StackTrace);
121+ DumpException(caused);
122122 return ShowErrorMessageBox(null, text, caused);
123123 }
124124 public bool ShowQueryMessage(string text,UIQueryType query,UIMessageType type,UIInformLevel level)
@@ -130,6 +130,16 @@
130130 }
131131 }
132132
133+ public static void DumpException(Exception ex) {
134+ if (ex.InnerException != null) {
135+ DumpException(ex.InnerException);
136+ Debug.WriteLine("----wrapped by----");
137+ }
138+ Debug.WriteLine(ex.GetType().Name + ":" + ex.Message);
139+ if(ex.HelpLink!=null) Debug.WriteLine(ex.HelpLink);
140+ Debug.WriteLine(ex.StackTrace);
141+ }
142+
133143 public static bool ShowErrorMessageBox(IWin32Window owner, string msg, Exception e )
134144 {
135145 Assembly asm = Assembly.LoadFrom(Directories.AppBaseDir+"NFT.UI.DLL");
@@ -137,7 +147,7 @@
137147 BindingFlags flags = BindingFlags.Public|BindingFlags.Static|BindingFlags.InvokeMethod;
138148 DialogResult ret = (DialogResult)t.InvokeMember("Show", flags, null, null, new object[] { owner, msg, e });
139149 if (DialogResult.Abort==ret && Main.mainFrame!=null) {
140- string msg2 = Main.resources["ui_util.confirm_exit_message"].stringValue;
150+ string msg2 =I18n.T("Are you sure to exit 'NeoFT'?");
141151 DialogResult r2 = MessageBox.Show(null, msg2, "NeoFT", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
142152 if (r2 == DialogResult.Yes) {
143153 Environment.Exit(0);
--- trunk/framework/util/ImageUtil.cs (revision 22)
+++ trunk/framework/util/ImageUtil.cs (revision 23)
@@ -69,11 +69,11 @@
6969 static private readonly string fmt_type_grayscale;
7070
7171 static ImageUtil() {
72- fmt_type_rgb = Main.resources["imageutil.type_rgb"].stringValue;
73- fmt_type_argb = Main.resources["imageutil.type_argb"].stringValue;
74- fmt_type_indexed_color = Main.resources["imageutil.type_indexed_color"].stringValue;
75- fmt_type_indexed_grayscale = Main.resources["imageutil.type_indexed_grayscale"].stringValue;
76- fmt_type_grayscale = Main.resources["imageutil.type_grayscale"].stringValue;
72+ fmt_type_rgb = I18n.T("{0}bit RGB");
73+ fmt_type_argb = I18n.T("{0}bit ARGB");
74+ fmt_type_indexed_color = I18n.T("Indexed {1} Colors");
75+ fmt_type_indexed_grayscale = I18n.T("Indexed {1} Gray scales");
76+ fmt_type_grayscale = I18n.T("{0}bit Gray scales");
7777
7878 Array arr = Enum.GetValues(typeof(PixelFormat));
7979 formatTable = new Dictionary<PixelFormat, ImageColorFormat>(arr.Length);
--- trunk/framework/util/Property.cs (revision 22)
+++ trunk/framework/util/Property.cs (revision 23)
@@ -13,7 +13,7 @@
1313 [Serializable]
1414 public class Property
1515 {
16- public const char SEPARATOR = '.';
16+ public const char SEPARATOR = '/';
1717 public readonly bool isReadonly;
1818 public readonly string name;
1919 public readonly bool isStatic;
@@ -59,12 +59,15 @@
5959
6060 }
6161
62- internal protected Property(XmlNode node)
62+ internal protected Property(XmlNode node) : this(node, false) {
63+ }
64+
65+ internal protected Property(XmlNode node, bool default_readonly)
6366 {
6467 this.name = XmlUtil.GetAttribute(node,"name");
6568 this.type = XmlUtil.GetAttribute(node,"type","string");
6669 this.isStatic = bool.Parse(XmlUtil.GetAttribute(node,"static","false"));
67- this.isReadonly = bool.Parse(XmlUtil.GetAttribute(node,"readonly","false"));
70+ this.isReadonly = bool.Parse(XmlUtil.GetAttribute(node,"readonly", default_readonly.ToString()));
6871 switch(type)
6972 {
7073 case "int":
--- trunk/framework/util/Properties.cs (revision 22)
+++ trunk/framework/util/Properties.cs (revision 23)
@@ -46,18 +46,24 @@
4646 XmlNode cn = ie.Current as XmlNode;
4747 Property p;
4848 if(cn.Name.Equals("properties"))
49- p = new NftProperties(cn);
49+ p = new NftProperties(cn, isReadonly);
5050 else
51- p = new Property(cn);
51+ p = new Property(cn, isReadonly);
5252 AddProperty(p);
5353 }
5454 }
5555
56+ public Property this[string name, bool raise_error] {
57+ get {
58+ return PickNode(name, raise_error);
59+ }
60+ }
61+
5662 public Property this[string name]
5763 {
5864 get
5965 {
60- return PickNode(name);
66+ return PickNode(name, true);
6167 }
6268 }
6369 #region get value methods.
@@ -121,21 +127,30 @@
121127 /// </summary>
122128 /// <param name="name"></param>
123129 /// <returns></returns>
124- protected Property PickNode(string fullpath )
130+ protected Property PickNode(string fullpath, bool raise_error)
125131 {
126132 int i = fullpath.IndexOf(SEPARATOR);
127- if(i==0 || i==fullpath.Length)
128- throw new ArgumentException("blank node is not allowed in :"+fullpath);
129- if(i==-1)
130- return table[fullpath] as Property;
131- else
132- {
133- NftProperties p = table[fullpath.Substring(0,i)] as NftProperties;
134- if(p!=null)
135- return p.PickNode(fullpath.Substring(i+1));
136- else
137- throw new ArgumentException("property node ["+fullpath+"] is not found.");
138- }
133+ if (i == 0 || i == fullpath.Length) {
134+ if (raise_error) {
135+ throw new ArgumentException("blank node is not allowed in :" + fullpath);
136+ } else {
137+ return null;
138+ }
139+ }
140+ if (i == -1) {
141+ return table[fullpath] as Property;
142+ } else {
143+ NftProperties p = table[fullpath.Substring(0, i)] as NftProperties;
144+ if (p != null) {
145+ return p.PickNode(fullpath.Substring(i + 1), raise_error);
146+ } else {
147+ if (raise_error) {
148+ throw new ArgumentException("property node [" + fullpath + "] is not found.");
149+ } else {
150+ return null;
151+ }
152+ }
153+ }
139154 }
140155
141156 /// <summary>
--- trunk/TestLauncher/test/SomeTest.cs (revision 22)
+++ trunk/TestLauncher/test/SomeTest.cs (revision 23)
@@ -5,12 +5,34 @@
55 using nft.framework;
66 using System.IO;
77 using System.Diagnostics;
8+using System.Reflection;
89
910 namespace nft.test.test
1011 {
1112 class SomeTest
1213 {
14+
1315 [TestEntry]
16+ static private bool TestStackFrame() {
17+ for (int i = 1; i < 4; i++) {
18+ DumpStack(i);
19+ }
20+ return true;
21+ }
22+
23+ static private void DumpStack(int skip) {
24+ Debug.WriteLine("####Dump StackFrame of "+skip+" ###");
25+ StackFrame callerFrame = new StackFrame(skip);
26+ MethodBase callerMethod = callerFrame.GetMethod();
27+ Type callerType = callerMethod.ReflectedType;
28+ Debug.WriteLine("FullName=" + callerType.FullName);
29+ Debug.WriteLine("Name=" + callerType.Name);
30+ Debug.WriteLine("Namespace=" + callerType.Namespace);
31+ Debug.WriteLine("BaseType=" + callerType.BaseType.FullName);
32+ Debug.WriteLine("ReflectedType=" + callerType.ReflectedType);
33+ }
34+
35+ [TestEntry]
1436 static private bool TestConverter() {
1537 object o;
1638 o = Convert.ChangeType("123", typeof(long));
@@ -52,4 +74,6 @@
5274 }
5375
5476 }
77+
78+
5579 }
--- trunk/ui_jp/ui/system/PluginListDialog.cs (revision 22)
+++ trunk/ui_jp/ui/system/PluginListDialog.cs (revision 23)
@@ -75,10 +75,9 @@
7575 private void InitializeComponent()
7676 {
7777 this.components = new System.ComponentModel.Container();
78- System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("ノード0");
78+ System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("ノード0");
7979 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PluginListDialog));
8080 this.panel1 = new System.Windows.Forms.Panel();
81- this.labelMsg = new nft.controls.MsgAndIconLabel();
8281 this.button1 = new System.Windows.Forms.Button();
8382 this.plist = new System.Windows.Forms.ListView();
8483 this.titleColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@@ -93,11 +92,12 @@
9392 this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
9493 this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
9594 this.tabPage2 = new System.Windows.Forms.TabPage();
96- this.info = new nft.controls.UrlLinkLabel();
9795 this.pluginCtxMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
9896 this.pluginCtxMenu_OpenFile = new System.Windows.Forms.ToolStripMenuItem();
9997 this.pluginCtxMenu_OpenByExplorer = new System.Windows.Forms.ToolStripMenuItem();
10098 this.pluginCtxMenu_CopyURI = new System.Windows.Forms.ToolStripMenuItem();
99+ this.info = new nft.controls.UrlLinkLabel();
100+ this.labelMsg = new nft.controls.MsgAndIconLabel();
101101 this.panel1.SuspendLayout();
102102 this.tabControl1.SuspendLayout();
103103 this.tabPage1.SuspendLayout();
@@ -115,17 +115,6 @@
115115 this.panel1.Size = new System.Drawing.Size(432, 32);
116116 this.panel1.TabIndex = 0;
117117 //
118- // labelMsg
119- //
120- this.labelMsg.BackColor = System.Drawing.SystemColors.Control;
121- this.labelMsg.ImageIndex = -1;
122- this.labelMsg.ImageList = null;
123- this.labelMsg.Location = new System.Drawing.Point(8, 0);
124- this.labelMsg.Message = "";
125- this.labelMsg.Name = "labelMsg";
126- this.labelMsg.Size = new System.Drawing.Size(312, 32);
127- this.labelMsg.TabIndex = 1;
128- //
129118 // button1
130119 //
131120 this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@@ -194,10 +183,10 @@
194183 this.tree.ImageList = this.image;
195184 this.tree.Location = new System.Drawing.Point(0, 0);
196185 this.tree.Name = "tree";
197- treeNode2.Name = "";
198- treeNode2.Text = "ノード0";
186+ treeNode1.Name = "";
187+ treeNode1.Text = "ノード0";
199188 this.tree.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
200- treeNode2});
189+ treeNode1});
201190 this.tree.SelectedImageIndex = 0;
202191 this.tree.Size = new System.Drawing.Size(424, 199);
203192 this.tree.TabIndex = 1;
@@ -227,7 +216,7 @@
227216 this.tabPage1.Name = "tabPage1";
228217 this.tabPage1.Size = new System.Drawing.Size(424, 248);
229218 this.tabPage1.TabIndex = 0;
230- this.tabPage1.Text = "リスト表示";
219+ this.tabPage1.Text = "ファイル別表示";
231220 //
232221 // clist
233222 //
@@ -274,18 +263,8 @@
274263 this.tabPage2.Name = "tabPage2";
275264 this.tabPage2.Size = new System.Drawing.Size(424, 248);
276265 this.tabPage2.TabIndex = 1;
277- this.tabPage2.Text = "ツリー表示";
266+ this.tabPage2.Text = "タイプ別表示";
278267 //
279- // info
280- //
281- this.info.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
282- this.info.Dock = System.Windows.Forms.DockStyle.Bottom;
283- this.info.Location = new System.Drawing.Point(0, 208);
284- this.info.Name = "info";
285- this.info.Size = new System.Drawing.Size(424, 40);
286- this.info.TabIndex = 2;
287- this.info.TargetUrl = null;
288- //
289268 // pluginCtxMenu
290269 //
291270 this.pluginCtxMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -294,7 +273,7 @@
294273 this.pluginCtxMenu_CopyURI});
295274 this.pluginCtxMenu.Name = "pluginCtxMenu";
296275 this.pluginCtxMenu.ShowImageMargin = false;
297- this.pluginCtxMenu.Size = new System.Drawing.Size(184, 92);
276+ this.pluginCtxMenu.Size = new System.Drawing.Size(184, 70);
298277 this.pluginCtxMenu.Opening += new System.ComponentModel.CancelEventHandler(this.pluginCtxMenu_Opening);
299278 //
300279 // pluginCtxMenu_OpenFile
@@ -318,6 +297,27 @@
318297 this.pluginCtxMenu_CopyURI.Text = "URIをコピー";
319298 this.pluginCtxMenu_CopyURI.Click += new System.EventHandler(this.puginCtxMenu_CopyURI_Click);
320299 //
300+ // info
301+ //
302+ this.info.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
303+ this.info.Dock = System.Windows.Forms.DockStyle.Bottom;
304+ this.info.Location = new System.Drawing.Point(0, 208);
305+ this.info.Name = "info";
306+ this.info.Size = new System.Drawing.Size(424, 40);
307+ this.info.TabIndex = 2;
308+ this.info.TargetUrl = null;
309+ //
310+ // labelMsg
311+ //
312+ this.labelMsg.BackColor = System.Drawing.SystemColors.Control;
313+ this.labelMsg.ImageIndex = -1;
314+ this.labelMsg.ImageList = null;
315+ this.labelMsg.Location = new System.Drawing.Point(8, 0);
316+ this.labelMsg.Message = "";
317+ this.labelMsg.Name = "labelMsg";
318+ this.labelMsg.Size = new System.Drawing.Size(312, 32);
319+ this.labelMsg.TabIndex = 1;
320+ //
321321 // PluginListDialog
322322 //
323323 this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
@@ -495,12 +495,12 @@
495495 private void ShowInfoMessage()
496496 {
497497 labelMsg.ImageIndex = (int)UIMessageType.info;
498- labelMsg.Text = Main.resources["pluginlist.normal_message"].stringValue;
498+ labelMsg.Text = I18n.T("Uncheck to forbid cpu using this plug-in.");
499499 }
500500 private void ShowErrorMessage()
501501 {
502502 labelMsg.ImageIndex = (int)UIMessageType.alert;
503- labelMsg.Text = Main.resources["pluginlist.error_message"].stringValue;
503+ labelMsg.Text = I18n.T("This contribution cannot invalidate.");
504504 Win32Util.MessageBeep();
505505 }
506506