22
33import org .snapfx .BuildInfo ;
44import org .snapfx .demo .MainDemo ;
5+ import org .snapfx .demo .i18n .DemoLocalizationService ;
56import javafx .animation .FadeTransition ;
67import javafx .animation .Interpolator ;
78import javafx .animation .ParallelTransition ;
@@ -54,20 +55,32 @@ private AboutDialog() {
5455 * @param linkOpener callback used for opening external links
5556 */
5657 public static void show (Window owner , Consumer <String > linkOpener ) {
58+ show (owner , linkOpener , new DemoLocalizationService (AboutDialog .class .getModule ()));
59+ }
60+
61+ /**
62+ * Shows the About dialog.
63+ *
64+ * @param owner owner window for modality; can be {@code null}
65+ * @param linkOpener callback used for opening external links
66+ * @param localizationService localization service used for demo strings
67+ */
68+ public static void show (Window owner , Consumer <String > linkOpener , DemoLocalizationService localizationService ) {
5769 Objects .requireNonNull (linkOpener , "linkOpener" );
70+ Objects .requireNonNull (localizationService , "localizationService" );
5871
5972 Alert alert = new Alert (Alert .AlertType .INFORMATION );
6073 if (owner != null ) {
6174 alert .initOwner (owner );
6275 }
6376
64- alert .setTitle ("About SnapFX" );
77+ alert .setTitle (localizationService . text ( "demo.about.title" ) );
6578 alert .setHeaderText (null );
6679
6780 DialogPane dialogPane = alert .getDialogPane ();
6881 dialogPane .setGraphic (null );
6982 dialogPane .setPrefWidth (620 );
70- dialogPane .setContent (createContent (linkOpener ));
83+ dialogPane .setContent (createContent (linkOpener , localizationService ));
7184
7285 applyDialogIcon (alert );
7386 alert .showAndWait ();
@@ -93,27 +106,28 @@ static String getYusukeLicenseUrl() {
93106 return YUSUKE_LICENSE_URL ;
94107 }
95108
96- private static VBox createContent (Consumer <String > linkOpener ) {
97- Label titleLabel = new Label ("SnapFX Docking Framework" );
109+ private static VBox createContent (Consumer <String > linkOpener , DemoLocalizationService localizationService ) {
110+ Label titleLabel = new Label ();
111+ localizationService .bind (titleLabel , "demo.about.header.title" );
98112 titleLabel .setStyle (MainDemo .FX_FONT_WEIGHT_BOLD + "-fx-font-size: 18px;" );
99113
100- Label versionLabel = new Label ("Version " + BuildInfo .getVersion ());
114+ Label versionLabel = new Label ();
115+ localizationService .bind (versionLabel , "demo.about.version" , BuildInfo .getVersion ());
101116 versionLabel .setStyle (MainDemo .FX_FONT_WEIGHT_BOLD );
102117
103- Label descriptionLabel = new Label (
104- "A high-performance, lightweight JavaFX docking framework\n " +
105- "designed for professional IDE-like applications."
106- );
118+ Label descriptionLabel = new Label ();
119+ localizationService .bind (descriptionLabel , "demo.about.description" );
107120 descriptionLabel .setWrapText (true );
108121
109- Label easterEggLabel = new Label ("Easter egg unlocked: docking energy is now at 100%." );
122+ Label easterEggLabel = new Label ();
123+ localizationService .bind (easterEggLabel , "demo.about.easterEgg" );
110124 easterEggLabel .setWrapText (true );
111125 easterEggLabel .setVisible (false );
112126 easterEggLabel .setManaged (false );
113127 easterEggLabel .setOpacity (0.0 );
114128 easterEggLabel .setStyle ("-fx-text-fill: #2873b8; -fx-font-style: italic;" );
115129
116- Node logoNode = createLogoNode ();
130+ Node logoNode = createLogoNode (localizationService );
117131 if (logoNode instanceof ImageView logoView ) {
118132 installEasterEggAnimation (logoView , easterEggLabel );
119133 }
@@ -125,20 +139,25 @@ private static VBox createContent(Consumer<String> linkOpener) {
125139 HBox header = new HBox (16 , logoNode , headerText );
126140 header .setAlignment (Pos .CENTER_LEFT );
127141
128- Label licenseTitle = new Label ("Icon Credits" );
142+ Label licenseTitle = new Label ();
143+ localizationService .bind (licenseTitle , "demo.about.iconCredits" );
129144 licenseTitle .setStyle (MainDemo .FX_FONT_WEIGHT_BOLD );
130145
131146 FlowPane yusukeCredits = new FlowPane (5 , 5 );
147+ Label someIconsByLabel = new Label ();
148+ localizationService .bind (someIconsByLabel , "demo.about.someIconsBy" );
149+ Label licensedUnderLabel = new Label ();
150+ localizationService .bind (licensedUnderLabel , "demo.about.licensedUnder" );
132151 yusukeCredits .getChildren ().addAll (
133- new Label ( "Some icons by" ) ,
152+ someIconsByLabel ,
134153 createHyperlink ("Yusuke Kamiyamane" , YUSUKE_AUTHOR_URL , linkOpener ),
135- new Label ( "licensed under" ) ,
154+ licensedUnderLabel ,
136155 createHyperlink ("Creative Commons Attribution 3.0" , YUSUKE_LICENSE_URL , linkOpener ),
137156 new Label ("." )
138157 );
139158
140159 Hyperlink flaticonCredits = createHyperlink (
141- "Logout icons created by Pixel perfect - Flaticon" ,
160+ localizationService . text ( "demo.about.flaticonCredit" ) ,
142161 FLATICON_CREDIT_URL ,
143162 linkOpener
144163 );
@@ -156,13 +175,13 @@ private static VBox createContent(Consumer<String> linkOpener) {
156175 return content ;
157176 }
158177
159- private static Node createLogoNode () {
178+ private static Node createLogoNode (DemoLocalizationService localizationService ) {
160179 ImageView logoView = createImageView (CONTENT_LOGO_RESOURCE , 110 );
161180 if (logoView != null ) {
162181 return logoView ;
163182 }
164183
165- Label fallback = new Label ("SnapFX" );
184+ Label fallback = new Label (localizationService . text ( "demo.about.logoFallback" ) );
166185 fallback .setStyle (MainDemo .FX_FONT_WEIGHT_BOLD + "-fx-font-size: 28px;" );
167186 return fallback ;
168187 }
0 commit comments